|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.io.Reader
xtc.util.NestedReader
public class NestedReader
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 insert(Reader) and 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.
| Nested Class Summary | |
|---|---|
static interface |
NestedReader.EOFListener
Event listener to provide notification a stream has reached its end. |
| Field Summary | |
|---|---|
protected boolean |
closed
Flag for whether this nested reader has been closed. |
protected NestedReader.EOFListener |
listener
The corresponding end-of-file listener. |
protected java.util.LinkedList<NestedReader.EOFListener> |
listenerStack
The stack of listeners, with the most recently added listener at the front. |
protected java.io.Reader |
reader
The current character stream. |
protected java.util.LinkedList<java.io.Reader> |
readerStack
The stack of readers, with the most recently added stream at the front. |
| Fields inherited from class java.io.Reader |
|---|
lock |
| Constructor Summary | |
|---|---|
NestedReader(java.io.Reader in)
Create a new nested reader. |
|
| Method Summary | |
|---|---|
void |
close()
|
void |
insert(java.io.Reader in)
Insert the specified character stream. |
void |
insert(java.io.Reader in,
NestedReader.EOFListener eof)
Insert the specified character stream. |
java.io.Reader |
open(java.lang.String file)
Open the specified file. |
int |
read()
|
int |
read(char[] cbuf,
int off,
int len)
|
| Methods inherited from class java.io.Reader |
|---|
mark, markSupported, read, read, ready, reset, skip |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected boolean closed
protected java.io.Reader reader
protected NestedReader.EOFListener listener
protected java.util.LinkedList<java.io.Reader> readerStack
protected java.util.LinkedList<NestedReader.EOFListener> listenerStack
| Constructor Detail |
|---|
public NestedReader(java.io.Reader in)
in - The main stream.| Method Detail |
|---|
public java.io.Reader open(java.lang.String file)
throws java.io.IOException
file - The file name.
java.io.IOException - Signals an I/O error.
public void insert(java.io.Reader in)
throws java.io.IOException
in - The stream.
java.io.IOException - Signals an I/O error.
public void insert(java.io.Reader in,
NestedReader.EOFListener eof)
throws java.io.IOException
notifies the
specified listener.
in - The stream.eof - The listener to be notified when the specified stream
has been consumed.
java.io.IOException - Signals an I/O error.
public int read()
throws java.io.IOException
read in class java.io.Readerjava.io.IOException
public int read(char[] cbuf,
int off,
int len)
throws java.io.IOException
read in class java.io.Readerjava.io.IOException
public void close()
throws java.io.IOException
close in interface java.io.Closeableclose in class java.io.Readerjava.io.IOException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||