Class JavaCharStream

  • All Implemented Interfaces:
    CharStream

    public class JavaCharStream
    extends AbstractCharStream
    An implementation of interface CharStream, where the stream is assumed to contain only ASCII characters (with java-like unicode escape processing).
    • Field Detail

      • NEXTCHAR_BUF_SIZE

        protected static final int NEXTCHAR_BUF_SIZE
        Predefined buffer size
        See Also:
        Constant Field Values
      • nextCharBuf

        protected char[] nextCharBuf
      • nextCharInd

        protected int nextCharInd
      • inputStream

        protected java.io.Reader inputStream
    • Constructor Detail

      • JavaCharStream

        public JavaCharStream​(java.io.Reader dstream,
                              int startline,
                              int startcolumn,
                              int buffersize)
        Constructor.
      • JavaCharStream

        public JavaCharStream​(java.io.Reader dstream,
                              int startline,
                              int startcolumn)
        Constructor.
      • JavaCharStream

        public JavaCharStream​(java.io.Reader dstream)
        Constructor.
      • JavaCharStream

        public JavaCharStream​(java.io.InputStream dstream,
                              java.nio.charset.Charset encoding,
                              int startline,
                              int startcolumn,
                              int buffersize)
        Constructor.
      • JavaCharStream

        public JavaCharStream​(java.io.InputStream dstream,
                              java.nio.charset.Charset encoding,
                              int startline,
                              int startcolumn)
        Constructor.
      • JavaCharStream

        public JavaCharStream​(java.io.InputStream dstream,
                              java.nio.charset.Charset encoding)
        Constructor.
    • Method Detail

      • streamRead

        protected int streamRead​(char[] buffer,
                                 int offset,
                                 int len)
                          throws java.io.IOException
        Specified by:
        streamRead in class AbstractCharStream
        Throws:
        java.io.IOException
      • streamClose

        protected void streamClose()
                            throws java.io.IOException
        Specified by:
        streamClose in class AbstractCharStream
        Throws:
        java.io.IOException
      • fillBuff

        protected void fillBuff()
                         throws java.io.IOException
        Overrides:
        fillBuff in class AbstractCharStream
        Throws:
        java.io.IOException
      • readByte

        protected char readByte()
                         throws java.io.IOException
        Throws:
        java.io.IOException
      • adjustBuffSize

        protected void adjustBuffSize()
      • readChar

        public char readChar()
                      throws java.io.IOException
        Read a character.
        Specified by:
        readChar in interface CharStream
        Overrides:
        readChar in class AbstractCharStream
        Returns:
        the next character from the selected input
        Throws:
        java.io.IOException - on IO error
      • reInit

        public void reInit​(java.io.Reader dstream)
        Reinitialise.
      • reInit

        public void reInit​(java.io.Reader dstream,
                           int startline,
                           int startcolumn)
        Reinitialise.
      • reInit

        public void reInit​(java.io.Reader dstream,
                           int startline,
                           int startcolumn,
                           int buffersize)
        Reinitialise.
      • reInit

        public void reInit​(java.io.InputStream dstream,
                           java.nio.charset.Charset encoding)
        Reinitialise.
      • reInit

        public void reInit​(java.io.InputStream dstream,
                           java.nio.charset.Charset encoding,
                           int startline,
                           int startcolumn)
        Reinitialise.
      • reInit

        public void reInit​(java.io.InputStream dstream,
                           java.nio.charset.Charset encoding,
                           int startline,
                           int startcolumn,
                           int buffersize)
        Reinitialise.
      • done

        public void done()
        Description copied from interface: CharStream
        The lexer calls this function to indicate that it is done with the stream and hence implementations can free any resources held by this class. Again, the body of this function can be just empty and it will not affect the lexer's operation.
        Specified by:
        done in interface CharStream
        Overrides:
        done in class AbstractCharStream