Class ReaderCharacterIterator

java.lang.Object
org.apache.regexp.ReaderCharacterIterator
All Implemented Interfaces:
CharacterIterator

public final class ReaderCharacterIterator extends Object implements CharacterIterator
Encapsulates java.io.Reader as CharacterIterator
Version:
CVS $Id: ReaderCharacterIterator.java 518156 2007-03-14 14:31:26Z vgritsenko $
Author:
Ales Novak
  • Field Details

    • reader

      private final Reader reader
      Underlying reader
    • buff

      private final StringBuffer buff
      Buffer of read chars
    • closed

      private boolean closed
      read end?
  • Constructor Details

    • ReaderCharacterIterator

      public ReaderCharacterIterator(Reader reader)
      Parameters:
      reader - a Reader, which is parsed
  • Method Details

    • substring

      public String substring(int beginIndex, int endIndex)
      Specified by:
      substring in interface CharacterIterator
      Returns:
      a substring
    • substring

      public String substring(int beginIndex)
      Specified by:
      substring in interface CharacterIterator
      Returns:
      a substring
    • charAt

      public char charAt(int pos)
      Specified by:
      charAt in interface CharacterIterator
      Returns:
      a character at the specified position.
    • isEnd

      public boolean isEnd(int pos)
      Specified by:
      isEnd in interface CharacterIterator
      Returns:
      true iff if the specified index is after the end of the character stream
    • read

      private int read(int n) throws IOException
      Reads n characters from the stream and appends them to the buffer
      Throws:
      IOException
    • readAll

      private void readAll() throws IOException
      Reads rest of the stream.
      Throws:
      IOException
    • ensure

      private void ensure(int idx) throws IOException
      Reads chars up to the idx
      Throws:
      IOException