Class GZIPUncompressor

java.lang.Object
com.ning.compress.Uncompressor
com.ning.compress.gzip.GZIPUncompressor

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.
  • Field Details

    • GZIP_MAGIC

      protected static final int GZIP_MAGIC
      See Also:
    • GZIP_MAGIC_0

      protected static final byte GZIP_MAGIC_0
      See Also:
    • GZIP_MAGIC_1

      protected static final byte GZIP_MAGIC_1
      See Also:
    • FHCRC

      protected static final int FHCRC
      See Also:
    • FEXTRA

      protected static final int FEXTRA
      See Also:
    • FNAME

      protected static final int FNAME
      See Also:
    • FCOMMENT

      protected static final int FCOMMENT
      See Also:
    • DEFAULT_CHUNK_SIZE

      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
      See Also:
    • DECODE_BUFFER_SIZE

      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
      See Also:
    • STATE_INITIAL

      protected static final int STATE_INITIAL
      State in which a new compression stream can start.
      See Also:
    • STATE_HEADER_SIG1

      protected static final int STATE_HEADER_SIG1
      See Also:
    • STATE_HEADER_COMP_TYPE

      protected static final int STATE_HEADER_COMP_TYPE
      See Also:
    • STATE_HEADER_FLAGS

      protected static final int STATE_HEADER_FLAGS
      See Also:
    • STATE_HEADER_SKIP

      protected static final int STATE_HEADER_SKIP
      See Also:
    • STATE_HEADER_EXTRA0

      protected static final int STATE_HEADER_EXTRA0
      See Also:
    • STATE_HEADER_EXTRA1

      protected static final int STATE_HEADER_EXTRA1
      See Also:
    • STATE_HEADER_FNAME

      protected static final int STATE_HEADER_FNAME
      See Also:
    • STATE_HEADER_COMMENT

      protected static final int STATE_HEADER_COMMENT
      See Also:
    • STATE_HEADER_CRC0

      protected static final int STATE_HEADER_CRC0
      See Also:
    • STATE_HEADER_CRC1

      protected static final int STATE_HEADER_CRC1
      See Also:
    • STATE_TRAILER_INITIAL

      protected static final int STATE_TRAILER_INITIAL
      See Also:
    • STATE_TRAILER_CRC1

      protected static final int STATE_TRAILER_CRC1
      See Also:
    • STATE_TRAILER_CRC2

      protected static final int STATE_TRAILER_CRC2
      See Also:
    • STATE_TRAILER_CRC3

      protected static final int STATE_TRAILER_CRC3
      See Also:
    • STATE_TRAILER_LEN0

      protected static final int STATE_TRAILER_LEN0
      See Also:
    • STATE_TRAILER_LEN1

      protected static final int STATE_TRAILER_LEN1
      See Also:
    • STATE_TRAILER_LEN2

      protected static final int STATE_TRAILER_LEN2
      See Also:
    • STATE_TRAILER_LEN3

      protected static final int STATE_TRAILER_LEN3
      See Also:
    • STATE_BODY

      protected static final int STATE_BODY
      State in which we are buffering compressed data for decompression
      See Also:
    • _handler

      protected final DataHandler _handler
      Handler that will receive uncompressed data.
    • _recycler

      protected final BufferRecycler _recycler
      Object that handles details of buffer recycling
    • _gzipRecycler

      protected final GZIPRecycler _gzipRecycler
    • _inflater

      protected Inflater _inflater
    • _crc

      protected final CRC32 _crc
    • _inputChunkLength

      protected final int _inputChunkLength
    • _decodeBuffer

      protected byte[] _decodeBuffer
      Buffer used for data uncompressed from _inputBuffer.
    • _state

      protected int _state
      Current decoding state, which determines meaning of following byte(s).
    • _terminated

      protected boolean _terminated
      Flag set if DataHandler indicates that processing should be terminated.
    • _flags

      protected int _flags
      Header flags read from gzip header
    • _headerCRC

      protected int _headerCRC
      Expected CRC for header, from gzip file itself.
    • _skippedBytes

      protected int _skippedBytes
      Simple counter used when skipping fixed number of bytes
    • _trailerCRC

      protected int _trailerCRC
      CRC container in trailer, should match calculated CRC over data
    • _trailerCount

      protected int _trailerCount
      Number of bytes that trailer indicates preceding data stream should have had.
  • Constructor Details

  • Method Details

    • feedCompressedData

      public boolean feedCompressedData(byte[] comp, int offset, int len) throws 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 class Uncompressor
      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:
      IOException
    • complete

      public void complete() throws 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 class Uncompressor
      Throws:
      IOException
    • _hasFlag

      protected final boolean _hasFlag(int flag)
    • _handleHeader

      private final int _handleHeader(byte[] comp, int offset, int end) throws IOException
      Throws:
      IOException
    • _handleTrailer

      private final int _handleTrailer(byte[] comp, int offset, int end) throws IOException
      Throws:
      IOException
    • _throwInternal

      protected void _throwInternal() throws GZIPException
      Throws:
      GZIPException
    • _throwInternal

      protected void _throwInternal(String msg) throws GZIPException
      Throws:
      GZIPException
    • _reportBadHeader

      protected void _reportBadHeader(byte[] comp, int nextOffset, int end, int relative) throws GZIPException
      Throws:
      GZIPException