sam.io
Class ByteArrayFilter.InputStream

java.lang.Object
  |
  +--java.io.InputStream
        |
        +--sam.io.ByteArrayFilter.InputStream
Enclosing class:
ByteArrayFilter

public class ByteArrayFilter.InputStream
extends java.io.InputStream

Instance inner-class for filtering an InputStream with outer-instance's filter, as in:


 ByteArrayFilter filter = new MyByteArrayFilter(myKey);
 InputStream input = filter.new InputStream(toBeFilteredInputStream);
 

See Also:
ByteArrayFilter.OutputStream

Constructor Summary
ByteArrayFilter.InputStream(java.io.InputStream delegee)
          Builts a new InputStream to read data that will be transparently filtered.
ByteArrayFilter.InputStream(int size, java.io.InputStream delegee)
          Builts a new InputStream to read data that will be transparently filtered.
 
Method Summary
 void close()
           
 int read()
           
 int read(byte[] data, int begin, int length)
           
 long skip(long length)
          Trivial although very efficient optimization: do not filter to-be-skipped bytes !
 
Methods inherited from class java.io.InputStream
available, mark, markSupported, read, reset
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ByteArrayFilter.InputStream

public ByteArrayFilter.InputStream(java.io.InputStream delegee)
Builts a new InputStream to read data that will be transparently filtered.

Parameters:
delegee - the underlying output stream to read to-be-filtered bytes from

ByteArrayFilter.InputStream

public ByteArrayFilter.InputStream(int size,
                                   java.io.InputStream delegee)
Builts a new InputStream to read data that will be transparently filtered.

Parameters:
size - the desired buffer size in atomic blocks (i.e. the underlying byte[] buffer will be of total length size * length, where length is the length of the enclosing ByteArrayFilter)
delegee - the underlying output stream to read to-be-filtered bytes from
Method Detail

read

public int read()
         throws java.io.IOException
Specified by:
read in class java.io.InputStream
Throws:
EOFException - if no more bytes are available
java.io.IOException

read

public int read(byte[] data,
                int begin,
                int length)
         throws java.io.IOException
Overrides:
read in class java.io.InputStream
Returns:
the number of bytes actually read
Throws:
EOFException - if no single byte is available
java.io.IOException

skip

public long skip(long length)
          throws java.io.IOException
Trivial although very efficient optimization: do not filter to-be-skipped bytes !

Overrides:
skip in class java.io.InputStream
java.io.IOException

close

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