tribble.io
Class PassThruReader

java.lang.Object
  extended by java.io.Reader
      extended by tribble.io.PassThruReader
All Implemented Interfaces:
java.io.Closeable, java.lang.Readable

public class PassThruReader
extends java.io.Reader

Pass-through character reader stream.

Reads bytes from an underlying InputStream object, returning each byte as a Unicode character code. This is effectively a character stream that reads ISO 8859-1 character codes as uninterpreted single-byte sequences, i.e., each character code is composed of a single 8-bit octet read from the input stream.

Since:
2005-04-05
Version:
$Revision: 1.1 $ $Date: 2005/04/06 04:17:06 $
Author:
David R. Tribble (david@tribble.com).
Copyright ©2005 by David R. Tribble, all rights reserved.
Permission is granted to freely use and distribute this source code provided that the original copyright and authorship notices remain intact.
See Also:
PassThruWriter

Field Summary
protected  java.io.InputStream m_in
          Underlying byte input stream.
(package private) static java.lang.String REV
          Revision information.
 
Fields inherited from class java.io.Reader
lock
 
Constructor Summary
PassThruReader(java.io.InputStream in)
          Constructor.
 
Method Summary
 void close()
          Close this input stream.
 void mark(int limit)
          Mark the present position in this input stream.
 boolean markSupported()
          Determine whether this stream supports the "mark" operation.
 int read()
          Read a single character.
 int read(char[] buf, int off, int len)
          Read a group of characters.
 boolean ready()
          Determine whether input is available in this input stream ro not.
 void reset()
          Reset the position of this input stream.
 long skip(long n)
          Skip (discard) a number of characters from this input stream.
 
Methods inherited from class java.io.Reader
read, read
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

REV

static final java.lang.String REV
Revision information.

See Also:
Constant Field Values

m_in

protected java.io.InputStream m_in
Underlying byte input stream.

Constructor Detail

PassThruReader

public PassThruReader(java.io.InputStream in)
Constructor.

Parameters:
in - Underlying input stream, which provides a source of input bytes.
Since:
1.1, 2005-04-05
Method Detail

close

public void close()
           throws java.io.IOException
Close this input stream.

Specified by:
close in interface java.io.Closeable
Specified by:
close in class java.io.Reader
Throws:
java.io.IOException - Thrown if an I/O error occurs while closing the underlying input stream.
Since:
1.1, 2005-04-05

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:
A Unicode character code, always in the range [0x0000,0x00FF], or -1 if the end of the input stream has been reached.
Throws:
java.io.IOException - Thrown if an I/O error occurs while reading the underlying input stream.
Since:
1.1, 2005-04-05

read

public int read(char[] buf,
                int off,
                int len)
         throws java.io.IOException
Read a group of characters. This method will block until a character is available, an I/O error occurs, or the end of the stream is reached.

Specified by:
read in class java.io.Reader
Parameters:
buf - An array of Unicode characters to be read. Each character is read as an 8-bit character code, always in the range [0x0000,0x00FF].
off - Index of the first character in buf to read.
len - Number of characters in buf to read.
Returns:
The number of characters actually read from the input stream, or -1 if the end of the stream has been reached.
Throws:
java.io.IOException - Thrown if an I/O error occurs while reading the underlying input stream.
Since:
1.1, 2005-04-05

skip

public long skip(long n)
          throws java.io.IOException
Skip (discard) a number of characters from this input stream.

Overrides:
skip in class java.io.Reader
Parameters:
n - The number of input characters to skip.
Returns:
The number of characters skipped.
Throws:
java.io.IOException - Thrown if an I/O error occurs in the underlying input stream.
Since:
1.1, 2005-04-05

ready

public boolean ready()
              throws java.io.IOException
Determine whether input is available in this input stream ro not.

Overrides:
ready in class java.io.Reader
Returns:
True if the next read() is guaranteed not to block for input, otherwise false. (Note that returning false does not guarantee that the next read will block.)
Throws:
java.io.IOException - Thrown if an I/O error occurs in the underlying input stream.
Since:
1.1, 2005-04-05

markSupported

public boolean markSupported()
Determine whether this stream supports the "mark" operation.

Overrides:
markSupported in class java.io.Reader
Returns:
True if the mark() method is supported, otherwise false.
Since:
1.1, 2005-04-05

mark

public void mark(int limit)
          throws java.io.IOException
Mark the present position in this input stream. A subsequent call to reset() will attempt to reposition the stream to the marked point.

Overrides:
mark in class java.io.Reader
Parameters:
limit - The minimum number of characters that can be read while still preserving the position mark. Reading more than this number of characters may cause the mark to become invalidated.
Throws:
java.io.IOException - Thrown if this operation is not supported, or if any other I/O error occurs in the underlying input stream.
Since:
1.1, 2005-04-05

reset

public void reset()
           throws java.io.IOException
Reset the position of this input stream. If the stream has been marked by a previous call to mark() and the mark is still valid, the position is reset to that mark; otherwise the stream is repostioned appropriately, e.g., the to beginning of the stream.

Overrides:
reset in class java.io.Reader
Throws:
java.io.IOException - Thrown if this operation is not supported, or if the mark has become invalidated, or if any other I/O error occurs in the underlying input stream.
Since:
1.1, 2005-04-05