org.apache.regexp

Class StreamCharacterIterator

Implemented Interfaces:
CharacterIterator

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

Encapsulates java.io.InputStream as CharacterIterator.
Version:
CVS $Id: StreamCharacterIterator.java 126148 2004-02-17 13:37:54Z vgritsenko $
Author:
Ales Novak

Field Summary

private StringBuffer
buff
Buffer of read chars
private boolean
closed
read end?
private InputStream
is
Underlying is

Constructor Summary

StreamCharacterIterator(InputStream is)

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 beginIndex)
String
substring(int beginIndex, int endIndex)

Field Details

buff

private final StringBuffer buff
Buffer of read chars

closed

private boolean closed
read end?

is

private final InputStream is
Underlying is

Constructor Details

StreamCharacterIterator

public StreamCharacterIterator(InputStream is)
Parameters:
is - an InputStream, 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 beginIndex)
Specified by:
substring in interface CharacterIterator
Returns:
a substring

substring

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

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