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

public Class LzmaFrameEncoder

extends MessageToByteEncoder<ByteBuf>
Class Inheritance
Imports
io.netty.buffer.ByteBuf, .ByteBufInputStream, .ByteBufOutputStream, io.netty.channel.ChannelHandlerContext, io.netty.handler.codec.MessageToByteEncoder, io.netty.util.internal.logging.InternalLogger, .InternalLoggerFactory, lzma.sdk.lzma.Base, .Encoder, java.io.InputStream

Compresses a ByteBuf using the LZMA algorithm. See LZMA and LZMA format or documents in LZMA SDK archive.

Field Summary

Modifier and TypeField and Description
private static final int
private static final int
private static final int
private static final int
private final Encoder
encoder

Underlying LZMA encoder in use.

private final int
littleEndianDictionarySize

Dictionary Size is stored as an unsigned 32-bit little endian integer.

private static final InternalLogger
private static final int
private static final int
private static final int
private static final int
private final byte
properties

The Properties field contains three properties which are encoded using the following formula:

Properties = (pb * 5 + lp) * 9 + lc The field consists of

  1. the number of literal context bits (lc, [0, 8]);
  2. the number of literal position bits (lp, [0, 4]);
  3. the number of position bits (pb, [0, 4]).
private static boolean
warningLogged

For log warning only once.

Constructor Summary

AccessConstructor and Description
public
LzmaFrameEncoder()

Creates LZMA encoder with default settings.

public
LzmaFrameEncoder(int lc, int lp, int pb)

Creates LZMA encoder with specified lc, lp, pb values and the medium dictionary size of 65536.

public
LzmaFrameEncoder(int dictionarySize)

Creates LZMA encoder with specified dictionary size and default values of lc = 3, lp = 0, pb = 2.

public
LzmaFrameEncoder(int lc, int lp, int pb, int dictionarySize)

Creates LZMA encoder with specified lc, lp, pb values and custom dictionary size.

public
LzmaFrameEncoder(int
the number of "literal context" bits, available values [0, 8], default value 3.
lc
,
int
the number of "literal position" bits, available values [0, 4], default value 0.
lp
,
int
the number of "position" bits, available values [0, 4], default value 2.
pb
,
int
available values [0, java.lang.Integer#MAX_VALUE], default value is 65536.
dictionarySize
,
boolean
indicates should LzmaFrameEncoder use end of stream marker or not. Note, that LzmaFrameEncoder always sets size of uncompressed data in LZMA header, so EOS marker is unnecessary. But you may use it for better portability. For full description see "LZMA Decoding modes" section of LZMA-Specification.txt in official LZMA SDK.
endMarkerMode
,
int
available values [5, 273].
numFastBytes
)

Creates LZMA encoder with specified settings.

Method Summary

Modifier and TypeMethod and Description
protected ByteBuf
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.
private static int
maxOutputBufferLength(int inputLength)

Calculates maximum possible size of output buffer for not compressible data.

Inherited from io.netty.handler.codec.MessageToByteEncoder:
acceptOutboundMessageisPreferDirectwrite

Field Detail

DEFAULT_LCback to summary
private static final int DEFAULT_LC
DEFAULT_LPback to summary
private static final int DEFAULT_LP
DEFAULT_MATCH_FINDERback to summary
private static final int DEFAULT_MATCH_FINDER
DEFAULT_PBback to summary
private static final int DEFAULT_PB
encoderback to summary
private final Encoder encoder

Underlying LZMA encoder in use.

littleEndianDictionarySizeback to summary
private final int littleEndianDictionarySize

Dictionary Size is stored as an unsigned 32-bit little endian integer.

loggerback to summary
private static final InternalLogger logger
MAX_FAST_BYTESback to summary
private static final int MAX_FAST_BYTES
MEDIUM_DICTIONARY_SIZEback to summary
private static final int MEDIUM_DICTIONARY_SIZE
MEDIUM_FAST_BYTESback to summary
private static final int MEDIUM_FAST_BYTES
MIN_FAST_BYTESback to summary
private static final int MIN_FAST_BYTES
propertiesback to summary
private final byte properties

The Properties field contains three properties which are encoded using the following formula:

Properties = (pb * 5 + lp) * 9 + lc

The field consists of
  1. the number of literal context bits (lc, [0, 8]);
  2. the number of literal position bits (lp, [0, 4]);
  3. the number of position bits (pb, [0, 4]).
warningLoggedback to summary
private static boolean warningLogged

For log warning only once.

Constructor Detail

LzmaFrameEncoderback to summary
public LzmaFrameEncoder()

Creates LZMA encoder with default settings.

LzmaFrameEncoderback to summary
public LzmaFrameEncoder(int lc, int lp, int pb)

Creates LZMA encoder with specified lc, lp, pb values and the medium dictionary size of 65536.

LzmaFrameEncoderback to summary
public LzmaFrameEncoder(int dictionarySize)

Creates LZMA encoder with specified dictionary size and default values of lc = 3, lp = 0, pb = 2.

LzmaFrameEncoderback to summary
public LzmaFrameEncoder(int lc, int lp, int pb, int dictionarySize)

Creates LZMA encoder with specified lc, lp, pb values and custom dictionary size.

LzmaFrameEncoderback to summary
public LzmaFrameEncoder(int lc, int lp, int pb, int dictionarySize, boolean endMarkerMode, int numFastBytes)

Creates LZMA encoder with specified settings.

Parameters
lc:int

the number of "literal context" bits, available values [0, 8], default value 3.

lp:int

the number of "literal position" bits, available values [0, 4], default value 0.

pb:int

the number of "position" bits, available values [0, 4], default value 2.

dictionarySize:int

available values [0, java.lang.Integer#MAX_VALUE], default value is 65536.

endMarkerMode:boolean

indicates should LzmaFrameEncoder use end of stream marker or not. Note, that LzmaFrameEncoder always sets size of uncompressed data in LZMA header, so EOS marker is unnecessary. But you may use it for better portability. For full description see "LZMA Decoding modes" section of LZMA-Specification.txt in official LZMA SDK.

numFastBytes:int

available values [5, 273].

Method Detail

allocateBufferback to summary
protected ByteBuf allocateBuffer(ChannelHandlerContext ctx, ByteBuf in, boolean preferDirect) throws Exception

Overrides io.netty.handler.codec.MessageToByteEncoder.allocateBuffer.

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

Allocate a ByteBuf which will be used as argument of encode(ChannelHandlerContext, I, ByteBuf). Sub-classes may override this method to return ByteBuf with a perfect matching initialCapacity.

Annotations
@Override
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
maxOutputBufferLengthback to summary
private static int maxOutputBufferLength(int inputLength)

Calculates maximum possible size of output buffer for not compressible data.