Package com.ning.compress.lzf
Class LZFUncompressor
- java.lang.Object
-
- com.ning.compress.Uncompressor
-
- com.ning.compress.lzf.LZFUncompressor
-
public class LZFUncompressor extends Uncompressor
Uncompressorimplementation for uncompressing LZF encoded data in "push" mode, in which input is not read usingInputStreambut rather pushed to uncompressor in variable length chunks.
-
-
Field Summary
Fields Modifier and Type Field Description protected int_bytesReadFromBlockNumber of bytes that have been buffered in_inputBufferto be uncompressed; or copied directly from uncompressed block.protected int_compressedLengthNumber of bytes in current, compressed blockprotected byte[]_decodeBufferBuffer used for data uncompressed from_inputBuffer.protected ChunkDecoder_decoderUnderlying decompressor we use for chunk decompression.protected DataHandler_handlerHandler that will receive uncompressed data.protected byte[]_inputBufferBuffer in which compressed input is buffered if necessary, to get full chunks for decoding.protected BufferRecycler_recyclerprotected int_stateCurrent decoding state, which determines meaning of following byte(s).protected boolean_terminatedFlag set ifDataHandlerindicates that processing should be terminated.protected int_uncompressedLengthNumber of bytes from current block, either after uncompressing data (for compressed blocks), or included in stream (for uncompressed).protected static intSTATE_HEADER_COMPRESSED_0protected static intSTATE_HEADER_COMPRESSED_1protected static intSTATE_HEADER_COMPRESSED_2protected static intSTATE_HEADER_COMPRESSED_3protected static intSTATE_HEADER_COMPRESSED_BUFFERINGprotected static intSTATE_HEADER_UNCOMPRESSED_0protected static intSTATE_HEADER_UNCOMPRESSED_1protected static intSTATE_HEADER_UNCOMPRESSED_STREAMINGprotected static intSTATE_HEADER_Z_GOTTENprotected static intSTATE_HEADER_ZV_GOTTENprotected static intSTATE_INITIALState in which a new block or end-of-stream is expected.
-
Constructor Summary
Constructors Constructor Description LZFUncompressor(DataHandler handler)LZFUncompressor(DataHandler handler, BufferRecycler bufferRecycler)LZFUncompressor(DataHandler handler, ChunkDecoder dec)LZFUncompressor(DataHandler handler, ChunkDecoder dec, BufferRecycler bufferRecycler)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private int_handleCompressed(byte[] comp, int offset, int end)private int_handleUncompressed(byte[] comp, int offset, int end)protected void_reportBadBlockType(byte[] comp, int nextOffset, int len, int type)protected void_reportBadHeader(byte[] comp, int nextOffset, int len, int relative)private void_uncompress(byte[] src, int srcOffset, int len)voidcomplete()Method called to indicate that all data to uncompress has already been fed.booleanfeedCompressedData(byte[] comp, int offset, int len)Method called to feed more compressed data to be uncompressed, and sent to possible listeners.
-
-
-
Field Detail
-
STATE_INITIAL
protected static final int STATE_INITIAL
State in which a new block or end-of-stream is expected.- See Also:
- Constant Field Values
-
STATE_HEADER_Z_GOTTEN
protected static final int STATE_HEADER_Z_GOTTEN
- See Also:
- Constant Field Values
-
STATE_HEADER_ZV_GOTTEN
protected static final int STATE_HEADER_ZV_GOTTEN
- See Also:
- Constant Field Values
-
STATE_HEADER_COMPRESSED_0
protected static final int STATE_HEADER_COMPRESSED_0
- See Also:
- Constant Field Values
-
STATE_HEADER_COMPRESSED_1
protected static final int STATE_HEADER_COMPRESSED_1
- See Also:
- Constant Field Values
-
STATE_HEADER_COMPRESSED_2
protected static final int STATE_HEADER_COMPRESSED_2
- See Also:
- Constant Field Values
-
STATE_HEADER_COMPRESSED_3
protected static final int STATE_HEADER_COMPRESSED_3
- See Also:
- Constant Field Values
-
STATE_HEADER_COMPRESSED_BUFFERING
protected static final int STATE_HEADER_COMPRESSED_BUFFERING
- See Also:
- Constant Field Values
-
STATE_HEADER_UNCOMPRESSED_0
protected static final int STATE_HEADER_UNCOMPRESSED_0
- See Also:
- Constant Field Values
-
STATE_HEADER_UNCOMPRESSED_1
protected static final int STATE_HEADER_UNCOMPRESSED_1
- See Also:
- Constant Field Values
-
STATE_HEADER_UNCOMPRESSED_STREAMING
protected static final int STATE_HEADER_UNCOMPRESSED_STREAMING
- See Also:
- Constant Field Values
-
_handler
protected final DataHandler _handler
Handler that will receive uncompressed data.
-
_decoder
protected final ChunkDecoder _decoder
Underlying decompressor we use for chunk decompression.
-
_recycler
protected final BufferRecycler _recycler
-
_state
protected int _state
Current decoding state, which determines meaning of following byte(s).
-
_terminated
protected boolean _terminated
Flag set ifDataHandlerindicates that processing should be terminated.
-
_compressedLength
protected int _compressedLength
Number of bytes in current, compressed block
-
_uncompressedLength
protected int _uncompressedLength
Number of bytes from current block, either after uncompressing data (for compressed blocks), or included in stream (for uncompressed).
-
_inputBuffer
protected byte[] _inputBuffer
Buffer in which compressed input is buffered if necessary, to get full chunks for decoding.
-
_decodeBuffer
protected byte[] _decodeBuffer
Buffer used for data uncompressed from_inputBuffer.
-
_bytesReadFromBlock
protected int _bytesReadFromBlock
Number of bytes that have been buffered in_inputBufferto be uncompressed; or copied directly from uncompressed block.
-
-
Constructor Detail
-
LZFUncompressor
public LZFUncompressor(DataHandler handler)
-
LZFUncompressor
public LZFUncompressor(DataHandler handler, BufferRecycler bufferRecycler)
-
LZFUncompressor
public LZFUncompressor(DataHandler handler, ChunkDecoder dec)
-
LZFUncompressor
public LZFUncompressor(DataHandler handler, ChunkDecoder dec, BufferRecycler bufferRecycler)
-
-
Method Detail
-
feedCompressedData
public boolean feedCompressedData(byte[] comp, int offset, int len) throws java.io.IOExceptionDescription copied from class:UncompressorMethod called to feed more compressed data to be uncompressed, and sent to possible listeners.NOTE: return value was added (from void to boolean) in 0.9.9
- Specified by:
feedCompressedDatain classUncompressor- Returns:
- True, if caller should process and feed more data; false if
caller is not interested in more data and processing should be terminated.
(and
Uncompressor.complete()should be called immediately) - Throws:
java.io.IOException
-
complete
public void complete() throws java.io.IOExceptionDescription copied from class:UncompressorMethod called to indicate that all data to uncompress has already been fed. This typically results in last block of data being uncompressed, and results being sent to listener(s); but may also throw an exception if incomplete block was passed.- Specified by:
completein classUncompressor- Throws:
java.io.IOException
-
_handleUncompressed
private final int _handleUncompressed(byte[] comp, int offset, int end) throws java.io.IOException- Throws:
java.io.IOException
-
_handleCompressed
private final int _handleCompressed(byte[] comp, int offset, int end) throws java.io.IOException- Throws:
java.io.IOException
-
_uncompress
private final void _uncompress(byte[] src, int srcOffset, int len) throws java.io.IOException- Throws:
java.io.IOException
-
_reportBadHeader
protected void _reportBadHeader(byte[] comp, int nextOffset, int len, int relative) throws java.io.IOException- Throws:
java.io.IOException
-
_reportBadBlockType
protected void _reportBadBlockType(byte[] comp, int nextOffset, int len, int type) throws java.io.IOException- Throws:
java.io.IOException
-
-