java.io
Class FilterReader

java.lang.Object
  extended by java.io.Reader
      extended by java.io.FilterReader
All Implemented Interfaces:
Closeable, Readable
Direct Known Subclasses:
PushbackReader

public abstract class FilterReader
extends Reader

This is the common superclass of all standard classes that filter input. It acts as a layer on top of an underlying Reader and simply redirects calls made to it to the subordinate Reader instead. Subclasses of this class perform additional filtering functions in addition to simply redirecting the call.

When creating a subclass of FilterReader, override the appropriate methods to implement the desired filtering. However, note that the read(char[]) method does not need to be overridden as this class redirects calls to that method to read(yte[], int, int) instead of to the subordinate Reader} read(yte[]) method.


Field Summary
protected  Reader in
          This is the subordinate Reader to which method calls are redirected
 
Fields inherited from class java.io.Reader
lock
 
Constructor Summary
protected FilterReader(Reader in)
          Create a FilterReader with the specified subordinate Reader.
 
Method Summary
 void close()
          This method closes the stream by calling the close() method of the underlying stream.
 void mark(int readlimit)
          Calls the in.mark(int) method.
 boolean markSupported()
          Calls the in.markSupported() method.
 int read()
          Calls the in.read() method
 int read(char[] buf, int offset, int len)
          Calls the in.read(char[], int, int) method.
 boolean ready()
          Calls the in.read() method.
 void reset()
          Calls the in.reset() method.
 long skip(long num_chars)
          Calls the in.skip(long) method
 
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

in

protected Reader in
This is the subordinate Reader to which method calls are redirected

Constructor Detail

FilterReader

protected FilterReader(Reader in)
Create a FilterReader with the specified subordinate Reader. The lock of the new FilterReader will be set to in.lock.

Parameters:
in - The subordinate Reader
Method Detail

mark

public void mark(int readlimit)
          throws IOException
Calls the in.mark(int) method.

Overrides:
mark in class Reader
Parameters:
readlimit - The parameter passed to in.mark(int)
Throws:
IOException - If an error occurs

markSupported

public boolean markSupported()
Calls the in.markSupported() method.

Overrides:
markSupported in class Reader
Returns:
true if mark/reset is supported, false otherwise

reset

public void reset()
           throws IOException
Calls the in.reset() method.

Overrides:
reset in class Reader
Throws:
IOException - If an error occurs

ready

public boolean ready()
              throws IOException
Calls the in.read() method.

Overrides:
ready in class Reader
Returns:
The value returned from in.available()
Throws:
IOException - If an error occurs

skip

public long skip(long num_chars)
          throws IOException
Calls the in.skip(long) method

Overrides:
skip in class Reader
Parameters:
num_chars - The requested number of chars to skip.
Returns:
The value returned from in.skip(long)
Throws:
IOException - If an error occurs

read

public int read()
         throws IOException
Calls the in.read() method

Overrides:
read in class Reader
Returns:
The value returned from in.read()
Throws:
IOException - If an error occurs

read

public int read(char[] buf,
                int offset,
                int len)
         throws IOException
Calls the in.read(char[], int, int) method.

Specified by:
read in class Reader
Parameters:
buf - The buffer to read chars into
offset - The index into the buffer to start storing chars
len - The maximum number of chars to read.
Returns:
The value retured from in.read(char[], int, int)
Throws:
IOException - If an error occurs

close

public void close()
           throws IOException
This method closes the stream by calling the close() method of the underlying stream.

Specified by:
close in interface Closeable
Specified by:
close in class Reader
Throws:
IOException - If an error occurs