Class DecoderJNI.Wrapper
- java.lang.Object
-
- com.aayushatharva.brotli4j.decoder.DecoderJNI.Wrapper
-
- Enclosing class:
- DecoderJNI
public static class DecoderJNI.Wrapper extends java.lang.Object
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanattachDictionary(java.nio.ByteBuffer dictionary)voiddestroy()Releases native resources.java.nio.ByteBuffergetInputBuffer()DecoderJNI.StatusgetStatus()booleanhasOutput()java.nio.ByteBufferpull()java.nio.ByteBufferpull(int maxBytes)Pulls decompressed output, returning at mostmaxBytesbytes.voidpush(int length)
-
-
-
Constructor Detail
-
Wrapper
public Wrapper(int inputBufferSize) throws java.io.IOException- Throws:
java.io.IOException
-
Wrapper
public Wrapper(int inputBufferSize, int maxOutputChunkSize) throws java.io.IOExceptionCreates 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:
java.io.IOException- if native decoder initialization fails
-
-
Method Detail
-
attachDictionary
public boolean attachDictionary(java.nio.ByteBuffer dictionary)
-
push
public void push(int length)
-
getStatus
public DecoderJNI.Status getStatus()
-
getInputBuffer
public java.nio.ByteBuffer getInputBuffer()
-
hasOutput
public boolean hasOutput()
-
pull
public java.nio.ByteBuffer pull()
-
pull
public java.nio.ByteBuffer pull(int maxBytes)
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.
-
-