Package com.ning.compress.lzf
Class LZFUncompressor
- java.lang.Object
-
- com.ning.compress.Uncompressor
-
- com.ning.compress.lzf.LZFUncompressor
-
public class LZFUncompressor extends Uncompressor
Uncompressor
implementation for uncompressing LZF encoded data in "push" mode, in which input is not read usingInputStream
but rather pushed to uncompressor in variable length chunks.
-
-
Field Summary
Fields Modifier and Type Field Description protected int
_bytesReadFromBlock
Number of bytes that have been buffered in_inputBuffer
to be uncompressed; or copied directly from uncompressed block.protected int
_compressedLength
Number of bytes in current, compressed blockprotected byte[]
_decodeBuffer
Buffer used for data uncompressed from_inputBuffer
.protected ChunkDecoder
_decoder
Underlying decompressor we use for chunk decompression.protected DataHandler
_handler
Handler that will receive uncompressed data.protected byte[]
_inputBuffer
Buffer in which compressed input is buffered if necessary, to get full chunks for decoding.protected BufferRecycler
_recycler
protected int
_state
Current decoding state, which determines meaning of following byte(s).protected boolean
_terminated
Flag set ifDataHandler
indicates that processing should be terminated.protected int
_uncompressedLength
Number of bytes from current block, either after uncompressing data (for compressed blocks), or included in stream (for uncompressed).protected static int
STATE_HEADER_COMPRESSED_0
protected static int
STATE_HEADER_COMPRESSED_1
protected static int
STATE_HEADER_COMPRESSED_2
protected static int
STATE_HEADER_COMPRESSED_3
protected static int
STATE_HEADER_COMPRESSED_BUFFERING
protected static int
STATE_HEADER_UNCOMPRESSED_0
protected static int
STATE_HEADER_UNCOMPRESSED_1
protected static int
STATE_HEADER_UNCOMPRESSED_STREAMING
protected static int
STATE_HEADER_Z_GOTTEN
protected static int
STATE_HEADER_ZV_GOTTEN
protected static int
STATE_INITIAL
State 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)
void
complete()
Method called to indicate that all data to uncompress has already been fed.boolean
feedCompressedData(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 ifDataHandler
indicates 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_inputBuffer
to 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.IOException
Description copied from class:Uncompressor
Method 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:
feedCompressedData
in 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.IOException
Description copied from class:Uncompressor
Method 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:
complete
in 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
-
-