Top Description Fields Constructors Methods
io.netty.handler.codec.compression

public Class FastLzFrameEncoder

extends MessageToByteEncoder<ByteBuf>
Class Inheritance
Imports
io.netty.buffer.ByteBuf, io.netty.channel.ChannelHandlerContext, io.netty.handler.codec.MessageToByteEncoder, java.util.zip.Adler32, .Checksum

Compresses a ByteBuf using the FastLZ algorithm. See FastLZ format.

Field Summary

Modifier and TypeField and Description
private final ByteBufChecksum
checksum

Underlying checksum calculator in use.

private final int
level

Compression level.

Constructor Summary

AccessConstructor and Description
public
FastLzFrameEncoder()

Creates a FastLZ encoder without checksum calculator and with auto detection of compression level.

public
FastLzFrameEncoder(int
supports only these values: 0 - Encoder will choose level automatically depending on the length of the input buffer. 1 - Level 1 is the fastest compression and generally useful for short data. 2 - Level 2 is slightly slower but it gives better compression ratio.
level
)

Creates a FastLZ encoder with specified compression level and without checksum calculator.

public
FastLzFrameEncoder(boolean
If true, the checksum of each block will be calculated and this value will be added to the header of block. By default FastLzFrameEncoder uses java.util.zip.Adler32 for checksum calculation.
validateChecksums
)

Creates a FastLZ encoder with auto detection of compression level and calculation of checksums as specified.

public
FastLzFrameEncoder(int
supports only these values: 0 - Encoder will choose level automatically depending on the length of the input buffer. 1 - Level 1 is the fastest compression and generally useful for short data. 2 - Level 2 is slightly slower but it gives better compression ratio.
level
,
Checksum
the Checksum instance to use to check data for integrity. You may set null if you don't want to validate checksum of each block.
checksum
)

Creates a FastLZ encoder with specified compression level and checksum calculator.

Method Summary

Modifier and TypeMethod and Description
protected void
encode(ChannelHandlerContext ctx, ByteBuf
the message to encode
in
,
ByteBuf
the ByteBuf into which the encoded message will be written
out
)

Implements abstract io.netty.handler.codec.MessageToByteEncoder.encode.

Encode a message into a ByteBuf.
Inherited from io.netty.handler.codec.MessageToByteEncoder:
acceptOutboundMessageallocateBufferisPreferDirectwrite

Field Detail

checksumback to summary
private final ByteBufChecksum checksum

Underlying checksum calculator in use.

levelback to summary
private final int level

Compression level.

Constructor Detail

FastLzFrameEncoderback to summary
public FastLzFrameEncoder()

Creates a FastLZ encoder without checksum calculator and with auto detection of compression level.

FastLzFrameEncoderback to summary
public FastLzFrameEncoder(int level)

Creates a FastLZ encoder with specified compression level and without checksum calculator.

Parameters
level:int

supports only these values: 0 - Encoder will choose level automatically depending on the length of the input buffer. 1 - Level 1 is the fastest compression and generally useful for short data. 2 - Level 2 is slightly slower but it gives better compression ratio.

FastLzFrameEncoderback to summary
public FastLzFrameEncoder(boolean validateChecksums)

Creates a FastLZ encoder with auto detection of compression level and calculation of checksums as specified.

Parameters
validateChecksums:boolean

If true, the checksum of each block will be calculated and this value will be added to the header of block. By default FastLzFrameEncoder uses java.util.zip.Adler32 for checksum calculation.

FastLzFrameEncoderback to summary
public FastLzFrameEncoder(int level, Checksum checksum)

Creates a FastLZ encoder with specified compression level and checksum calculator.

Parameters
level:int

supports only these values: 0 - Encoder will choose level automatically depending on the length of the input buffer. 1 - Level 1 is the fastest compression and generally useful for short data. 2 - Level 2 is slightly slower but it gives better compression ratio.

checksum:Checksum

the Checksum instance to use to check data for integrity. You may set null if you don't want to validate checksum of each block.

Method Detail

encodeback to summary
protected void encode(ChannelHandlerContext ctx, ByteBuf in, ByteBuf out) throws Exception

Implements abstract io.netty.handler.codec.MessageToByteEncoder.encode.

Doc from io.netty.handler.codec.MessageToByteEncoder.encode.

Encode a message into a ByteBuf. This method will be called for each written message that can be handled by this encoder.

Parameters
ctx:ChannelHandlerContext

the ChannelHandlerContext which this MessageToByteEncoder belongs to

in:ByteBuf

the message to encode

out:ByteBuf

the ByteBuf into which the encoded message will be written

Annotations
@Override
Exceptions
Exception:
is thrown if an error occurs