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

public final Class LzfDecompressor

extends Object
implements Decompressor
Class Inheritance
All Implemented Interfaces
io.netty5.handler.codec.compression.Decompressor, java.lang.AutoCloseable
Imports
com.ning.compress.BufferRecycler, com.ning.compress.lzf.ChunkDecoder, .LZFChunk, .LZFException, com.ning.compress.lzf.util.ChunkDecoderFactory, io.netty5.buffer.Buffer, .BufferAllocator, java.util.function.Supplier

Uncompresses a Buffer encoded with the LZF format. See original LZF package and LZF format for full description.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static enum
LzfDecompressor.State

Current state of decompression.

Field Summary

Modifier and TypeField and Description
private int
chunkLength

Length of current received chunk of data.

private LzfDecompressor.State
private ChunkDecoder
decoder

Underlying decoder in use.

private boolean
isCompressed

Indicates is this chunk compressed or not.

private static final short
MAGIC_NUMBER

Magic number of LZF chunk.

private int
originalLength

Original length of current received chunk of data.

private BufferRecycler
recycler

Object that handles details of buffer recycling.

Constructor Summary

AccessConstructor and Description
private
LzfDecompressor(boolean
If true decoder will use ChunkDecoder that only uses standard JDK access methods, and should work on all Java platforms and JVMs. Otherwise decoder will try to use highly optimized ChunkDecoder implementation that uses Sun JDK's sun.misc.Unsafe class (which may be included by other JDK's as well).
safeInstance
)

Creates a new LZF decompressor with specified decoding instance.

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.
private Buffer
decompress(BufferAllocator allocator, byte[] inputArray, int offset, int len)

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<LzfDecompressor>

Returns:

the factory.
newFactory
()

Creates a new LZF decompressor factory with the most optimal available methods for underlying data access.

public static Supplier<LzfDecompressor>

Returns:

the factory.
newFactory
(boolean
If true decoder will use ChunkDecoder that only uses standard JDK access methods, and should work on all Java platforms and JVMs. Otherwise decoder will try to use highly optimized ChunkDecoder implementation that uses Sun JDK's sun.misc.Unsafe class (which may be included by other JDK's as well).
safeInstance
)

Creates a new LZF decompressor factory with specified decoding instance.

private void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

chunkLengthback to summary
private int chunkLength

Length of current received chunk of data.

currentStateback to summary
private LzfDecompressor.State currentState
decoderback to summary
private ChunkDecoder decoder

Underlying decoder in use.

isCompressedback to summary
private boolean isCompressed

Indicates is this chunk compressed or not.

MAGIC_NUMBERback to summary
private static final short MAGIC_NUMBER

Magic number of LZF chunk.

originalLengthback to summary
private int originalLength

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

recyclerback to summary
private BufferRecycler recycler

Object that handles details of buffer recycling.

Constructor Detail

LzfDecompressorback to summary
private LzfDecompressor(boolean safeInstance)

Creates a new LZF decompressor with specified decoding instance.

Parameters
safeInstance:boolean

If true decoder will use ChunkDecoder that only uses standard JDK access methods, and should work on all Java platforms and JVMs. Otherwise decoder will try to use highly optimized ChunkDecoder implementation that uses Sun JDK's sun.misc.Unsafe class (which may be included by other JDK's as well).

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.
    decompressback to summary
    private Buffer decompress(BufferAllocator allocator, byte[] inputArray, int offset, int len) throws LZFException
    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<LzfDecompressor> newFactory()

    Creates a new LZF decompressor factory 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 LzfDecompressor(boolean) with true param.

    Returns:Supplier<LzfDecompressor>

    the factory.

    newFactoryback to summary
    public static Supplier<LzfDecompressor> newFactory(boolean safeInstance)

    Creates a new LZF decompressor factory with specified decoding instance.

    Parameters
    safeInstance:boolean

    If true decoder will use ChunkDecoder that only uses standard JDK access methods, and should work on all Java platforms and JVMs. Otherwise decoder will try to use highly optimized ChunkDecoder implementation that uses Sun JDK's sun.misc.Unsafe class (which may be included by other JDK's as well).

    Returns:Supplier<LzfDecompressor>

    the factory.

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

    private final Enum LzfDecompressor.State

    extends Enum<LzfDecompressor.State>
    Class Inheritance

    Current state of decompression.

    Field Summary

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

    Constructor Summary

    AccessConstructor and Description
    private

    Method Summary

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

    Field Detail

    CLOSEDback to summary
    public static final LzfDecompressor.State CLOSED
    CORRUPTEDback to summary
    public static final LzfDecompressor.State CORRUPTED
    DECOMPRESS_DATAback to summary
    public static final LzfDecompressor.State DECOMPRESS_DATA
    FINISHEDback to summary
    public static final LzfDecompressor.State FINISHED
    INIT_BLOCKback to summary
    public static final LzfDecompressor.State INIT_BLOCK
    INIT_ORIGINAL_LENGTHback to summary
    public static final LzfDecompressor.State INIT_ORIGINAL_LENGTH

    Constructor Detail

    Stateback to summary
    private State()

    Method Detail

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