public class GZIPUncompressor extends Uncompressor
Uncompressor
implementation for uncompressing
GZIP encoded data in "push" mode, in which input is not
read using InputStream
but rather pushed to
uncompressor in variable length chunks.Modifier and Type | Field and Description |
---|---|
protected CRC32 |
_crc |
protected byte[] |
_decodeBuffer
Buffer used for data uncompressed from
_inputBuffer . |
protected int |
_flags
Header flags read from gzip header
|
protected GZIPRecycler |
_gzipRecycler |
protected DataHandler |
_handler
Handler that will receive uncompressed data.
|
protected int |
_headerCRC
Expected CRC for header, from gzip file itself.
|
protected Inflater |
_inflater |
protected int |
_inputChunkLength |
protected 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 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 int |
DEFAULT_CHUNK_SIZE
Size of input chunks fed to underlying decoder.
|
protected static int |
FCOMMENT |
protected static int |
FEXTRA |
protected static int |
FHCRC |
protected static int |
FNAME |
protected static int |
GZIP_MAGIC |
protected static byte |
GZIP_MAGIC_0 |
protected static byte |
GZIP_MAGIC_1 |
protected static int |
STATE_BODY
State in which we are buffering compressed data for decompression
|
protected static int |
STATE_HEADER_COMMENT |
protected static int |
STATE_HEADER_COMP_TYPE |
protected static int |
STATE_HEADER_CRC0 |
protected static int |
STATE_HEADER_CRC1 |
protected static int |
STATE_HEADER_EXTRA0 |
protected static int |
STATE_HEADER_EXTRA1 |
protected static int |
STATE_HEADER_FLAGS |
protected static int |
STATE_HEADER_FNAME |
protected static int |
STATE_HEADER_SIG1 |
protected static int |
STATE_HEADER_SKIP |
protected static int |
STATE_INITIAL
State in which a new compression stream can start.
|
protected static int |
STATE_TRAILER_CRC1 |
protected static int |
STATE_TRAILER_CRC2 |
protected static int |
STATE_TRAILER_CRC3 |
protected static int |
STATE_TRAILER_INITIAL |
protected static int |
STATE_TRAILER_LEN0 |
protected static int |
STATE_TRAILER_LEN1 |
protected static int |
STATE_TRAILER_LEN2 |
protected static int |
STATE_TRAILER_LEN3 |
Constructor and Description |
---|
GZIPUncompressor(DataHandler h) |
GZIPUncompressor(DataHandler h,
int inputChunkLength) |
GZIPUncompressor(DataHandler h,
int inputChunkLength,
BufferRecycler bufferRecycler,
GZIPRecycler gzipRecycler) |
Modifier and Type | Method and Description |
---|---|
protected boolean |
_hasFlag(int flag) |
protected void |
_reportBadHeader(byte[] comp,
int nextOffset,
int end,
int relative) |
protected void |
_throwInternal() |
protected void |
_throwInternal(String msg) |
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.
|
protected static final int GZIP_MAGIC
protected static final byte GZIP_MAGIC_0
protected static final byte GZIP_MAGIC_1
protected static final int FHCRC
protected static final int FEXTRA
protected static final int FNAME
protected static final int FCOMMENT
protected static final int DEFAULT_CHUNK_SIZE
protected static final int DECODE_BUFFER_SIZE
protected static final int STATE_INITIAL
protected static final int STATE_HEADER_SIG1
protected static final int STATE_HEADER_COMP_TYPE
protected static final int STATE_HEADER_FLAGS
protected static final int STATE_HEADER_SKIP
protected static final int STATE_HEADER_EXTRA0
protected static final int STATE_HEADER_EXTRA1
protected static final int STATE_HEADER_FNAME
protected static final int STATE_HEADER_COMMENT
protected static final int STATE_HEADER_CRC0
protected static final int STATE_HEADER_CRC1
protected static final int STATE_TRAILER_INITIAL
protected static final int STATE_TRAILER_CRC1
protected static final int STATE_TRAILER_CRC2
protected static final int STATE_TRAILER_CRC3
protected static final int STATE_TRAILER_LEN0
protected static final int STATE_TRAILER_LEN1
protected static final int STATE_TRAILER_LEN2
protected static final int STATE_TRAILER_LEN3
protected static final int STATE_BODY
protected final DataHandler _handler
protected final BufferRecycler _recycler
protected final GZIPRecycler _gzipRecycler
protected Inflater _inflater
protected final CRC32 _crc
protected final int _inputChunkLength
protected byte[] _decodeBuffer
_inputBuffer
.protected int _state
protected boolean _terminated
DataHandler
indicates that processing should be
terminated.protected int _flags
protected int _headerCRC
protected int _skippedBytes
protected int _trailerCRC
protected int _trailerCount
public GZIPUncompressor(DataHandler h)
public GZIPUncompressor(DataHandler h, int inputChunkLength)
public GZIPUncompressor(DataHandler h, int inputChunkLength, BufferRecycler bufferRecycler, GZIPRecycler gzipRecycler)
public boolean feedCompressedData(byte[] comp, int offset, int len) throws IOException
Uncompressor
NOTE: return value was added (from void to boolean) in 0.9.9
feedCompressedData
in class Uncompressor
Uncompressor.complete()
should be called immediately)IOException
public void complete() throws IOException
Uncompressor
complete
in class Uncompressor
IOException
protected final boolean _hasFlag(int flag)
protected void _throwInternal() throws GZIPException
GZIPException
protected void _throwInternal(String msg) throws GZIPException
GZIPException
protected void _reportBadHeader(byte[] comp, int nextOffset, int end, int relative) throws GZIPException
GZIPException
Copyright © 2019. All rights reserved.