-
- All Superinterfaces:
AutoCloseable
- All Known Implementing Classes:
BrotliDecompressor
,Bzip2Decompressor
,FastLzDecompressor
,Lz4Decompressor
,LzfDecompressor
,SnappyDecompressor
,ZlibDecompressor
public interface Decompressor extends AutoCloseable
Decompressor that takes care of decompress some input.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
close()
Close the decompressor.Buffer
decompress(Buffer input, BufferAllocator allocator)
This method will read from the inputBuffer
and decompress into a newBuffer
that will be allocated (if needed) from theBufferAllocator
.boolean
isClosed()
Returntrue
if the decompressor was closed,false
otherwise.boolean
isFinished()
Returns true if the decompressor was finish.
-
-
-
Method Detail
-
decompress
Buffer decompress(Buffer input, BufferAllocator allocator) throws DecompressionException
This method will read from the inputBuffer
and decompress into a newBuffer
that will be allocated (if needed) from theBufferAllocator
. If there is not enough readable data in theBuffer
to process it will returnnull
. This method should be called in a loop as long:isFinished()
isfalse
- something was read from the
input
- something was returned
- Parameters:
input
- theBuffer
that contains the data to be decompressed.allocator
- theBufferAllocator
that is used to allocate a new buffer (if needed) to write the decompressed bytes too.- Returns:
- the
Buffer
that contains the decompressed data. The caller of this method takes ownership of the buffer. The return value will benull
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. - Throws:
DecompressionException
- thrown if an decompression error was encountered or the decompressor was closed before.
-
isFinished
boolean 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:
true
if the decompressor is done with decompressing the stream.
-
isClosed
boolean isClosed()
Returntrue
if the decompressor was closed,false
otherwise.- Returns:
- if
close()
was called.
-
close
void close()
Close the decompressor. After this method was calledisFinished()
will returntrue
as well and it is not allowed to calldecompress(Buffer, BufferAllocator)
anymore.- Specified by:
close
in interfaceAutoCloseable
-
-