TreeProtocol¶
-
public class
TreeProtocol
¶ Manages a connection with an input stream that carries a tree, in agreement with our tree protocol. Operators may come as strings or coded as integers.
Constructors¶
TreeProtocol¶
-
public
TreeProtocol
(InputStream is)¶ Creates one TreeProtocol. Opens a reader on the stream “is”.
TreeProtocol¶
-
public
TreeProtocol
(BufferedReader reader)¶ Creates one TreeProtocol. Opens a reader on the stream “reader”.
Methods¶
position¶
-
public int
position
()¶ - Returns
the index of the last thing (operator or value) read. This index starts at 0 (before the first thing is read).
readOperator¶
readPrefixTree¶
readString¶
readTree¶
readTree¶
-
public Tree
readTree
()¶ Read a Tree with this protocol.
- Throws
IOException – when operator is incorrect or when stream is empty.
- Returns
the next incoming complete Tree on the InputStream. Advances the pointer in the InputStream to the next token immediately following this returned tree. Attaches to the top of the returned tree an annotation with the “position” in the protocol just after the top operator of this tree was read.