Top Description Inners Fields Constructors Methods
io.netty5.handler.codec.compression

public final Class LzmaCompressor

extends Object
implements Compressor
Class Inheritance
All Implemented Interfaces
io.netty5.handler.codec.compression.Compressor, java.lang.AutoCloseable
Imports
io.netty5.buffer.BufferInputStream, .BufferOutputStream, .Buffer, .BufferAllocator, io.netty5.util.internal.logging.InternalLogger, .InternalLoggerFactory, lzma.sdk.lzma.Base, .Encoder, java.io.IOException, .InputStream, java.util.function.Supplier

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

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static enum

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 LzmaCompressor.State
private static boolean
warningLogged

For log warning only once.

Constructor Summary

AccessConstructor and Description
private
LzmaCompressor(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 LzmaCompressor use end of stream marker or not. Note, that LzmaCompressor 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 compressor with specified settings.

Method Summary

Modifier and TypeMethod and Description
private static Buffer
public void
close()

Implements io.netty5.handler.codec.compression.Compressor.close.

# Close the compressor.
public Buffer
compress(Buffer
the Buffer that contains the data to be compressed.
in
,
BufferAllocator
the BufferAllocator that is used to allocate a new buffer (if needed) to write the compressed bytes too.
allocator
)

Implements io.netty5.handler.codec.compression.Compressor.compress.

This method will read from the input Buffer and compress into a new Buffer that will be allocated (if needed) from the BufferAllocator.
public Buffer
finish(BufferAllocator allocator)

Implements io.netty5.handler.codec.compression.Compressor.finish.

By calling this method we signal that the compression stream is marked as finish.
public boolean
isClosed()

Implements io.netty5.handler.codec.compression.Compressor.isClosed.

Return true if the decompressor was closed, false otherwise.
public boolean
isFinished()

Implements io.netty5.handler.codec.compression.Compressor.isFinished.

Returns true if the compressor was finished or closed.
private static int
maxOutputBufferLength(int inputLength)

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

public static Supplier<LzmaCompressor>

Returns:

the factory.
newFactory
()

Creates LZMA compressor factory with default settings.

public static Supplier<LzmaCompressor>

Returns:

the factory.
newFactory
(int lc, int lp, int pb)

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

public static Supplier<LzmaCompressor>

Returns:

the factory.
newFactory
(int dictionarySize)

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

public static Supplier<LzmaCompressor>

Returns:

the factory.
newFactory
(int lc, int lp, int pb, int dictionarySize)

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

public static Supplier<LzmaCompressor>

Returns:

the factory.
newFactory
(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 LzmaCompressor use end of stream marker or not. Note, that LzmaCompressor 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 compressor factory with specified settings.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

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]).
stateback to summary
private LzmaCompressor.State state
warningLoggedback to summary
private static boolean warningLogged

For log warning only once.

Constructor Detail

LzmaCompressorback to summary
private LzmaCompressor(int lc, int lp, int pb, int dictionarySize, boolean endMarkerMode, int numFastBytes)

Creates LZMA compressor 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 LzmaCompressor use end of stream marker or not. Note, that LzmaCompressor 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
private static Buffer allocateBuffer(Buffer in, BufferAllocator allocator)
closeback to summary
public void close()

Implements io.netty5.handler.codec.compression.Compressor.close.

Doc from io.netty5.handler.codec.compression.Compressor.close.

# Close the compressor. After this method was called isFinished() will return true as well and it is not allowed to call compress(Buffer, BufferAllocator) or finish(BufferAllocator) anymore -

Annotations
@Override
compressback to summary
public Buffer compress(Buffer in, BufferAllocator allocator) throws CompressionException

Implements io.netty5.handler.codec.compression.Compressor.compress.

Doc from io.netty5.handler.codec.compression.Compressor.compress.

This method will read from the input Buffer and compress into a new Buffer that will be allocated (if needed) from the BufferAllocator. This method is expected to consume all data from the input but not take ownership. The caller is responsible to release the input buffer after this method returns.

