-
- Type Parameters:
Token- - the type of items in the streamPosition- - the type which implements the positions in the stream
- All Known Implementing Classes:
SqlTokenStream
public interface TokenStream<Token,Position>A read-only sequence ofTokenStreams that are read one-by-one. Reads are not destructive and the stream can be reset and reread. At any time a position may be obtained, and subsequently used to reset the stream to that position.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description TokengetNext()Increment position in the stream; no-op if already at the end.booleanmoreTokens()Positionposition()TokenreadToken()Reads token at the current position and the position is not changed.voidreset()Reset the stream to the start.voidreset(Position position)Reset the stream to the position provided, if it is a valid position.voidstepBack()Decrement position in the stream; no-op if already at the beginning.
-
-
-
Method Detail
-
moreTokens
boolean moreTokens()
- Returns:
- true if there are more tokens after the current position in the stream
-
readToken
Token readToken()
Reads token at the current position and the position is not changed.- Returns:
- the current
TokenStreamin the stream if any, otherwisenull
-
getNext
Token getNext()
Increment position in the stream; no-op if already at the end.- Returns:
- the next
TokenStreamin the stream if any, otherwisenull
-
stepBack
void stepBack()
Decrement position in the stream; no-op if already at the beginning.
-
position
Position position()
- Returns:
- the current position in the stream
-
reset
void reset(Position position)
Reset the stream to the position provided, if it is a valid position. Otherwise undefined.- Parameters:
position- - previously returned place in the stream
-
reset
void reset()
Reset the stream to the start. Equivalent totokenStream.reset(START)wherePosition START = tokenStream.getPosition();was executed first after instantiation of theTokenStream.
-
-