Class SGMLParser.Buffer

  • Enclosing class:
    SGMLParser

    static class SGMLParser.Buffer
    extends Object
    Class which buffers the read stream.
    • Constructor Detail

      • Buffer

        Buffer​(Reader reader,
               int length)
        throws IOException
        Creates a new Buffer from the given reader with the given size.
        Parameters:
        reader - the Reader to be buffered.
        length - the length of the buffer.
        Throws:
        IOException - if an error occurs
    • Method Detail

      • isEmpty

        boolean isEmpty()
        Returns whether this buffer is currently empty. When this is the case and someone tries to read further characters this will lead to a trial to read further pieces from reader.
        Returns:
        a boolean value signifying whether this buffer is currently empty.
      • reachedEOS

        boolean reachedEOS()
        Returns whether the end of the stream is reached.
        Returns:
        a boolean specifying whether the end of the stream is reached.
      • readChar

        int readChar()
              throws IOException
        Reads a single char and returns it.
        Returns:
        an int value which is either the next char read in or -1 which signifies the end of the stream.
        Throws:
        IOException - if an error occurs
      • readArray

        int readArray​(SGMLParser.CharTester charTester)
               throws IOException
        Reads an array from reader. As a side effect, writes the field newStart. Also, if the portion of bufferArray to be read, i.e. between start and end, is empty, a new portion is buffered.
        Parameters:
        charTester - a CharTester which signifies when to end reading from the buffer.
        Returns:
        an int signifying the number of chars read or -1 which signifies the end of the stream. It is read to the next < or, if there is none, to the end of the stream. Thus there is a difference between the return values -1 and 0.
        Throws:
        IOException - if an error occurs
      • getChars

        char[] getChars()
        Returns the buffer of chars.
        Returns:
        the char[] bufferArray.
      • getStartAndMove

        int getStartAndMove()
        Moves newStart to start and returns the old value of start.
        Returns:
        the old int value of start.
      • getStart

        int getStart()
        Get method for start.
        Returns:
        start
      • getEnd

        int getEnd()
        Get method for end.
        Returns:
        end