Class CharReaderScanner

    • Constructor Detail

      • CharReaderScanner

        public CharReaderScanner()
        The constructor.
      • CharReaderScanner

        public CharReaderScanner​(Reader reader)
        The constructor.
        Parameters:
        reader - the (initial) Reader.
      • CharReaderScanner

        public CharReaderScanner​(int capacity)
        The constructor.
        Parameters:
        capacity - the buffer capacity.
      • CharReaderScanner

        public CharReaderScanner​(int capacity,
                                 Reader reader)
        The constructor.
        Parameters:
        capacity - the buffer capacity.
        reader - the (initial) Reader.
    • Method Detail

      • setReader

        public void setReader​(Reader reader)
        Resets this buffer for reuse with a new Reader.
        Parameters:
        reader - the new Reader to set. May be null to entirely clear this buffer.
      • isEos

        public boolean isEos()
        Specified by:
        isEos in interface CharStreamScanner
        Overrides:
        isEos in class AbstractCharStreamScanner
        Returns:
        true if the end of stream (EOS) has been reached, false otherwise. If true (EOS) the internal buffer contains the entire rest of the data to scan in memory. If then also all data is consumed from the buffer, EOT has been reached. For instances of that are not backed by an underlying stream of data (like CharSequenceScanner) this method will always return true.
      • isEot

        public boolean isEot()
        Specified by:
        isEot in interface CharStreamScanner
        Overrides:
        isEot in class AbstractCharStreamScanner
        Returns:
        true if end of text (EOT) is known to have been reached, false otherwise. The returned result will be almost the same as !CharStreamScanner.hasNext() but this method will not modify the state of this scanner (read additional data, modify buffers, etc.). However, if the underlying stream is already consumed without returning -1 to signal EOS this method may return false even though the next call of CharStreamScanner.hasNext() may also return false.
      • expectStrict

        public boolean expectStrict​(String expected,
                                    boolean ignoreCase)
        Description copied from interface: CharStreamScanner
        This method acts as CharStreamScanner.expect(String, boolean) but if the expected String is NOT completely present, no character is consumed and the state of the scanner remains unchanged.
        Attention:
        This method requires lookahead. For implementations that are backed by an underlying stream (or reader) the length of the expected String shall not exceed the available lookahead size (buffer capacity given at construction time). Otherwise the method may fail.
        Parameters:
        expected - is the expected string.
        ignoreCase - - if true the case of the characters is ignored when compared.
        Returns:
        true if the expected string was successfully consumed from this scanner, false otherwise.