Class JZlibEncoder

All Implemented Interfaces:
ChannelHandler, ChannelOutboundHandler

public class JZlibEncoder extends ZlibEncoder
Compresses a ByteBuf using the deflate algorithm.
  • Field Details

    • wrapperOverhead

      private final int wrapperOverhead
    • z

      private final com.jcraft.jzlib.Deflater z
    • finished

      private volatile boolean finished
    • ctx

      private volatile ChannelHandlerContext ctx
    • THREAD_POOL_DELAY_SECONDS

      private static final int THREAD_POOL_DELAY_SECONDS
      See Also:
  • Constructor Details

    • JZlibEncoder

      public JZlibEncoder()
      Creates a new zlib encoder with the default compression level (6), default window bits (15), default memory level (8), and the default wrapper (ZlibWrapper.ZLIB).
      Throws:
      CompressionException - if failed to initialize zlib
    • JZlibEncoder

      public JZlibEncoder(int compressionLevel)
      Creates a new zlib encoder with the specified compressionLevel, default window bits (15), default memory level (8), 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
    • JZlibEncoder

      public JZlibEncoder(ZlibWrapper wrapper)
      Creates a new zlib encoder with the default compression level (6), default window bits (15), default memory level (8), and the specified wrapper.
      Throws:
      CompressionException - if failed to initialize zlib
    • JZlibEncoder

      public JZlibEncoder(ZlibWrapper wrapper, int compressionLevel)
      Creates a new zlib encoder with the specified compressionLevel, default window bits (15), default memory level (8), 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 is 6.
      Throws:
      CompressionException - if failed to initialize zlib
    • JZlibEncoder

      public JZlibEncoder(ZlibWrapper wrapper, int compressionLevel, int windowBits, int memLevel)
      Creates a new zlib encoder with the specified compressionLevel, the specified windowBits, the specified memLevel, 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 is 6.
      windowBits - The base two logarithm of the size of the history buffer. The value should be in the range 9 to 15 inclusive. Larger values result in better compression at the expense of memory usage. The default value is 15.
      memLevel - How much memory should be allocated for the internal compression state. 1 uses minimum memory and 9 uses maximum memory. Larger values result in better and faster compression at the expense of memory usage. The default value is 8
      Throws:
      CompressionException - if failed to initialize zlib
    • JZlibEncoder

      public JZlibEncoder(byte[] dictionary)
      Creates a new zlib encoder with the default compression level (6), default window bits (15), default memory level (8), 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
    • JZlibEncoder

      public JZlibEncoder(int compressionLevel, byte[] dictionary)
      Creates a new zlib encoder with the specified compressionLevel, default window bits (15), default memory level (8), 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 is 6.
      dictionary - the preset dictionary
      Throws:
      CompressionException - if failed to initialize zlib
    • JZlibEncoder

      public JZlibEncoder(int compressionLevel, int windowBits, int memLevel, byte[] dictionary)
      Creates a new zlib encoder with the specified compressionLevel, the specified windowBits, the specified memLevel, 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 is 6.
      windowBits - The base two logarithm of the size of the history buffer. The value should be in the range 9 to 15 inclusive. Larger values result in better compression at the expense of memory usage. The default value is 15.
      memLevel - How much memory should be allocated for the internal compression state. 1 uses minimum memory and 9 uses maximum memory. Larger values result in better and faster compression at the expense of memory usage. The default value is 8
      dictionary - the preset dictionary
      Throws:
      CompressionException - if failed to initialize zlib
  • Method Details