Class ZlibDecompressor

    • Method Detail

      • newFactory

        public static Supplier<ZlibDecompressor> newFactory​(int maxAllocation)
        Creates a zlib decompressor factory with the default wrapper (ZlibWrapper.ZLIB) and the specified maximum buffer allocation.
        Parameters:
        maxAllocation - Maximum size of the decompression buffer. Must be >= 0. If zero, maximum size is decided by the BufferAllocator.
        Returns:
        the factory.
      • newFactory

        public static Supplier<ZlibDecompressor> newFactory​(byte[] dictionary)
        Creates a zlib decompressor factory with the specified preset dictionary. The wrapper is always ZlibWrapper.ZLIB because it is the only format that supports the preset dictionary.
        Returns:
        the factory.
      • newFactory

        public static Supplier<ZlibDecompressor> newFactory​(byte[] dictionary,
                                                            int maxAllocation)
        Creates zlib decompressor factory with the specified preset dictionary and maximum buffer allocation. The wrapper is always ZlibWrapper.ZLIB because it is the only format that supports the preset dictionary.
        Parameters:
        maxAllocation - Maximum size of the decompression buffer. Must be >= 0. If zero, maximum size is decided by the BufferAllocator.
        Returns:
        the factory.
      • newFactory

        public static Supplier<ZlibDecompressor> newFactory​(boolean decompressConcatenated,
                                                            int maxAllocation)
      • decompress

        public Buffer decompress​(Buffer in,
                                 BufferAllocator allocator)
                          throws DecompressionException
        Description copied from interface: Decompressor
        This method will read from the input Buffer and decompress into a new Buffer that will be allocated (if needed) from the BufferAllocator. If there is not enough readable data in the Buffer to process it will return null. This method should be called in a loop as long:
        • something was read from the input
          something was returned
      • Otherwise this method should be called again once there is more data in the input buffer.
Specified by:
decompress in interface Decompressor
Parameters:
in - the Buffer that contains the data to be decompressed.
allocator - the BufferAllocator that is used to allocate a new buffer (if needed) to write the decompressed bytes too.
Returns:
the Buffer that contains the decompressed data. The caller of this method takes ownership of the buffer. The return value will be null if there is not enough data readable in the input to make any progress. In this case the user should call it again once there is more data ready to be consumed.
Throws:
DecompressionException - thrown if an decompression error was encountered or the decompressor was closed before.