com.jkristian.io
Class FilteredByteInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by com.jkristian.io.FilteredByteInputStream
All Implemented Interfaces:
java.io.Closeable
Direct Known Subclasses:
FilteredCharInputStream, InputFilterInputStream

public abstract class FilteredByteInputStream
extends java.io.InputStream

A stream that produces input by reading from an underlying source and optionally transforming the data through a chain of FilterOutputStreams.

This class is not thread-safe.


Field Summary
static int CHUNK_LENGTH
          The default amount of data (from the underlying source) to process at a time.
 
Constructor Summary
FilteredByteInputStream()
           
 
Method Summary
 int available()
           
 void close()
           
protected abstract  int filterInput()
          Copy data from the underlying input stream into the filter chain.
protected  void flush()
          Flush the filters into the output.
 java.io.OutputStream getByteFilter()
           
 void mark(int readAheadLimit)
           
 boolean markSupported()
           
 int read()
           
 int read(byte[] b)
           
 int read(byte[] b, int off, int len)
           
protected abstract  boolean ready()
           
 void reset()
           
 void setByteFilter(java.io.OutputStream filter)
          Set the tail of the chain of FilterOutputStream objects.
 long skip(long n)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CHUNK_LENGTH

public static final int CHUNK_LENGTH
The default amount of data (from the underlying source) to process at a time.

See Also:
Constant Field Values
Constructor Detail

FilteredByteInputStream

public FilteredByteInputStream()
Method Detail

getByteFilter

public java.io.OutputStream getByteFilter()
Returns:
a reference to the tail of the chain of FilterOutputStream objects.

setByteFilter

public void setByteFilter(java.io.OutputStream filter)
Set the tail of the chain of FilterOutputStream objects. Recommended usage is: setByteFilter(new YourFilterClass(getByteFilter()));


ready

protected abstract boolean ready()
                          throws java.io.IOException
Returns:
true if some input is known to be available.
Throws:
java.io.IOException

filterInput

protected abstract int filterInput()
                            throws java.io.IOException
Copy data from the underlying input stream into the filter chain.

Returns:
a positive number if some input data were processed.
Throws:
java.io.IOException

flush

protected void flush()
              throws java.io.IOException
Flush the filters into the output.

Throws:
java.io.IOException

read

public int read(byte[] b,
                int off,
                int len)
         throws java.io.IOException
Overrides:
read in class java.io.InputStream
Throws:
java.io.IOException

read

public int read(byte[] b)
         throws java.io.IOException
Overrides:
read in class java.io.InputStream
Throws:
java.io.IOException

read

public int read()
         throws java.io.IOException
Specified by:
read in class java.io.InputStream
Throws:
java.io.IOException

skip

public long skip(long n)
          throws java.io.IOException
Overrides:
skip in class java.io.InputStream
Throws:
java.io.IOException

available

public int available()
              throws java.io.IOException
Overrides:
available in class java.io.InputStream
Throws:
java.io.IOException

markSupported

public boolean markSupported()
Overrides:
markSupported in class java.io.InputStream

mark

public void mark(int readAheadLimit)
Overrides:
mark in class java.io.InputStream

reset

public void reset()
           throws java.io.IOException
Overrides:
reset in class java.io.InputStream
Throws:
java.io.IOException

close

public void close()
           throws java.io.IOException
Specified by:
close in interface java.io.Closeable
Overrides:
close in class java.io.InputStream
Throws:
java.io.IOException