Class BaseTokenStream


  • public class BaseTokenStream
    extends Object
    Since BaseTokens can nest, BaseTokenStream creates for clients a utility interface that allows streaming (atEnd(), next()) over a CompoundBaseToken.
    Author:
    djl 2009.03.14
    • Constructor Detail

      • BaseTokenStream

        public BaseTokenStream​(CompoundBaseToken token)
        Constructor a new BaseTokenStream on the CompoundBaseToken.
        Parameters:
        token - the CompoundBaseToken to stream over
    • Method Detail

      • isEnd

        public boolean isEnd()
        Answer a boolean indication as to whether the stream is at the end
        Returns:
        true if streaming is at an end otherwise false
      • getCurrentToken

        public BaseToken getCurrentToken()
        Answer a current BaseToken base on the position of streaming
        Returns:
        the BaseToken at the current stream position
      • next

        public BaseToken next()
        Answer the next token in the stream or null if at end. Advance the stream position.
        Returns:
        the next BaseToken in the stream
      • peek

        public BaseToken peek()
        Answer the next token in the stream or null if at end. Do not advance the stream position
        Returns:
        the next BaseToken in the stream
      • peek2

        public BaseToken[] peek2()
        Answer the next two tokens in the stream or null(s) if at end. Do not advance the stream position
        Returns:
        the next BaseToken in the stream
      • setLink

        public void setLink​(BaseTokenStream ts)
        Remember a BaseTokenStream that can be the target of streaming
        Parameters:
        ts - the remembered token stream
      • getLink

        public BaseTokenStream getLink()
        Answer a BaseTokenStream that can become the target of streaming
        Returns:
        the BaseTokenStream that can become the target of streaming