Interface Decompressor
- All Superinterfaces:
AutoCloseable
- All Known Implementing Classes:
BrotliDecompressor, Bzip2Decompressor, FastLzFrameDecompressor, JdkZlibDecompressor, Lz4FrameDecompressor, LzfDecompressor, SnappyFrameDecompressor, ZstdDecompressor
Shared API for various decompression algorithms. A decompressor reports its current status using
status().
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 ClassesModifier and TypeInterfaceDescriptionstatic classstatic enumCurrent status of the decompressor. -
Method Summary
-
Method Details
-
status
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
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
Notify 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
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
Close this decompressor, cleaning up any associated resources. This method is idempotent.- Specified by:
closein interfaceAutoCloseable- Throws:
DecompressionException
-