Package org.brotli.wrapper.enc
Class Encoder
- java.lang.Object
-
- org.brotli.wrapper.enc.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.hstatic class
Encoder.Parameters
Brotli encoder settings.
-
Field Summary
Fields Modifier and Type Field Description private java.nio.ByteBuffer
buffer
(package private) boolean
closed
private java.nio.channels.WritableByteChannel
destination
private java.util.List<PreparedDictionary>
dictionaries
private EncoderJNI.Wrapper
encoder
(package private) java.nio.ByteBuffer
inputBuffer
-
Constructor Summary
Constructors Constructor Description Encoder(java.nio.channels.WritableByteChannel destination, Encoder.Parameters params, int inputBufferSize)
Creates a Encoder wrapper.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
attachDictionary(PreparedDictionary dictionary)
(package private) void
close()
static byte[]
compress(byte[] data)
static byte[]
compress(byte[] data, Encoder.Parameters params)
Encodes the given data buffer.(package private) boolean
encode(EncoderJNI.Operation op)
private void
fail(java.lang.String message)
(package private) void
flush()
static PreparedDictionary
prepareDictionary(java.nio.ByteBuffer dictionary, int sharedDictionaryType)
Prepares raw or serialized dictionary for being used by encoder.(package private) boolean
pushOutput(boolean force)
-
-
-
Field Detail
-
destination
private final java.nio.channels.WritableByteChannel destination
-
dictionaries
private final java.util.List<PreparedDictionary> dictionaries
-
encoder
private final EncoderJNI.Wrapper encoder
-
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 destinationparams
- encoding parametersinputBufferSize
- 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 directsharedDictionaryType
- dictionary data type
-
-