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.ObjectBase class for OutputStream / Channel implementations.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classEncoder.Modehttps://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 classEncoder.ParametersBrotli encoder settings.
-
Field Summary
Fields Modifier and Type Field Description private java.nio.ByteBufferbuffer(package private) booleanclosedprivate java.nio.channels.WritableByteChanneldestinationprivate java.util.List<PreparedDictionary>dictionariesprivate EncoderJNI.Wrapperencoder(package private) java.nio.ByteBufferinputBuffer
-
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 voidattachDictionary(PreparedDictionary dictionary)(package private) voidclose()static byte[]compress(byte[] data)static byte[]compress(byte[] data, Encoder.Parameters params)Encodes the given data buffer.(package private) booleanencode(EncoderJNI.Operation op)private voidfail(java.lang.String message)(package private) voidflush()static PreparedDictionaryprepareDictionary(java.nio.ByteBuffer dictionary, int sharedDictionaryType)Prepares raw or serialized dictionary for being used by encoder.(package private) booleanpushOutput(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.IOExceptionCreates 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.IOExceptionEncodes 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
-
-