Class LzfEncoder

  • All Implemented Interfaces:
    io.netty.channel.ChannelHandler, io.netty.channel.ChannelOutboundHandler

    public class LzfEncoder
    extends io.netty.handler.codec.MessageToByteEncoder<io.netty.buffer.ByteBuf>
    Compresses a ByteBuf using the LZF format.

    See original LZF package and LZF format for full description.

    • Nested Class Summary

      • Nested classes/interfaces inherited from interface io.netty.channel.ChannelHandler

        io.netty.channel.ChannelHandler.Sharable
    • Constructor Summary

      Constructors 
      Constructor Description
      LzfEncoder()
      Creates a new LZF encoder with the most optimal available methods for underlying data access.
      LzfEncoder​(boolean safeInstance)
      Deprecated.
      Use the constructor without the safeInstance parameter.
      LzfEncoder​(boolean safeInstance, int totalLength)
      Deprecated.
      Use the constructor without the safeInstance parameter.
      LzfEncoder​(boolean safeInstance, int totalLength, int compressThreshold)
      Deprecated.
      Use the constructor without the safeInstance parameter.
      LzfEncoder​(int totalLength)
      Creates a new LZF encoder with specified total length of encoded chunk.
      LzfEncoder​(int totalLength, int compressThreshold)
      Creates a new LZF encoder with specified settings.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void encode​(io.netty.channel.ChannelHandlerContext ctx, io.netty.buffer.ByteBuf in, io.netty.buffer.ByteBuf out)  
      void handlerRemoved​(io.netty.channel.ChannelHandlerContext ctx)  
      • Methods inherited from class io.netty.handler.codec.MessageToByteEncoder

        acceptOutboundMessage, allocateBuffer, isPreferDirect, write
      • Methods inherited from class io.netty.channel.ChannelOutboundHandlerAdapter

        bind, close, connect, deregister, disconnect, flush, read
      • Methods inherited from class io.netty.channel.ChannelHandlerAdapter

        ensureNotSharable, exceptionCaught, handlerAdded, isSharable
      • Methods inherited from interface io.netty.channel.ChannelHandler

        exceptionCaught, handlerAdded
    • Constructor Detail

      • LzfEncoder

        public LzfEncoder()
        Creates a new LZF encoder with the most optimal available methods for underlying data access. It will "unsafe" instance if one can be used on current JVM. It should be safe to call this constructor as implementations are dynamically loaded; however, on some non-standard platforms it may be necessary to use LzfEncoder(boolean) with true param.
      • LzfEncoder

        @Deprecated
        public LzfEncoder​(boolean safeInstance)
        Deprecated.
        Use the constructor without the safeInstance parameter.
        Creates a new LZF encoder with specified encoding instance.
        Parameters:
        safeInstance - If true encoder will use ChunkEncoder that only uses standard JDK access methods, and should work on all Java platforms and JVMs. Otherwise encoder will try to use highly optimized ChunkEncoder implementation that uses Sun JDK's Unsafe class (which may be included by other JDK's as well).
      • LzfEncoder

        @Deprecated
        public LzfEncoder​(boolean safeInstance,
                          int totalLength)
        Deprecated.
        Use the constructor without the safeInstance parameter.
        Creates a new LZF encoder with specified encoding instance and compressThreshold.
        Parameters:
        safeInstance - If true encoder will use ChunkEncoder that only uses standard JDK access methods, and should work on all Java platforms and JVMs. Otherwise encoder will try to use highly optimized ChunkEncoder implementation that uses Sun JDK's Unsafe class (which may be included by other JDK's as well).
        totalLength - Expected total length of content to compress; only matters for outgoing messages that is smaller than maximum chunk size (64k), to optimize encoding hash tables.
      • LzfEncoder

        public LzfEncoder​(int totalLength)
        Creates a new LZF encoder with specified total length of encoded chunk. You can configure it to encode your data flow more efficient if you know the average size of messages that you send.
        Parameters:
        totalLength - Expected total length of content to compress; only matters for outgoing messages that is smaller than maximum chunk size (64k), to optimize encoding hash tables.
      • LzfEncoder

        public LzfEncoder​(int totalLength,
                          int compressThreshold)
        Creates a new LZF encoder with specified settings.
        Parameters:
        totalLength - Expected total length of content to compress; only matters for outgoing messages that is smaller than maximum chunk size (64k), to optimize encoding hash tables.
        compressThreshold - Compress threshold for LZF format. When the amount of input data is less than compressThreshold, we will construct an uncompressed output according to the LZF format.
      • LzfEncoder

        @Deprecated
        public LzfEncoder​(boolean safeInstance,
                          int totalLength,
                          int compressThreshold)
        Deprecated.
        Use the constructor without the safeInstance parameter.
        Creates a new LZF encoder with specified settings.
        Parameters:
        safeInstance - If true encoder will use ChunkEncoder that only uses standard JDK access methods, and should work on all Java platforms and JVMs. Otherwise encoder will try to use highly optimized ChunkEncoder implementation that uses Sun JDK's Unsafe class (which may be included by other JDK's as well).
        totalLength - Expected total length of content to compress; only matters for outgoing messages that is smaller than maximum chunk size (64k), to optimize encoding hash tables.
        compressThreshold - Compress threshold for LZF format. When the amount of input data is less than compressThreshold, we will construct an uncompressed output according to the LZF format.
    • Method Detail

      • encode

        protected void encode​(io.netty.channel.ChannelHandlerContext ctx,
                              io.netty.buffer.ByteBuf in,
                              io.netty.buffer.ByteBuf out)
                       throws Exception
        Specified by:
        encode in class io.netty.handler.codec.MessageToByteEncoder<io.netty.buffer.ByteBuf>
        Throws:
        Exception
      • handlerRemoved

        public void handlerRemoved​(io.netty.channel.ChannelHandlerContext ctx)
                            throws Exception
        Specified by:
        handlerRemoved in interface io.netty.channel.ChannelHandler
        Overrides:
        handlerRemoved in class io.netty.channel.ChannelHandlerAdapter
        Throws:
        Exception