Top Description Fields Constructors Methods
com.ning.compress.gzip

public Class GZIPUncompressor

extends Uncompressor
Class Inheritance
Imports
java.io.IOException, java.util.zip.CRC32, .DataFormatException, .Deflater, .Inflater, com.ning.compress.*

com.ning.compress.Uncompressor implementation for uncompressing GZIP encoded data in "push" mode, in which input is not read using java.io.InputStream but rather pushed to uncompressor in variable length chunks.

Field Summary

Modifier and TypeField and Description
protected final CRC32
protected byte[]
_decodeBuffer

Buffer used for data uncompressed from _inputBuffer.

protected int
_flags

Header flags read from gzip header

protected final GZIPRecycler
protected final DataHandler
_handler

Handler that will receive uncompressed data.

protected int
_headerCRC

Expected CRC for header, from gzip file itself.

protected Inflater
protected final int
protected final BufferRecycler
_recycler

Object that handles details of buffer recycling

protected int
_skippedBytes

Simple counter used when skipping fixed number of bytes

protected int
_state

Current decoding state, which determines meaning of following byte(s).

protected boolean
_terminated

Flag set if DataHandler indicates that processing should be terminated.

protected int
_trailerCount

Number of bytes that trailer indicates preceding data stream should have had.

protected int
_trailerCRC

CRC container in trailer, should match calculated CRC over data

protected static final int
DECODE_BUFFER_SIZE

For decoding we should use buffer that is big enough to contain typical amount of decoded data; 64k seems like a nice big number

protected static final int
DEFAULT_CHUNK_SIZE

Size of input chunks fed to underlying decoder.

protected static final int
protected static final int
protected static final int
protected static final int
protected static final int
protected static final byte
protected static final byte
protected static final int
STATE_BODY

State in which we are buffering compressed data for decompression

protected static final int
protected static final int
protected static final int
protected static final int
protected static final int
protected static final int
protected static final int
protected static final int
protected static final int
protected static final int
protected static final int
STATE_INITIAL

State in which a new compression stream can start.

protected static final int
protected static final int
protected static final int
protected static final int
protected static final int
protected static final int
protected static final int
protected static final int

Constructor Summary

AccessConstructor and Description
public
public
GZIPUncompressor(DataHandler h, int inputChunkLength)

public
GZIPUncompressor(DataHandler h, int inputChunkLength, BufferRecycler bufferRecycler, GZIPRecycler gzipRecycler)

Method Summary

Modifier and TypeMethod and Description
private final int
_handleHeader(byte[] comp, int offset, final int end)

private final int
_handleTrailer(byte[] comp, int offset, final int end)

protected final boolean
_hasFlag(int flag)

protected void
_reportBadHeader(byte[] comp, int nextOffset, int end, int relative)

protected void
protected void
public void
complete()

Implements abstract com.ning.compress.Uncompressor.complete.

Method called to indicate that all data to uncompress has already been fed.
public boolean
feedCompressedData(byte[] comp, int offset, int len)

Implements abstract com.ning.compress.Uncompressor.feedCompressedData.

Method called to feed more compressed data to be uncompressed, and sent to possible listeners.

Field Detail

_crcback to summary
protected final CRC32 _crc
_decodeBufferback to summary
protected byte[] _decodeBuffer

Buffer used for data uncompressed from _inputBuffer.

_flagsback to summary
protected int _flags

Header flags read from gzip header

_gzipRecyclerback to summary
protected final GZIPRecycler _gzipRecycler
_handlerback to summary
protected final DataHandler _handler

Handler that will receive uncompressed data.

_headerCRCback to summary
protected int _headerCRC

Expected CRC for header, from gzip file itself.

_inflaterback to summary
protected Inflater _inflater
_inputChunkLengthback to summary
protected final int _inputChunkLength
_recyclerback to summary
protected final BufferRecycler _recycler

Object that handles details of buffer recycling

_skippedBytesback to summary
protected int _skippedBytes

Simple counter used when skipping fixed number of bytes

_stateback to summary
protected int _state

Current decoding state, which determines meaning of following byte(s).

_terminatedback to summary
protected boolean _terminated

Flag set if DataHandler indicates that processing should be terminated.

_trailerCountback to summary
protected int _trailerCount

Number of bytes that trailer indicates preceding data stream should have had.

_trailerCRCback to summary
protected int _trailerCRC

CRC container in trailer, should match calculated CRC over data

