Class 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 Detail

      • 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:
        Constant Field Values
      • 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:
        Constant Field Values
      • STATE_INITIAL

        protected static final int STATE_INITIAL
        State in which a new compression stream can start.
        See Also:
        Constant Field Values
      • STATE_HEADER_COMP_TYPE

        protected static final int STATE_HEADER_COMP_TYPE
        See Also:
        Constant Field Values
      • STATE_TRAILER_INITIAL

        protected static final int STATE_TRAILER_INITIAL
        See Also:
        Constant Field Values
      • STATE_BODY

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

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

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

        protected java.util.zip.Inflater _inflater
      • _crc

        protected final java.util.zip.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.
    • 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 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:
        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 class Uncompressor
        Throws:
        java.io.IOException
      • _hasFlag

        protected final boolean _hasFlag​(int flag)
      • _handleHeader

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

        private final int _handleTrailer​(byte[] comp,
                                         int offset,
                                         int end)
                                  throws java.io.IOException
        Throws:
        java.io.IOException
      • _reportBadHeader

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