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

public final Class FastLzDecompressor

extends Object
implements Decompressor
Class Inheritance
All Implemented Interfaces
io.netty5.handler.codec.compression.Decompressor, java.lang.AutoCloseable
Imports
io.netty5.buffer.Buffer, .BufferAllocator, java.util.function.Supplier, java.util.zip.Adler32, .Checksum

Uncompresses a Buffer encoded by FastLzCompressor using the FastLZ algorithm. See FastLZ format.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static enum
FastLzDecompressor.State

Current state of decompression.

Field Summary

Modifier and TypeField and Description
private final BufferChecksum
checksum

Underlying checksum calculator in use.

private int
chunkLength

Length of current received chunk of data.

private int
currentChecksum

Checksum value of current received chunk of data which has checksum.

private FastLzDecompressor.State
private boolean
hasChecksum

Indicates is this chunk has checksum or not.

private boolean
isCompressed

Indicates is this chunk compressed or not.

private int
originalLength

Original of current received chunk of data.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public void
public Buffer
decompress(Buffer
the Buffer that contains the data to be decompressed.
in
,
BufferAllocator
the BufferAllocator that is used to allocate a new buffer (if needed) to write the decompressed bytes too.
allocator
)

Implements io.netty5.handler.codec.compression.Decompressor.decompress.

This method will read from the input Buffer and decompress into a new Buffer that will be allocated (if needed) from the BufferAllocator.
public boolean
isClosed()

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

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

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

Returns true if the decompressor was finish.
public static Supplier<FastLzDecompressor>

Returns:

the factory.
newFactory
()

Creates the fastest FastLZ decompressor factory without checksum calculation.

public static Supplier<FastLzDecompressor>

Returns:

the factory.
newFactory
(boolean
If true, the checksum field will be validated against the actual uncompressed data, and if the checksums do not match, a suitable DecompressionException will be thrown. Note, that in this case decoder will use java.util.zip.Adler32 as a default checksum calculator.
validateChecksums
)

Creates a FastLZ decompressor factory with calculation of checksums as specified.

public static Supplier<FastLzDecompressor>

Returns:

the factory.
newFactory
(Checksum
the Checksum instance to use to check data for integrity. You may set null if you do not want to validate checksum of each block.
checksum
)

Creates a FastLZ decompressor factory with specified checksum calculator.

private void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

checksumback to summary
private final BufferChecksum checksum

Underlying checksum calculator in use.

chunkLengthback to summary
private int chunkLength

Length of current received chunk of data.

currentChecksumback to summary
private int currentChecksum

Checksum value of current received chunk of data which has checksum.

currentStateback to summary
private FastLzDecompressor.State currentState
hasChecksumback to summary
private boolean hasChecksum

Indicates is this chunk has checksum or not.

isCompressedback to summary
private boolean isCompressed

Indicates is this chunk compressed or not.

originalLengthback to summary
private int originalLength

Original of current received chunk of data. It is equal to chunkLength for non compressed chunks.

Constructor Detail

FastLzDecompressorback to summary
private FastLzDecompressor(Checksum checksum)

Method Detail

closeback to summary
public void close()

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

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

Close the decompressor. After this method was called isFinished() will return true as well and it is not allowed to call decompress(Buffer, BufferAllocator) anymore.

Annotations
@Override
decompressback to summary
public Buffer decompress(Buffer in, BufferAllocator allocator) throws DecompressionException

Implements io.netty5.handler.codec.compression.Decompressor.decompress.

Doc from io.netty5.handler.codec.compression.Decompressor.decompress.

This method will read from the input Buffer and decompress into a new Buffer that will be allocated (if needed) from the BufferAllocator. If there is not enough readable data in the Buffer to process it will return null. This method should be called in a loop as long:

    • something was read from the input
      something was returned
  • Otherwise this method should be called again once there is more data in the input buffer.
    Parameters
    in:Buffer

    the Buffer that contains the data to be decompressed.

    allocator:BufferAllocator

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

    Returns:Buffer

    the Buffer that contains the decompressed data. The caller of this method takes ownership of the buffer. The return value will be null if there is not enough data readable in the input to make any progress. In this case the user should call it again once there is more data ready to be consumed.

    Annotations
    @Override
    Exceptions
    DecompressionException:
    thrown if an decompression error was encountered or the decompressor was closed before.
    isClosedback to summary
    public boolean isClosed()

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

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

    Return true if the decompressor was closed, false otherwise.

    Returns:boolean

    if close() was called.

    Annotations
    @Override
    isFinishedback to summary
    public boolean isFinished()

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

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

    Returns true if the decompressor was finish. This might be because the decompressor was explicitly closed or the end of the compressed stream was detected.

    Returns:boolean

    true if the decompressor is done with decompressing the stream.

    Annotations
    @Override
    newFactoryback to summary
    public static Supplier<FastLzDecompressor> newFactory()

    Creates the fastest FastLZ decompressor factory without checksum calculation.

    Returns:Supplier<FastLzDecompressor>

    the factory.

    newFactoryback to summary
    public static Supplier<FastLzDecompressor> newFactory(boolean validateChecksums)

    Creates a FastLZ decompressor factory with calculation of checksums as specified.

    Parameters
    validateChecksums:boolean

    If true, the checksum field will be validated against the actual uncompressed data, and if the checksums do not match, a suitable DecompressionException will be thrown. Note, that in this case decoder will use java.util.zip.Adler32 as a default checksum calculator.

    Returns:Supplier<FastLzDecompressor>

    the factory.

    newFactoryback to summary
    public static Supplier<FastLzDecompressor> newFactory(Checksum checksum)

    Creates a FastLZ decompressor factory with specified checksum calculator.

    Parameters
    checksum:Checksum

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

    Returns:Supplier<FastLzDecompressor>

    the factory.

    streamCorruptedback to summary
    private void streamCorrupted(String message)
    io.netty5.handler.codec.compression back to summary

    private final Enum FastLzDecompressor.State

    extends Enum<FastLzDecompressor.State>
    Class Inheritance

    Current state of decompression.

    Field Summary

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

    Constructor Summary

    AccessConstructor and Description
    private

    Method Summary

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

    Field Detail

    CLOSEDback to summary
    public static final FastLzDecompressor.State CLOSED
    CORRUPTEDback to summary
    public static final FastLzDecompressor.State CORRUPTED
    DECOMPRESS_DATAback to summary
    public static final FastLzDecompressor.State DECOMPRESS_DATA
    DONEback to summary
    public static final FastLzDecompressor.State DONE
    INIT_BLOCKback to summary
    public static final FastLzDecompressor.State INIT_BLOCK
    INIT_BLOCK_PARAMSback to summary
    public static final FastLzDecompressor.State INIT_BLOCK_PARAMS

    Constructor Detail

    Stateback to summary
    private State()

    Method Detail

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