DECODE_BUFFER_SIZEback to summary
protected static final int DECODE_BUFFER_SIZE

For decoding we should use buffer that is big enough to contain typical amount of decoded data; 64k seems like a nice big number

DEFAULT_CHUNK_SIZEback to summary
protected static final int DEFAULT_CHUNK_SIZE

Size of input chunks fed to underlying decoder. Since it is not 100% clear what its effects are on

FCOMMENTback to summary
protected static final int FCOMMENT
FEXTRAback to summary
protected static final int FEXTRA
FHCRCback to summary
protected static final int FHCRC
FNAMEback to summary
protected static final int FNAME
GZIP_MAGICback to summary
protected static final int GZIP_MAGIC
GZIP_MAGIC_0back to summary
protected static final byte GZIP_MAGIC_0
GZIP_MAGIC_1back to summary
protected static final byte GZIP_MAGIC_1
STATE_BODYback to summary
protected static final int STATE_BODY

State in which we are buffering compressed data for decompression

STATE_HEADER_COMMENTback to summary
protected static final int STATE_HEADER_COMMENT
STATE_HEADER_COMP_TYPEback to summary
protected static final int STATE_HEADER_COMP_TYPE
STATE_HEADER_CRC0back to summary
protected static final int STATE_HEADER_CRC0
STATE_HEADER_CRC1back to summary
protected static final int STATE_HEADER_CRC1
STATE_HEADER_EXTRA0back to summary
protected static final int STATE_HEADER_EXTRA0
STATE_HEADER_EXTRA1back to summary
protected static final int STATE_HEADER_EXTRA1
STATE_HEADER_FLAGSback to summary
protected static final int STATE_HEADER_FLAGS
STATE_HEADER_FNAMEback to summary
protected static final int STATE_HEADER_FNAME
STATE_HEADER_SIG1back to summary
protected static final int STATE_HEADER_SIG1
STATE_HEADER_SKIPback to summary
protected static final int STATE_HEADER_SKIP
STATE_INITIALback to summary
protected static final int STATE_INITIAL

State in which a new compression stream can start.

STATE_TRAILER_CRC1back to summary
protected static final int STATE_TRAILER_CRC1
STATE_TRAILER_CRC2back to summary
protected static final int STATE_TRAILER_CRC2
STATE_TRAILER_CRC3back to summary
protected static final int STATE_TRAILER_CRC3
STATE_TRAILER_INITIALback to summary
protected static final int STATE_TRAILER_INITIAL
STATE_TRAILER_LEN0back to summary
protected static final int STATE_TRAILER_LEN0
STATE_TRAILER_LEN1back to summary
protected static final int STATE_TRAILER_LEN1
STATE_TRAILER_LEN2back to summary
protected static final int STATE_TRAILER_LEN2
STATE_TRAILER_LEN3back to summary
protected static final int STATE_TRAILER_LEN3

Constructor Detail

GZIPUncompressorback to summary
public GZIPUncompressor(DataHandler h)
GZIPUncompressorback to summary
public GZIPUncompressor(DataHandler h, int inputChunkLength)
GZIPUncompressorback to summary
public GZIPUncompressor(DataHandler h, int inputChunkLength, BufferRecycler bufferRecycler, GZIPRecycler gzipRecycler)

Method Detail

_handleHeaderback to summary
private final int _handleHeader(byte[] comp, int offset, final int end) throws IOException
_handleTrailerback to summary
private final int _handleTrailer(byte[] comp, int offset, final int end) throws IOException
_hasFlagback to summary
protected final boolean _hasFlag(int flag)
_reportBadHeaderback to summary
protected void _reportBadHeader(byte[] comp, int nextOffset, int end, int relative) throws GZIPException
_throwInternalback to summary
protected void _throwInternal() throws GZIPException
_throwInternalback to summary
protected void _throwInternal(String msg) throws GZIPException
completeback to summary
public void complete() throws IOException

Implements abstract com.ning.compress.Uncompressor.complete.

Doc from com.ning.compress.Uncompressor.complete.

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.

Annotations
@Override
feedCompressedDataback to summary
public boolean feedCompressedData(byte[] comp, int offset, int len) throws IOException

Implements abstract com.ning.compress.Uncompressor.feedCompressedData.

Doc from com.ning.compress.Uncompressor.feedCompressedData.

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

Returns:boolean

True, if caller should process and feed more data; false if caller is not interested in more data and processing should be terminated. (and complete should be called immediately)

Annotations
@Override