Parameters
in:Buffer

the Buffer that contains the data to be compressed.

allocator:BufferAllocator

the BufferAllocator that is used to allocate a new buffer (if needed) to write the compressed bytes too.

Returns:Buffer

the Buffer that contains the compressed data. The caller of this method takes ownership of the buffer. The return value will never be null.

Annotations
@Override
Exceptions
CompressionException:
thrown if an compression error was encountered or the compressor was closed already.
finishback to summary
public Buffer finish(BufferAllocator allocator)

Implements io.netty5.handler.codec.compression.Compressor.finish.

Doc from io.netty5.handler.codec.compression.Compressor.finish.

By calling this method we signal that the compression stream is marked as finish. The returned Buffer might contain a "trailer" which marks the end of the stream.

Returns:Buffer

the Buffer which represent the end of the compression stream, which might be empty if the compressor don't need a trailer to signal the end. The caller of this method takes ownership of the buffer. The return value will never be null.

Annotations
@Override
isClosedback to summary
public boolean isClosed()

Implements io.netty5.handler.codec.compression.Compressor.isClosed.

Doc from io.netty5.handler.codec.compression.Compressor.isClosed.

Return true if the decompressor was closed, false otherwise.

Returns:boolean

true if the decompressor was closed, false otherwise.

Annotations
@Override
isFinishedback to summary
public boolean isFinished()

Implements io.netty5.handler.codec.compression.Compressor.isFinished.

Doc from io.netty5.handler.codec.compression.Compressor.isFinished.

Returns true if the compressor was finished or closed. This might happen because someone explicit called finish(BufferAllocator) / close() or the compressor implementation did decide to close itself due a compression error which can't be recovered. After isFinished() returns true the compress(Buffer, BufferAllocator) method will just return an empty buffer without consuming anything from its input buffer.

Returns:boolean

true if the compressor was marked as finished, false otherwise.

Annotations
@Override
maxOutputBufferLengthback to summary
private static int maxOutputBufferLength(int inputLength)

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

newFactoryback to summary
public static Supplier<LzmaCompressor> newFactory()

Creates LZMA compressor factory with default settings.

Returns:Supplier<LzmaCompressor>

the factory.

newFactoryback to summary
public static Supplier<LzmaCompressor> newFactory(int lc, int lp, int pb)

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

Returns:Supplier<LzmaCompressor>

the factory.

newFactoryback to summary
public static Supplier<LzmaCompressor> newFactory(int dictionarySize)

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

Returns:Supplier<LzmaCompressor>

the factory.

newFactoryback to summary
public static Supplier<LzmaCompressor> newFactory(int lc, int lp, int pb, int dictionarySize)

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

Returns:Supplier<LzmaCompressor>

the factory.

newFactoryback to summary
public static Supplier<LzmaCompressor> newFactory(int lc, int lp, int pb, int dictionarySize, boolean endMarkerMode, int numFastBytes)

Creates LZMA compressor factory 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 LzmaCompressor use end of stream marker or not. Note, that LzmaCompressor 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].

Returns:Supplier<LzmaCompressor>

the factory.

io.netty5.handler.codec.compression back to summary

private final Enum LzmaCompressor.State

extends Enum<LzmaCompressor.State>
Class Inheritance

Field Summary

Modifier and TypeField and Description
public static final LzmaCompressor.State
public static final LzmaCompressor.State
public static final LzmaCompressor.State

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static LzmaCompressor.State
public static LzmaCompressor.State[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

CLOSEDback to summary
public static final LzmaCompressor.State CLOSED
FINISHEDback to summary
public static final LzmaCompressor.State FINISHED
PROCESSINGback to summary
public static final LzmaCompressor.State PROCESSING

Constructor Detail

Stateback to summary
private State()

Method Detail

valueOfback to summary
public static LzmaCompressor.State valueOf(String name)
valuesback to summary
public static LzmaCompressor.State[] values()