Top Description Methods
io.netty5.handler.codec.compression

public Interface Compressor

extends AutoCloseable
Known Direct Implementers
io.netty5.handler.codec.compression.BrotliCompressor, io.netty5.handler.codec.compression.Bzip2Compressor, io.netty5.handler.codec.compression.FastLzCompressor, io.netty5.handler.codec.compression.Lz4Compressor, io.netty5.handler.codec.compression.LzfCompressor, io.netty5.handler.codec.compression.LzmaCompressor, io.netty5.handler.codec.compression.SnappyCompressor, io.netty5.handler.codec.compression.ZlibCompressor, io.netty5.handler.codec.compression.ZstdCompressor
Imports
io.netty5.buffer.Buffer, .BufferAllocator

Compressor that takes care of compress some input.

Method Summary

Modifier and TypeMethod and Description
public void
close()

Redeclares java.lang.AutoCloseable.close.

# Close the compressor.
public Buffer

Returns:

the Buffer that contains the compressed data. The caller of this method takes ownership of the buffer. The return value will never be null.
compress
(Buffer
the Buffer that contains the data to be compressed.
input
,
BufferAllocator
the BufferAllocator that is used to allocate a new buffer (if needed) to write the compressed bytes too.
allocator
)

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

Returns:

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.
finish
(BufferAllocator allocator)

By calling this method we signal that the compression stream is marked as finish.

public boolean

Returns:

true if the decompressor was closed, false otherwise.
isClosed
()

Return true if the decompressor was closed, false otherwise.

public boolean

Returns:

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

Returns true if the compressor was finished or closed.

Method Detail

closeback to summary
public void close()

Redeclares java.lang.AutoCloseable.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 input, BufferAllocator allocator) throws CompressionException

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
input: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.

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

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.

Exceptions
CompressionException:
thrown if a compression error was encountered or the compressor was closed already.
isClosedback to summary
public boolean isClosed()

Return true if the decompressor was closed, false otherwise.

Returns:boolean

true if the decompressor was closed, false otherwise.

isFinishedback to summary
public boolean 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.