org.apache.regexp

Class ReaderCharacterIterator

Implemented Interfaces:
CharacterIterator

public final class ReaderCharacterIterator
extends java.lang.Object
implements CharacterIterator

Encapsulates InputStream, ...

Author:
Ales Novak

Field Summary

private StringBuffer
buff
Buffer of read chars
private boolean
closed
read end?
private Reader
reader
Underlying reader

Constructor Summary

ReaderCharacterIterator(Reader reader)

Method Summary

char
charAt(int pos)
private void
ensure(int idx)
Reads chars up to the idx
boolean
isEnd(int pos)
private int
read(int n)
Reads n characters from the stream and appends them to the buffer
private void
readAll()
Reads rest of the stream.
String
substring(int offset)
String
substring(int offset, int length)

Field Details

buff

private final StringBuffer buff
Buffer of read chars


closed

private boolean closed
read end?


reader

private final Reader reader
Underlying reader

Constructor Details

ReaderCharacterIterator

public ReaderCharacterIterator(Reader reader)

Parameters:
reader - a Reader, which is parsed

Method Details

charAt

public char charAt(int pos)
Specified by:
charAt in interface CharacterIterator

Returns:
a character at the specified position.


ensure

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


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


readAll

private void readAll()
            throws IOException
Reads rest of the stream.


substring

public String substring(int offset)
Specified by:
substring in interface CharacterIterator

Returns:
a substring


substring

public String substring(int offset,
                        int length)
Specified by:
substring in interface CharacterIterator

Returns:
a substring


Copyright © 2001-2003 Apache Software Foundation. All Rights Reserved.