public class Bzip2Encoder extends MessageToByteEncoder<ByteBuf>
ChannelHandler.Sharable
Constructor and Description |
---|
Bzip2Encoder()
Creates a new bzip2 encoder with the maximum (900,000 byte) block size.
|
Bzip2Encoder(int blockSizeMultiplier)
Creates a new bzip2 encoder with the specified
blockSizeMultiplier . |
Modifier and Type | Method and Description |
---|---|
ChannelFuture |
close()
Close this
Bzip2Encoder and so finish the encoding. |
void |
close(ChannelHandlerContext ctx,
ChannelPromise promise)
Calls
ChannelOutboundInvoker.close(ChannelPromise) to forward
to the next ChannelOutboundHandler in the ChannelPipeline . |
ChannelFuture |
close(ChannelPromise promise)
Close this
Bzip2Encoder and so finish the encoding. |
protected void |
encode(ChannelHandlerContext ctx,
ByteBuf in,
ByteBuf out)
Encode a message into a
ByteBuf . |
void |
handlerAdded(ChannelHandlerContext ctx)
Do nothing by default, sub-classes may override this method.
|
boolean |
isClosed()
Returns
true if and only if the end of the compressed stream has been reached. |
acceptOutboundMessage, allocateBuffer, isPreferDirect, write
bind, connect, deregister, disconnect, flush, read
ensureNotSharable, exceptionCaught, handlerRemoved, isSharable
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
exceptionCaught, handlerRemoved
public Bzip2Encoder()
public Bzip2Encoder(int blockSizeMultiplier)
blockSizeMultiplier
.blockSizeMultiplier
- The Bzip2 block size as a multiple of 100,000 bytes (minimum 1
, maximum 9
).
Larger block sizes require more memory for both compression and decompression,
but give better compression ratios. 9
will usually be the best value to use.protected void encode(ChannelHandlerContext ctx, ByteBuf in, ByteBuf out) throws Exception
MessageToByteEncoder
ByteBuf
. This method will be called for each written message that can be handled
by this encoder.encode
in class MessageToByteEncoder<ByteBuf>
ctx
- the ChannelHandlerContext
which this MessageToByteEncoder
belongs toin
- the message to encodeout
- the ByteBuf
into which the encoded message will be writtenException
- is thrown if an error occurspublic boolean isClosed()
true
if and only if the end of the compressed stream has been reached.public ChannelFuture close()
Bzip2Encoder
and so finish the encoding.
The returned ChannelFuture
will be notified once the operation completes.public ChannelFuture close(ChannelPromise promise)
Bzip2Encoder
and so finish the encoding.
The given ChannelFuture
will be notified once the operation
completes and will also be returned.public void close(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception
ChannelOutboundHandlerAdapter
ChannelOutboundInvoker.close(ChannelPromise)
to forward
to the next ChannelOutboundHandler
in the ChannelPipeline
.
Sub-classes may override this method to change behavior.close
in interface ChannelOutboundHandler
close
in class ChannelOutboundHandlerAdapter
ctx
- the ChannelHandlerContext
for which the close operation is madepromise
- the ChannelPromise
to notify once the operation completesException
- thrown if an error occurspublic void handlerAdded(ChannelHandlerContext ctx) throws Exception
ChannelHandlerAdapter
handlerAdded
in interface ChannelHandler
handlerAdded
in class ChannelHandlerAdapter
Exception
Copyright © 2008–2017 The Netty Project. All rights reserved.