Interface Decompressor
-
- All Superinterfaces:
java.lang.AutoCloseable
- All Known Implementing Classes:
BrotliDecompressor,Bzip2Decompressor,FastLzFrameDecompressor,JdkZlibDecompressor,Lz4FrameDecompressor,LzfDecompressor,SnappyFrameDecompressor,ZstdDecompressor
@UnstableApi public interface Decompressor extends java.lang.AutoCloseable
Shared API for various decompression algorithms. A decompressor reports its current status usingstatus(). Status documentation lists which operations are permitted for which status. Callers must observe the current status before invoking an operation that is only valid for that status.All methods may throw exceptions. If an exception is thrown, no further operations are permitted, except for
close().This API is still in progress as part of the decompression migration tracked by #16743.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classDecompressor.AbstractDecompressorBuilderstatic classDecompressor.StatusCurrent status of the decompressor.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidaddInput(ByteBuf buf)Add a new input buffer.voidclose()Close this decompressor, cleaning up any associated resources.voidendOfInput()Notify the decompressor that the end of input has been reached.Decompressor.Statusstatus()Get the current status.ByteBuftakeOutput()Take a decompressed buffer from this decompressor.
-
-
-
Method Detail
-
status
Decompressor.Status status() throws DecompressionException
Get the current status. Like the other operations on this class, calling this method is not permitted if the decompressor has failed or was closed.- Returns:
- The current status
- Throws:
DecompressionException
-
addInput
void addInput(ByteBuf buf) throws DecompressionException
Add a new input buffer. Only permitted forDecompressor.Status.NEED_INPUT.- Parameters:
buf- The input buffer. Buffer ownership transfers to the decompressor (also on exception).- Throws:
DecompressionException
-
endOfInput
void endOfInput() throws DecompressionExceptionNotify the decompressor that the end of input has been reached. Some implementations may flush remaining data or throw an exception if the input is truncated, but most implementations do nothing. Only permitted forDecompressor.Status.NEED_INPUT.- Throws:
DecompressionException
-
takeOutput
ByteBuf takeOutput() throws DecompressionException
Take a decompressed buffer from this decompressor. Only permitted forDecompressor.Status.NEED_OUTPUT. Buffer ownership transfers to the caller.- Returns:
- The decompressed buffer. May be empty.
- Throws:
DecompressionException
-
close
void close() throws DecompressionExceptionClose this decompressor, cleaning up any associated resources. This method is idempotent.- Specified by:
closein interfacejava.lang.AutoCloseable- Throws:
DecompressionException
-
-