edu.vt.middleware.crypt.io
Class AbstractEncodingFilterInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by java.io.FilterInputStream
          extended by edu.vt.middleware.crypt.io.AbstractEncodingFilterInputStream
All Implemented Interfaces:
Closeable
Direct Known Subclasses:
Base64FilterInputStream, HexFilterInputStream

public abstract class AbstractEncodingFilterInputStream
extends FilterInputStream

Abstract base class for filter input streams that decode encoded character bytes into raw bytes.

Version:
$Revision: 3 $
Author:
Middleware Services

Field Summary
protected  byte[] byteBuffer
          Holds bytes encoded bytes read from input stream.
protected static int CHUNK_SIZE
          Number of encoded bytes to read in one buffer filling round.
protected  DirectByteArrayOutputStream decodeBuffer
          Buffer containing decoded bytes.
protected  int position
          Position in decoded byte buffer.
 
Fields inherited from class java.io.FilterInputStream
in
 
Constructor Summary
protected AbstractEncodingFilterInputStream(InputStream in)
          Creates an input filter that decodes characters in the given input stream.
 
Method Summary
protected abstract  void fillBuffer()
          Reads characters from the input reader and decodes them to fill decodeBuffer.
protected abstract  int getDecodeBufferCapacity()
          Gets the encoder that decodes encoded character data in the input stream to raw bytes.
 int read()
          
 int read(byte[] b)
          
 int read(byte[] b, int off, int len)
          
 
Methods inherited from class java.io.FilterInputStream
available, close, mark, markSupported, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CHUNK_SIZE

protected static final int CHUNK_SIZE
Number of encoded bytes to read in one buffer filling round.

See Also:
Constant Field Values

decodeBuffer

protected final DirectByteArrayOutputStream decodeBuffer
Buffer containing decoded bytes.


byteBuffer

protected final byte[] byteBuffer
Holds bytes encoded bytes read from input stream.


position

protected int position
Position in decoded byte buffer.

Constructor Detail

AbstractEncodingFilterInputStream

protected AbstractEncodingFilterInputStream(InputStream in)
Creates an input filter that decodes characters in the given input stream.

Parameters:
in - Input stream to wrap.
Method Detail

read

public int read()
         throws IOException

Overrides:
read in class FilterInputStream
Throws:
IOException

read

public int read(byte[] b)
         throws IOException

Overrides:
read in class FilterInputStream
Throws:
IOException

read

public int read(byte[] b,
                int off,
                int len)
         throws IOException

Overrides:
read in class FilterInputStream
Throws:
IOException

getDecodeBufferCapacity

protected abstract int getDecodeBufferCapacity()
Gets the encoder that decodes encoded character data in the input stream to raw bytes.

Returns:
Encoder instance.

fillBuffer

protected abstract void fillBuffer()
                            throws IOException
Reads characters from the input reader and decodes them to fill decodeBuffer.

Throws:
IOException - On read errors.


Copyright © 2003-2011 Virginia Tech. All Rights Reserved.