Class DecoderJNI.Wrapper
java.lang.Object
com.aayushatharva.brotli4j.decoder.DecoderJNI.Wrapper
- Enclosing class:
DecoderJNI
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanattachDictionary(ByteBuffer dictionary) voiddestroy()Releases native resources.booleanpull()pull(int maxBytes) Pulls decompressed output, returning at mostmaxBytesbytes.voidpush(int length)
-
Constructor Details
-
Wrapper
- Throws:
IOException
-
Wrapper
Creates a Wrapper that caps everypull()to at mostmaxOutputChunkSizebytes. A zero-or-negative value disables the cap (equivalent to the single-argument constructor).Use this to bound peak memory when streaming potentially-malicious compressed input: each pull returns a
ByteBufferwhoseremaining()is at mostmaxOutputChunkSize, with remaining decoded output served by subsequent pulls.- Parameters:
inputBufferSize- size of the decoder's input buffermaxOutputChunkSize- per-pull output cap in bytes;0for no cap- Throws:
IOException- if native decoder initialization fails
-
-
Method Details
-
attachDictionary
-
push
public void push(int length) -
getStatus
-
getInputBuffer
-
hasOutput
public boolean hasOutput() -
pull
-
pull
Pulls decompressed output, returning at mostmaxBytesbytes. Use this to bound a single allocation when handling untrusted input; any remaining decoded output is served by subsequent pulls.- Parameters:
maxBytes- positive upper bound on the returned buffer size- Returns:
- direct
ByteBufferwithremaining() <= maxBytes
-
destroy
public void destroy()Releases native resources.
-