Class BrotliDecoder
- java.lang.Object
-
- io.netty.channel.ChannelHandlerAdapter
-
- io.netty.channel.ChannelInboundHandlerAdapter
-
- io.netty.handler.codec.ByteToMessageDecoder
-
- io.netty.handler.codec.compression.BrotliDecoder
-
- All Implemented Interfaces:
ChannelHandler,ChannelInboundHandler
public final class BrotliDecoder extends ByteToMessageDecoder
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classBrotliDecoder.State-
Nested classes/interfaces inherited from class io.netty.handler.codec.ByteToMessageDecoder
ByteToMessageDecoder.Cumulator
-
Nested classes/interfaces inherited from interface io.netty.channel.ChannelHandler
ChannelHandler.Sharable
-
-
Field Summary
Fields Modifier and Type Field Description private ByteBufaccumBufferprivate com.aayushatharva.brotli4j.decoder.DecoderJNI.Wrapperdecoderprivate static intDEFAULT_INPUT_BUFFER_SIZEprivate static intDEFAULT_MAX_FORWARD_BYTES(package private) static intDEFAULT_OUTPUT_BUFFER_SIZEprivate booleandestroyedprivate intinputBufferSizeprivate intmaxForwardBytesprivate booleanneedsReadprivate intoutputBufferSizeprivate booleanpulledSinceLastPush-
Fields inherited from class io.netty.handler.codec.ByteToMessageDecoder
COMPOSITE_CUMULATOR, MERGE_CUMULATOR
-
-
Constructor Summary
Constructors Constructor Description BrotliDecoder()Creates a new BrotliDecoder with a default 8kB input bufferBrotliDecoder(int inputBufferSize)Creates a new BrotliDecoderBrotliDecoder(int inputBufferSize, int outputBufferSize)Creates a new BrotliDecoderBrotliDecoder(int inputBufferSize, int outputBufferSize, int defaultMaxForwardBytes)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidchannelInactive(ChannelHandlerContext ctx)CallsChannelHandlerContext.fireChannelInactive()to forward to the nextChannelInboundHandlerin theChannelPipeline.voidchannelReadComplete(ChannelHandlerContext ctx)CallsChannelHandlerContext.fireChannelReadComplete()to forward to the nextChannelInboundHandlerin theChannelPipeline.protected voiddecode(ChannelHandlerContext ctx, ByteBuf in, java.util.List<java.lang.Object> out)Decode the from oneByteBufto an other.private BrotliDecoder.Statedecompress(ChannelHandlerContext ctx, ByteBuf input)private voiddestroy()private voidflushAccumBuffer(ChannelHandlerContext ctx)private voidforwardOutput(ChannelHandlerContext ctx)voidhandlerAdded(ChannelHandlerContext ctx)Do nothing by default, sub-classes may override this method.protected voidhandlerRemoved0(ChannelHandlerContext ctx)Gets called after theByteToMessageDecoderwas removed from the actual context and it doesn't handle events anymore.static BrotliDecodernewDecoderWithMaxAllocation(int maxAllocation)Creates a newBrotliDecoderthat use themaxAllocationsemantics: the supplied value bounds the size of the emitted decompressed chunks.private voidpush(int length)private static intreadBytes(ByteBuf in, java.nio.ByteBuffer dest)-
Methods inherited from class io.netty.handler.codec.ByteToMessageDecoder
actualReadableBytes, callDecode, channelRead, decodeLast, discardSomeReadBytes, handlerRemoved, internalBuffer, isSingleDecode, setCumulator, setDiscardAfterReads, setSingleDecode, userEventTriggered
-
Methods inherited from class io.netty.channel.ChannelInboundHandlerAdapter
channelActive, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaught
-
Methods inherited from class io.netty.channel.ChannelHandlerAdapter
ensureNotSharable, isSharable
-
-
-
-
Field Detail
-
DEFAULT_MAX_FORWARD_BYTES
private static final int DEFAULT_MAX_FORWARD_BYTES
-
DEFAULT_INPUT_BUFFER_SIZE
private static final int DEFAULT_INPUT_BUFFER_SIZE
- See Also:
- Constant Field Values
-
DEFAULT_OUTPUT_BUFFER_SIZE
static final int DEFAULT_OUTPUT_BUFFER_SIZE
- See Also:
- Constant Field Values
-
inputBufferSize
private final int inputBufferSize
-
outputBufferSize
private final int outputBufferSize
-
maxForwardBytes
private final int maxForwardBytes
-
decoder
private com.aayushatharva.brotli4j.decoder.DecoderJNI.Wrapper decoder
-
destroyed
private boolean destroyed
-
needsRead
private boolean needsRead
-
pulledSinceLastPush
private boolean pulledSinceLastPush
-
accumBuffer
private ByteBuf accumBuffer
-
-
Constructor Detail
-
BrotliDecoder
public BrotliDecoder()
Creates a new BrotliDecoder with a default 8kB input buffer
-
BrotliDecoder
public BrotliDecoder(int inputBufferSize)
Creates a new BrotliDecoder- Parameters:
inputBufferSize- desired size of the input buffer in bytes
-
BrotliDecoder
public BrotliDecoder(int inputBufferSize, int outputBufferSize)Creates a new BrotliDecoder- Parameters:
inputBufferSize- desired size of the input buffer in bytesoutputBufferSize- desired max size of the output buffer in bytes (produce multiple output buffers if exceeded)
-
BrotliDecoder
BrotliDecoder(int inputBufferSize, int outputBufferSize, int defaultMaxForwardBytes)
-
-
Method Detail
-
newDecoderWithMaxAllocation
public static BrotliDecoder newDecoderWithMaxAllocation(int maxAllocation)
Creates a newBrotliDecoderthat use themaxAllocationsemantics: the supplied value bounds the size of the emitted decompressed chunks. The input buffer size stays at the decoder's default.- Parameters:
maxAllocation- maximum size, in bytes, of each decompressed output buffer forwarded downstream; if0, the decoder's default output cap is used.
-
forwardOutput
private void forwardOutput(ChannelHandlerContext ctx)
-
flushAccumBuffer
private void flushAccumBuffer(ChannelHandlerContext ctx)
-
decompress
private BrotliDecoder.State decompress(ChannelHandlerContext ctx, ByteBuf input)
-
push
private void push(int length)
-
readBytes
private static int readBytes(ByteBuf in, java.nio.ByteBuffer dest)
-
handlerAdded
public void handlerAdded(ChannelHandlerContext ctx) throws java.lang.Exception
Description copied from class:ChannelHandlerAdapterDo nothing by default, sub-classes may override this method.- Specified by:
handlerAddedin interfaceChannelHandler- Overrides:
handlerAddedin classChannelHandlerAdapter- Throws:
java.lang.Exception
-
decode
protected void decode(ChannelHandlerContext ctx, ByteBuf in, java.util.List<java.lang.Object> out) throws java.lang.Exception
Description copied from class:ByteToMessageDecoderDecode the from oneByteBufto an other. This method will be called till either the inputByteBufhas nothing to read when return from this method or till nothing was read from the inputByteBuf.- Specified by:
decodein classByteToMessageDecoder- Parameters:
ctx- theChannelHandlerContextwhich thisByteToMessageDecoderbelongs toin- theByteBuffrom which to read dataout- theListto which decoded messages should be added- Throws:
java.lang.Exception- is thrown if an error occurs
-
destroy
private void destroy()
-
handlerRemoved0
protected void handlerRemoved0(ChannelHandlerContext ctx) throws java.lang.Exception
Description copied from class:ByteToMessageDecoderGets called after theByteToMessageDecoderwas removed from the actual context and it doesn't handle events anymore.- Overrides:
handlerRemoved0in classByteToMessageDecoder- Throws:
java.lang.Exception
-
channelInactive
public void channelInactive(ChannelHandlerContext ctx) throws java.lang.Exception
Description copied from class:ChannelInboundHandlerAdapterCallsChannelHandlerContext.fireChannelInactive()to forward to the nextChannelInboundHandlerin theChannelPipeline. Sub-classes may override this method to change behavior.- Specified by:
channelInactivein interfaceChannelInboundHandler- Overrides:
channelInactivein classByteToMessageDecoder- Throws:
java.lang.Exception
-
channelReadComplete
public void channelReadComplete(ChannelHandlerContext ctx) throws java.lang.Exception
Description copied from class:ChannelInboundHandlerAdapterCallsChannelHandlerContext.fireChannelReadComplete()to forward to the nextChannelInboundHandlerin theChannelPipeline. Sub-classes may override this method to change behavior.- Specified by:
channelReadCompletein interfaceChannelInboundHandler- Overrides:
channelReadCompletein classByteToMessageDecoder- Throws:
java.lang.Exception
-
-