com.twelvemonkeys.io.enc
Class DecoderStream

java.lang.Object
  extended by java.io.InputStream
      extended by java.io.FilterInputStream
          extended by com.twelvemonkeys.io.enc.DecoderStream
All Implemented Interfaces:
Closeable

public final class DecoderStream
extends FilterInputStream

An InputStream that provides on-the-fly decoding from an underlying stream.

Version:
$Id: //depot/branches/personal/haraldk/twelvemonkeys/release-2/twelvemonkeys-core/src/main/java/com/twelvemonkeys/io/enc/DecoderStream.java#2 $
Author:
Harald Kuhr
See Also:
EncoderStream, Decoder

Field Summary
protected  ByteBuffer buffer
           
protected  Decoder decoder
           
 
Fields inherited from class java.io.FilterInputStream
in
 
Constructor Summary
DecoderStream(InputStream pStream, Decoder pDecoder)
          Creates a new decoder stream and chains it to the input stream specified by the pStream argument.
DecoderStream(InputStream pStream, Decoder pDecoder, int pBufferSize)
          Creates a new decoder stream and chains it to the input stream specified by the pStream argument.
 
Method Summary
 int available()
           
protected  int fill()
          Fills the buffer, by decoding data from the underlying input stream.
 int read()
           
 int read(byte[] pBytes, int pOffset, int pLength)
           
 long skip(long pLength)
           
 
Methods inherited from class java.io.FilterInputStream
close, mark, markSupported, read, reset
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

buffer

protected final ByteBuffer buffer

decoder

protected final Decoder decoder
Constructor Detail

DecoderStream

public DecoderStream(InputStream pStream,
                     Decoder pDecoder)
Creates a new decoder stream and chains it to the input stream specified by the pStream argument. The stream will use a default decode buffer size.

Parameters:
pStream - the underlying input stream.
pDecoder - the decoder that will be used to decode the underlying stream
See Also:
FilterInputStream.in

DecoderStream

public DecoderStream(InputStream pStream,
                     Decoder pDecoder,
                     int pBufferSize)
Creates a new decoder stream and chains it to the input stream specified by the pStream argument.

Parameters:
pStream - the underlying input stream.
pDecoder - the decoder that will be used to decode the underlying stream
pBufferSize - the size of the decode buffer
See Also:
FilterInputStream.in
Method Detail

available

public int available()
              throws IOException
Overrides:
available in class FilterInputStream
Throws:
IOException

read

public int read()
         throws IOException
Overrides:
read in class FilterInputStream
Throws:
IOException

read

public int read(byte[] pBytes,
                int pOffset,
                int pLength)
         throws IOException
Overrides:
read in class FilterInputStream
Throws:
IOException

skip

public long skip(long pLength)
          throws IOException
Overrides:
skip in class FilterInputStream
Throws:
IOException

fill

protected int fill()
            throws IOException
Fills the buffer, by decoding data from the underlying input stream.

Returns:
the number of bytes decoded, or -1 if the end of the file is reached
Throws:
IOException - if an I/O error occurs


Copyright © 2015. All Rights Reserved.