Class DecoderJNI.Wrapper

java.lang.Object
com.aayushatharva.brotli4j.decoder.DecoderJNI.Wrapper
Enclosing class:
DecoderJNI

public static class DecoderJNI.Wrapper extends Object
  • Constructor Details

    • Wrapper

      public Wrapper(int inputBufferSize) throws IOException
      Throws:
      IOException
    • Wrapper

      public Wrapper(int inputBufferSize, int maxOutputChunkSize) throws IOException
      Creates a Wrapper that caps every pull() to at most maxOutputChunkSize bytes. 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 ByteBuffer whose remaining() is at most maxOutputChunkSize, with remaining decoded output served by subsequent pulls.

      Parameters:
      inputBufferSize - size of the decoder's input buffer
      maxOutputChunkSize - per-pull output cap in bytes; 0 for no cap
      Throws:
      IOException - if native decoder initialization fails
  • Method Details

    • attachDictionary

      public boolean attachDictionary(ByteBuffer dictionary)
    • push

      public void push(int length)
    • getStatus

      public DecoderJNI.Status getStatus()
    • getInputBuffer

      public ByteBuffer getInputBuffer()
    • hasOutput

      public boolean hasOutput()
    • pull

      public ByteBuffer pull()
    • pull

      public ByteBuffer pull(int maxBytes)
      Pulls decompressed output, returning at most maxBytes bytes. 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 ByteBuffer with remaining() <= maxBytes
    • destroy

      public void destroy()
      Releases native resources.