public class JdkZlibEncoder extends ZlibEncoder
ByteBuf
using the deflate algorithm.Constructor and Description |
---|
JdkZlibEncoder()
Creates a new zlib encoder with the default compression level (
6 )
and the default wrapper (ZlibWrapper.ZLIB ). |
JdkZlibEncoder(byte[] dictionary)
Creates a new zlib encoder with the default compression level (
6 )
and the specified preset dictionary. |
JdkZlibEncoder(int compressionLevel)
Creates a new zlib encoder with the specified
compressionLevel
and the default wrapper (ZlibWrapper.ZLIB ). |
JdkZlibEncoder(int compressionLevel,
byte[] dictionary)
Creates a new zlib encoder with the specified
compressionLevel
and the specified preset dictionary. |
JdkZlibEncoder(ZlibWrapper wrapper)
Creates a new zlib encoder with the default compression level (
6 )
and the specified wrapper. |
JdkZlibEncoder(ZlibWrapper wrapper,
int compressionLevel)
Creates a new zlib encoder with the specified
compressionLevel
and the specified wrapper. |
Modifier and Type | Method and Description |
---|---|
io.netty.channel.ChannelFuture |
close()
Close this
ZlibEncoder and so finish the encoding. |
void |
close(io.netty.channel.ChannelHandlerContext ctx,
io.netty.channel.ChannelPromise promise) |
io.netty.channel.ChannelFuture |
close(io.netty.channel.ChannelPromise future)
Close this
ZlibEncoder and so finish the encoding. |
protected void |
encode(io.netty.channel.ChannelHandlerContext ctx,
io.netty.buffer.ByteBuf in,
io.netty.buffer.ByteBuf out)
Encodes the from one
ByteBuf to an other. |
void |
handlerAdded(io.netty.channel.ChannelHandlerContext ctx) |
boolean |
isClosed()
Returns
true if and only if the end of the compressed stream
has been reached. |
flush, sendFile
discardOutboundReadBytes, flush, newOutboundBuffer
bind, connect, deregister, disconnect, read
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
public JdkZlibEncoder()
6
)
and the default wrapper (ZlibWrapper.ZLIB
).CompressionException
- if failed to initialize zlibpublic JdkZlibEncoder(int compressionLevel)
compressionLevel
and the default wrapper (ZlibWrapper.ZLIB
).compressionLevel
- 1
yields the fastest compression and 9
yields the
best compression. 0
means no compression. The default
compression level is 6
.CompressionException
- if failed to initialize zlibpublic JdkZlibEncoder(ZlibWrapper wrapper)
6
)
and the specified wrapper.CompressionException
- if failed to initialize zlibpublic JdkZlibEncoder(ZlibWrapper wrapper, int compressionLevel)
compressionLevel
and the specified wrapper.compressionLevel
- 1
yields the fastest compression and 9
yields the
best compression. 0
means no compression. The default
compression level is 6
.CompressionException
- if failed to initialize zlibpublic JdkZlibEncoder(byte[] dictionary)
6
)
and the specified preset dictionary. The wrapper is always
ZlibWrapper.ZLIB
because it is the only format that supports
the preset dictionary.dictionary
- the preset dictionaryCompressionException
- if failed to initialize zlibpublic JdkZlibEncoder(int compressionLevel, byte[] dictionary)
compressionLevel
and the specified preset dictionary. The wrapper is always
ZlibWrapper.ZLIB
because it is the only format that supports
the preset dictionary.compressionLevel
- 1
yields the fastest compression and 9
yields the
best compression. 0
means no compression. The default
compression level is 6
.dictionary
- the preset dictionaryCompressionException
- if failed to initialize zlibpublic io.netty.channel.ChannelFuture close()
ZlibEncoder
ZlibEncoder
and so finish the encoding.
The returned ChannelFuture
will be notified once the
operation completes.close
in class ZlibEncoder
public io.netty.channel.ChannelFuture close(io.netty.channel.ChannelPromise future)
ZlibEncoder
ZlibEncoder
and so finish the encoding.
The given ChannelFuture
will be notified once the operation
completes and will also be returned.close
in class ZlibEncoder
public boolean isClosed()
ZlibEncoder
true
if and only if the end of the compressed stream
has been reached.isClosed
in class ZlibEncoder
protected void encode(io.netty.channel.ChannelHandlerContext ctx, io.netty.buffer.ByteBuf in, io.netty.buffer.ByteBuf out) throws Exception
ByteToByteEncoder
ByteBuf
to an other. This method will be called till either the input
ByteBuf
has nothing to read anymore or till nothing was read from the input ByteBuf
.encode
in class ByteToByteEncoder
ctx
- the ChannelHandlerContext
which this ByteToByteDecoder
belongs toin
- the ByteBuf
from which to read dataout
- the ByteBuf
to which the decoded data will be writtenException
- is thrown if an error accourpublic void close(io.netty.channel.ChannelHandlerContext ctx, io.netty.channel.ChannelPromise promise) throws Exception
close
in interface io.netty.channel.ChannelOperationHandler
close
in class io.netty.channel.ChannelOperationHandlerAdapter
Exception
Copyright © 2008-2013 The Netty Project. All Rights Reserved.