- java.lang.Object
-
- com.rabbitmq.jms.parse.sql.SqlTokenStream
-
- All Implemented Interfaces:
TokenStream<com.rabbitmq.jms.parse.sql.SqlToken,java.lang.Integer>
public class SqlTokenStream extends java.lang.Object implements TokenStream<com.rabbitmq.jms.parse.sql.SqlToken,java.lang.Integer>
A simple stream of SQL tokens generated from an input character sequence at instantiation time.Apart from the
TokenStreamoperations this implementation also supports agetResidue()method, which returns the character sequence remaining after lexical scanning. If this is not empty, the tokeniser failed to completely scan the input.
-
-
Constructor Summary
Constructors Constructor Description SqlTokenStream(java.lang.CharSequence cseq)The constructor builds the whole token stream from the given character sequence by tokenising it.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description com.rabbitmq.jms.parse.sql.SqlTokengetNext()Increment position in the stream; no-op if already at the end.java.lang.CharSequencegetResidue()After this object is instantiated there may be characters in the initial sequence which were not able to be tokenized.booleanmoreTokens()java.lang.Integerposition()com.rabbitmq.jms.parse.sql.SqlTokenreadToken()Reads token at the current position and the position is not changed.voidreset()Reset the stream to the start.voidreset(java.lang.Integer 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.
-
-
-
Constructor Detail
-
SqlTokenStream
public SqlTokenStream(java.lang.CharSequence cseq)
The constructor builds the whole token stream from the given character sequence by tokenising it. The tokens are defined by theSqlTokenTypeenumtype.This never fails with an exception, but may not consume many (or any) characters from
cseqand return most of the original sequence ingetResidue().- Parameters:
cseq- - the sequence of characters (for example aString) which is tokenized- See Also:
SqlTokenType,tokenize(CharSequence)
-
-
Method Detail
-
getResidue
public java.lang.CharSequence getResidue()
After this object is instantiated there may be characters in the initial sequence which were not able to be tokenized. The characters after which the tokenizer could not determine any more tokens are returned by this method.- Returns:
- the characters after the first non-tokenisable chars in the intial sequence.
-
moreTokens
public boolean moreTokens()
- Specified by:
moreTokensin interfaceTokenStream<com.rabbitmq.jms.parse.sql.SqlToken,java.lang.Integer>- Returns:
- true if there are more tokens after the current position in the stream
-
readToken
public com.rabbitmq.jms.parse.sql.SqlToken readToken()
Description copied from interface:TokenStreamReads token at the current position and the position is not changed.- Specified by:
readTokenin interfaceTokenStream<com.rabbitmq.jms.parse.sql.SqlToken,java.lang.Integer>- Returns:
- the current
TokenStreamin the stream if any, otherwisenull
-
getNext
public com.rabbitmq.jms.parse.sql.SqlToken getNext()
Description copied from interface:TokenStreamIncrement position in the stream; no-op if already at the end.- Specified by:
getNextin interfaceTokenStream<com.rabbitmq.jms.parse.sql.SqlToken,java.lang.Integer>- Returns:
- the next
TokenStreamin the stream if any, otherwisenull
-
position
public java.lang.Integer position()
- Specified by:
positionin interfaceTokenStream<com.rabbitmq.jms.parse.sql.SqlToken,java.lang.Integer>- Returns:
- the current position in the stream
-
stepBack
public void stepBack()
Description copied from interface:TokenStreamDecrement position in the stream; no-op if already at the beginning.- Specified by:
stepBackin interfaceTokenStream<com.rabbitmq.jms.parse.sql.SqlToken,java.lang.Integer>
-
reset
public void reset(java.lang.Integer position)
Description copied from interface:TokenStreamReset the stream to the position provided, if it is a valid position. Otherwise undefined.- Specified by:
resetin interfaceTokenStream<com.rabbitmq.jms.parse.sql.SqlToken,java.lang.Integer>- Parameters:
position- - previously returned place in the stream
-
reset
public void reset()
Description copied from interface:TokenStreamReset the stream to the start. Equivalent totokenStream.reset(START)wherePosition START = tokenStream.getPosition();was executed first after instantiation of theTokenStream.- Specified by:
resetin interfaceTokenStream<com.rabbitmq.jms.parse.sql.SqlToken,java.lang.Integer>
-
-