Class DecoderJNI.Wrapper

  • Enclosing class:
    DecoderJNI

    public static class DecoderJNI.Wrapper
    extends java.lang.Object
    • Constructor Summary

      Constructors 
      Constructor Description
      Wrapper​(int inputBufferSize)  
      Wrapper​(int inputBufferSize, int maxOutputChunkSize)
      Creates a Wrapper that caps every pull() to at most maxOutputChunkSize bytes.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean attachDictionary​(java.nio.ByteBuffer dictionary)  
      void destroy()
      Releases native resources.
      java.nio.ByteBuffer getInputBuffer()  
      DecoderJNI.Status getStatus()  
      boolean hasOutput()  
      java.nio.ByteBuffer pull()  
      java.nio.ByteBuffer pull​(int maxBytes)
      Pulls decompressed output, returning at most maxBytes bytes.
      void push​(int length)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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.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:
        java.io.IOException - if native decoder initialization fails
    • Method Detail

      • attachDictionary

        public boolean attachDictionary​(java.nio.ByteBuffer dictionary)
      • push

        public void push​(int length)
      • 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 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.