Class 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 TokenStream operations this implementation also supports a getResidue() 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.SqlToken getNext()
      Increment position in the stream; no-op if already at the end.
      java.lang.CharSequence getResidue()
      After this object is instantiated there may be characters in the initial sequence which were not able to be tokenized.
      boolean moreTokens()  
      java.lang.Integer position()  
      com.rabbitmq.jms.parse.sql.SqlToken readToken()
      Reads token at the current position and the position is not changed.
      void reset()
      Reset the stream to the start.
      void reset​(java.lang.Integer position)
      Reset the stream to the position provided, if it is a valid position.
      void stepBack()
      Decrement position in the stream; no-op if already at the beginning.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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 the SqlTokenType enum type.

        This never fails with an exception, but may not consume many (or any) characters from cseq and return most of the original sequence in getResidue().

        Parameters:
        cseq - - the sequence of characters (for example a String) 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:
        moreTokens in interface TokenStream<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: TokenStream
        Reads token at the current position and the position is not changed.
        Specified by:
        readToken in interface TokenStream<com.rabbitmq.jms.parse.sql.SqlToken,​java.lang.Integer>
        Returns:
        the current TokenStream in the stream if any, otherwise null
      • getNext

        public com.rabbitmq.jms.parse.sql.SqlToken getNext()
        Description copied from interface: TokenStream
        Increment position in the stream; no-op if already at the end.
        Specified by:
        getNext in interface TokenStream<com.rabbitmq.jms.parse.sql.SqlToken,​java.lang.Integer>
        Returns:
        the next TokenStream in the stream if any, otherwise null
      • position

        public java.lang.Integer position()
        Specified by:
        position in interface TokenStream<com.rabbitmq.jms.parse.sql.SqlToken,​java.lang.Integer>
        Returns:
        the current position in the stream
      • stepBack

        public void stepBack()
        Description copied from interface: TokenStream
        Decrement position in the stream; no-op if already at the beginning.
        Specified by:
        stepBack in interface TokenStream<com.rabbitmq.jms.parse.sql.SqlToken,​java.lang.Integer>
      • reset

        public void reset​(java.lang.Integer position)
        Description copied from interface: TokenStream
        Reset the stream to the position provided, if it is a valid position. Otherwise undefined.
        Specified by:
        reset in interface TokenStream<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: TokenStream
        Reset the stream to the start. Equivalent to tokenStream.reset(START) where Position START = tokenStream.getPosition(); was executed first after instantiation of the TokenStream.
        Specified by:
        reset in interface TokenStream<com.rabbitmq.jms.parse.sql.SqlToken,​java.lang.Integer>