Class Encoder

  • All Implemented Interfaces:
    java.lang.AutoCloseable
    Direct Known Subclasses:
    BrotliEncoderChannel

    public class Encoder
    extends java.lang.Object
    implements java.lang.AutoCloseable
    Base class for OutputStream / Channel implementations.
    • Constructor Detail

      • Encoder

        public Encoder​(java.nio.channels.WritableByteChannel destination,
                       Encoder.Parameters params,
                       int inputBufferSize)
                throws java.io.IOException
        Creates a Encoder wrapper.
        Parameters:
        destination - underlying destination
        params - encoding parameters
        inputBufferSize - read buffer size
        Throws:
        java.io.IOException
    • Method Detail

      • compress

        public static byte[] compress​(byte[] data,
                                      int offset,
                                      int length,
                                      Encoder.Parameters params)
                               throws java.io.IOException
        Throws:
        java.io.IOException
      • compress

        public static byte[] compress​(byte[] data)
                               throws java.io.IOException
        Throws:
        java.io.IOException
      • compress

        public static byte[] compress​(byte[] data,
                                      Encoder.Parameters params)
                               throws java.io.IOException
        Throws:
        java.io.IOException
      • compress

        public static byte[] compress​(byte[] data,
                                      int offset,
                                      int length)
                               throws java.io.IOException
        Throws:
        java.io.IOException
      • prepareDictionary

        public static PreparedDictionary prepareDictionary​(java.nio.ByteBuffer dictionary,
                                                           int sharedDictionaryType)
        Prepares raw or serialized dictionary for being used by encoder.
        Parameters:
        dictionary - raw / serialized dictionary data; MUST be direct
        sharedDictionaryType - dictionary data type
        Returns:
        PreparedDictionary instance
      • attachDictionary

        public void attachDictionary​(PreparedDictionary dictionary)
                              throws java.io.IOException
        Throws:
        java.io.IOException
      • encode

        public boolean encode​(EncoderJNI.Operation op)
                       throws java.io.IOException
        Returns:
        true if there is space in inputBuffer.
        Throws:
        java.io.IOException
      • flush

        public void flush()
                   throws java.io.IOException
        Throws:
        java.io.IOException
      • close

        public void close()
                   throws java.io.IOException
        Specified by:
        close in interface java.lang.AutoCloseable
        Throws:
        java.io.IOException