Class Encoder

  • Direct Known Subclasses:
    BrotliEncoderChannel

    public class Encoder
    extends java.lang.Object
    Base class for OutputStream / Channel implementations.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  Encoder.Mode
      https://www.brotli.org/encode.html#aa6f See encode.h, typedef enum BrotliEncoderMode Important: The ordinal value of the modes should be the same as the constant values in encode.h
      static class  Encoder.Parameters
      Brotli encoder settings.
    • Constructor Summary

      Constructors 
      Constructor Description
      Encoder​(java.nio.channels.WritableByteChannel destination, Encoder.Parameters params, int inputBufferSize)
      Creates a Encoder wrapper.
    • Field Detail

      • destination

        private final java.nio.channels.WritableByteChannel destination
      • buffer

        private java.nio.ByteBuffer buffer
      • inputBuffer

        final java.nio.ByteBuffer inputBuffer
      • closed

        boolean closed
    • Constructor Detail

      • Encoder

        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

      • fail

        private void fail​(java.lang.String message)
                   throws java.io.IOException
        Throws:
        java.io.IOException
      • attachDictionary

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

        boolean pushOutput​(boolean force)
                    throws java.io.IOException
        Parameters:
        force - repeat pushing until all output is consumed
        Returns:
        true if all encoder output is consumed
        Throws:
        java.io.IOException
      • encode

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

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

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

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

        public static byte[] compress​(byte[] data)
                               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