| java.lang.Object java.io.Reader xtc.util.NestedReader
NestedReader | public class NestedReader extends Reader (Code) | | Implementation of a nested reader. A nested reader combines
several streams into a single stream. It starts by reading from a
main stream. Additional streams are added through the
NestedReader.insert(Reader) and
NestedReader.insert(Reader,NestedReader.EOFListener) methods and are consumed
completely before returning to read from the previous stream. Note
that inserted streams are automatically closed after having being
consumed. Further note that closing a nested reader closes all
streams currently associated with that nested reader.
author: Robert Grimm version: $Revision: 1.1 $ |
Inner Class :public static interface EOFListener extends EventListener | |
Field Summary | |
protected boolean | closed Flag for whether this nested reader has been closed. | protected EOFListener | listener The corresponding end-of-file listener. | protected LinkedList | listenerStack The stack of listeners, with the most recently added listener at
the front. | protected Reader | reader The current character stream. | protected LinkedList | readerStack The stack of readers, with the most recently added stream at the
front. |
Method Summary | |
public void | close() | public void | insert(Reader in) Insert the specified character stream. | public void | insert(Reader in, EOFListener eof) Insert the specified character stream. | public Reader | open(String file) Open the specified file. | public int | read() | public int | read(char[] cbuf, int off, int len) |
closed | protected boolean closed(Code) | | Flag for whether this nested reader has been closed.
|
listener | protected EOFListener listener(Code) | | The corresponding end-of-file listener.
|
listenerStack | protected LinkedList listenerStack(Code) | | The stack of listeners, with the most recently added listener at
the front.
|
reader | protected Reader reader(Code) | | The current character stream.
|
readerStack | protected LinkedList readerStack(Code) | | The stack of readers, with the most recently added stream at the
front.
|
NestedReader | public NestedReader(Reader in)(Code) | | Create a new nested reader.
Parameters: in - The main stream. |
insert | public void insert(Reader in) throws IOException(Code) | | Insert the specified character stream. After reading all
characters from the specified stream, this nested reader silently
returns to reading characters from the current stream.
Parameters: in - The stream. throws: IOException - Signals an I/O error. |
insert | public void insert(Reader in, EOFListener eof) throws IOException(Code) | | Insert the specified character stream. After reading all
characters from the specified stream, but before returning to
read characters from the current stream, this nested reader
NestedReader.EOFListener.consumed notifies the
specified listener.
Parameters: in - The stream. Parameters: eof - The listener to be notified when the specified streamhas been consumed. throws: IOException - Signals an I/O error. |
open | public Reader open(String file) throws IOException(Code) | | Open the specified file. The implementation of this method
simply creates a new file reader with the specified file name.
Parameters: file - The file name. The corresponding character stream. throws: IOException - Signals an I/O error. |
|
|