Top Description Fields Constructors Methods
com.aayushatharva.brotli4j.decoder

public Class BrotliDecoderChannel

extends Decoder
implements ReadableByteChannel
Class Inheritance
All Implemented Interfaces
java.nio.channels.ReadableByteChannel, java.nio.channels.Channel, java.io.Closeable, java.lang.AutoCloseable
Annotations
@Upstream
Imports
com.aayushatharva.brotli4j.common.annotations.Upstream, java.io.IOException, java.nio.ByteBuffer, java.nio.channels.ClosedChannelException, .ReadableByteChannel

ReadableByteChannel that wraps native brotli decoder.

Field Summary

Modifier and TypeField and Description
private static final int
DEFAULT_BUFFER_SIZE

The default internal buffer size used by the decoder.

private final Object
Inherited from com.aayushatharva.brotli4j.decoder.Decoder:
bufferclosedeager

Constructor Summary

AccessConstructor and Description
public
BrotliDecoderChannel(ReadableByteChannel
underlying source
source
)

Creates a BrotliDecoderChannel.

public
BrotliDecoderChannel(ReadableByteChannel
underlying source
source
,
int
intermediate buffer size
bufferSize
)

Creates a BrotliDecoderChannel.

Method Summary

Modifier and TypeMethod and Description
public void
public void
public boolean
isOpen()

Implements java.nio.channels.Channel.isOpen.

Tells whether or not this channel is open.
public int
read(ByteBuffer
The buffer into which bytes are to be transferred
dst
)

Implements java.nio.channels.ReadableByteChannel.read.

Reads a sequence of bytes from this channel into the given buffer.
Inherited from com.aayushatharva.brotli4j.decoder.Decoder:
consumedecodedecompressdecompressdiscardenableEagerOutput

Field Detail

DEFAULT_BUFFER_SIZEback to summary
private static final int DEFAULT_BUFFER_SIZE

The default internal buffer size used by the decoder.

mutexback to summary
private final Object mutex

Constructor Detail

BrotliDecoderChannelback to summary
public BrotliDecoderChannel(ReadableByteChannel source) throws IOException

Creates a BrotliDecoderChannel.

Parameters
source:ReadableByteChannel

underlying source

Exceptions
IOException:
If any failure during initialization
BrotliDecoderChannelback to summary
public BrotliDecoderChannel(ReadableByteChannel source, int bufferSize) throws IOException

Creates a BrotliDecoderChannel.

Parameters
source:ReadableByteChannel

underlying source

bufferSize:int

intermediate buffer size

Exceptions
IOException:
If any failure during initialization

Method Detail

attachDictionaryback to summary
public void attachDictionary(ByteBuffer dictionary) throws IOException

Overrides com.aayushatharva.brotli4j.decoder.Decoder.attachDictionary.

Annotations
@Override
closeback to summary
public void close() throws IOException

Overrides com.aayushatharva.brotli4j.decoder.Decoder.close.

Implements java.nio.channels.Channel.close.

Doc from java.nio.channels.Channel.close.

Closes this channel.

After a channel is closed, any further attempt to invoke I/O operations upon it will cause a ClosedChannelException to be thrown.

If this channel is already closed then invoking this method has no effect.

This method may be invoked at any time. If some other thread has already invoked it, however, then another invocation will block until the first invocation is complete, after which it will return without effect.

Annotations
@Override
Exceptions
IOException:
If an I/O error occurs
isOpenback to summary
public boolean isOpen()

Implements java.nio.channels.Channel.isOpen.

Doc from java.nio.channels.Channel.isOpen.

Tells whether or not this channel is open.

Returns:boolean

true if, and only if, this channel is open

Annotations
@Override
readback to summary
public int read(ByteBuffer dst) throws IOException

Implements java.nio.channels.ReadableByteChannel.read.

Doc from java.nio.channels.ReadableByteChannel.read.

Reads a sequence of bytes from this channel into the given buffer.

An attempt is made to read up to r bytes from the channel, where r is the number of bytes remaining in the buffer, that is, dst.remaining(), at the moment this method is invoked.

Suppose that a byte sequence of length n is read, where 0 <= n <= r. This byte sequence will be transferred into the buffer so that the first byte in the sequence is at index p and the last byte is at index p + n - 1, where p is the buffer's position at the moment this method is invoked. Upon return the buffer's position will be equal to p + n; its limit will not have changed.

A read operation might not fill the buffer, and in fact it might not read any bytes at all. Whether or not it does so depends upon the nature and state of the channel. A socket channel in non-blocking mode, for example, cannot read any more bytes than are immediately available from the socket's input buffer; similarly, a file channel cannot read any more bytes than remain in the file. It is guaranteed, however, that if a channel is in blocking mode and there is at least one byte remaining in the buffer then this method will block until at least one byte is read.

This method may be invoked at any time. If another thread has already initiated a read operation upon this channel, however, then an invocation of this method will block until the first operation is complete.

Parameters
dst:ByteBuffer

The buffer into which bytes are to be transferred

Returns:int

The number of bytes read, possibly zero, or -1 if the channel has reached end-of-stream

Annotations
@Override
Exceptions
IOException:
If some other I/O error occurs