Bali Share 1.1.18

oracle.bali.share.io
Class CompositeReader

java.lang.Object
  |
  +--java.io.Reader
        |
        +--oracle.bali.share.io.CompositeReader

public class CompositeReader
extends java.io.Reader

The CompositeReader class allows an application to combine several Readers serially and make them appear as if they were a single Reader. Each Reader is read from, in turn, until it reaches the end of it's data stream. The CompositeReader class then automatically continues reading from the next Reader.


Fields inherited from class java.io.Reader
lock
 
Constructor Summary
CompositeReader()
          Creates a new CompositeReader.
CompositeReader(java.io.Reader aReader)
          Creates a CompositeReader and makes the given reader the first reader in the sequence.
 
Method Summary
 void appendReader(java.io.Reader aReader)
          Adds a new Reader to the CompositeReader sequence.
 void close()
          Close the stream.
 int read()
          Read a single character.
 int read(char[] cbuf)
          Read characters into an array.
 int read(char[] cbuf, int off, int len)
          Read characters into a portion of an array.
 boolean ready()
          Tell whether this stream is ready to be read.
 void removeAllReaders()
          Removes all of the Readers that this CompositeReader contains.
 void reset()
          Reset the composite stream to the beginning.
 long skip(long n)
          Skip characters.
 
Methods inherited from class java.io.Reader
mark, markSupported
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CompositeReader

public CompositeReader()
Creates a new CompositeReader.
Parameters:
aReader - the first reader in the sequence

CompositeReader

public CompositeReader(java.io.Reader aReader)
Creates a CompositeReader and makes the given reader the first reader in the sequence.
Parameters:
aReader - the first reader in the sequence
Method Detail

appendReader

public void appendReader(java.io.Reader aReader)
Adds a new Reader to the CompositeReader sequence.
Parameters:
aReader - the reader to add

ready

public boolean ready()
              throws java.io.IOException
Tell whether this stream is ready to be read.
Overrides:
ready in class java.io.Reader
Returns:
True if the next read() is guaranteed not to block for input, false otherwise. Note that returning false does not guarantee that the next read will block.
Throws:
java.io.IOException - If an I/O error occurs

removeAllReaders

public void removeAllReaders()
Removes all of the Readers that this CompositeReader contains.

read

public int read()
         throws java.io.IOException
Read a single character. This method will block until a character is available, an I/O error occurs, or the end of the stream is reached.
Overrides:
read in class java.io.Reader
Returns:
The character read, as an integer in the range 0 to 16383 (0x00-0xffff), or -1 if the end of the stream has been reached
Throws:
java.io.IOException - If an I/O error occurs

read

public int read(char[] cbuf)
         throws java.io.IOException
Read characters into an array. This method will block until some input is available, an I/O error occurs, or the end of the stream is reached.
Overrides:
read in class java.io.Reader
Parameters:
cbuf - Destination buffer
Returns:
The number of bytes read, or -1 if the end of the stream has been reached
Throws:
java.io.IOException - If an I/O error occurs

read

public int read(char[] cbuf,
                int off,
                int len)
         throws java.io.IOException
Read characters into a portion of an array. This method will block until some input is available, an I/O error occurs, or the end of the stream is reached.
Overrides:
read in class java.io.Reader
Parameters:
cbuf - Destination buffer
off - Offset at which to start storing characters
len - Maximum number of characters to read
Returns:
The number of characters read, or -1 if the end of the stream has been reached
Throws:
java.io.IOException - If an I/O error occurs

skip

public long skip(long n)
          throws java.io.IOException
Skip characters. This method will block until some characters are available, an I/O error occurs, or the end of the stream is reached.
Overrides:
skip in class java.io.Reader
Parameters:
n - The number of characters to skip
Returns:
The number of characters actually skipped
Throws:
java.io.IOException - If an I/O error occurs

reset

public void reset()
           throws java.io.IOException
Reset the composite stream to the beginning. Attempts to reset Readers contained within this CompositeReader, and the next read will be attempted on the first Reader in the sequence.
Overrides:
reset in class java.io.Reader
Throws:
java.io.IOException -  

close

public void close()
           throws java.io.IOException
Close the stream. Once a stream has been closed, further read(), ready(), or reset() invocations will throw an IOException. Closing a previously-closed stream, however, has no effect.
Overrides:
close in class java.io.Reader
Throws:
java.io.IOException - If an I/O error occurs

Bali Share 1.1.18