Class JdkZlibEncoder

    • Field Detail

      • MAX_INITIAL_OUTPUT_BUFFER_SIZE

        private static final int MAX_INITIAL_OUTPUT_BUFFER_SIZE
        Maximum initial size for temporary heap buffers used for the compressed output. Buffer may still grow beyond this if necessary.
      • MAX_INPUT_BUFFER_SIZE

        private static final int MAX_INPUT_BUFFER_SIZE
        Max size for temporary heap buffers used to copy input data to heap.
      • deflater

        private final java.util.zip.Deflater deflater
      • finished

        private volatile boolean finished
      • crc

        private final java.util.zip.CRC32 crc
      • gzipHeader

        private static final byte[] gzipHeader
      • writeHeader

        private boolean writeHeader
    • Constructor Detail

      • JdkZlibEncoder

        public JdkZlibEncoder()
        Creates a new zlib encoder with a compression level of (6) and the default wrapper (ZlibWrapper.ZLIB).
        Throws:
        CompressionException - if failed to initialize zlib
      • JdkZlibEncoder

        public JdkZlibEncoder​(int compressionLevel)
        Creates a new zlib encoder with the specified compressionLevel and the default wrapper (ZlibWrapper.ZLIB).
        Parameters:
        compressionLevel - 1 yields the fastest compression and 9 yields the best compression. 0 means no compression. The default compression level is 6.
        Throws:
        CompressionException - if failed to initialize zlib
      • JdkZlibEncoder

        public JdkZlibEncoder​(ZlibWrapper wrapper)
        Creates a new zlib encoder with a compression level of (6) and the specified wrapper.
        Throws:
        CompressionException - if failed to initialize zlib
      • JdkZlibEncoder

        public JdkZlibEncoder​(ZlibWrapper wrapper,
                              int compressionLevel)
        Creates a new zlib encoder with the specified compressionLevel and the specified wrapper.
        Parameters:
        compressionLevel - 1 yields the fastest compression and 9 yields the best compression. 0 means no compression. The default compression level can be set as -1 which correlates to the underlying Deflater.DEFAULT_COMPRESSION level.
        Throws:
        CompressionException - if failed to initialize zlib
      • JdkZlibEncoder

        public JdkZlibEncoder​(byte[] dictionary)
        Creates a new zlib encoder with a compression level of (6) and the specified preset dictionary. The wrapper is always ZlibWrapper.ZLIB because it is the only format that supports the preset dictionary.
        Parameters:
        dictionary - the preset dictionary
        Throws:
        CompressionException - if failed to initialize zlib
      • JdkZlibEncoder

        public JdkZlibEncoder​(int compressionLevel,
                              byte[] dictionary)
        Creates a new zlib encoder with the specified compressionLevel and the specified preset dictionary. The wrapper is always ZlibWrapper.ZLIB because it is the only format that supports the preset dictionary.
        Parameters:
        compressionLevel - 1 yields the fastest compression and 9 yields the best compression. 0 means no compression. The default compression level can be set as -1 which correlates to the underlying Deflater.DEFAULT_COMPRESSION level.
        dictionary - the preset dictionary
        Throws:
        CompressionException - if failed to initialize zlib