public class JZlibEncoder extends ZlibEncoder
ByteBuf
using the deflate algorithm.Constructor and Description |
---|
JZlibEncoder()
Creates a new zlib encoder with the default compression level (
6 ),
default window bits (15 ), default memory level (8 ),
and the default wrapper (ZlibWrapper.ZLIB ). |
JZlibEncoder(byte[] dictionary)
Creates a new zlib encoder with the default compression level (
6 ),
default window bits (15 ), default memory level (8 ),
and the specified preset dictionary. |
JZlibEncoder(int compressionLevel)
Creates a new zlib encoder with the specified
compressionLevel ,
default window bits (15 ), default memory level (8 ),
and the default wrapper (ZlibWrapper.ZLIB ). |
JZlibEncoder(int compressionLevel,
byte[] dictionary)
Creates a new zlib encoder with the specified
compressionLevel ,
default window bits (15 ), default memory level (8 ),
and the specified preset dictionary. |
JZlibEncoder(int compressionLevel,
int windowBits,
int memLevel,
byte[] dictionary)
Creates a new zlib encoder with the specified
compressionLevel ,
the specified windowBits , the specified memLevel ,
and the specified preset dictionary. |
JZlibEncoder(ZlibWrapper wrapper)
Creates a new zlib encoder with the default compression level (
6 ),
default window bits (15 ), default memory level (8 ),
and the specified wrapper. |
JZlibEncoder(ZlibWrapper wrapper,
int compressionLevel)
Creates a new zlib encoder with the specified
compressionLevel ,
default window bits (15 ), default memory level (8 ),
and the specified wrapper. |
JZlibEncoder(ZlibWrapper wrapper,
int compressionLevel,
int windowBits,
int memLevel)
Creates a new zlib encoder with the specified
compressionLevel ,
the specified windowBits , the specified memLevel , 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 promise)
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)
Encode a message into a
ByteBuf . |
void |
handlerAdded(io.netty.channel.ChannelHandlerContext ctx) |
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
public JZlibEncoder()
6
),
default window bits (15
), default memory level (8
),
and the default wrapper (ZlibWrapper.ZLIB
).CompressionException
- if failed to initialize zlibpublic JZlibEncoder(int compressionLevel)
compressionLevel
,
default window bits (15
), default memory level (8
),
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 JZlibEncoder(ZlibWrapper wrapper)
6
),
default window bits (15
), default memory level (8
),
and the specified wrapper.CompressionException
- if failed to initialize zlibpublic JZlibEncoder(ZlibWrapper wrapper, int compressionLevel)
compressionLevel
,
default window bits (15
), default memory level (8
),
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 JZlibEncoder(ZlibWrapper wrapper, int compressionLevel, int windowBits, int memLevel)
compressionLevel
,
the specified windowBits
, the specified memLevel
, 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
.windowBits
- The base two logarithm of the size of the history buffer. The
value should be in the range 9
to 15
inclusive.
Larger values result in better compression at the expense of
memory usage. The default value is 15
.memLevel
- How much memory should be allocated for the internal compression
state. 1
uses minimum memory and 9
uses maximum
memory. Larger values result in better and faster compression
at the expense of memory usage. The default value is 8
CompressionException
- if failed to initialize zlibpublic JZlibEncoder(byte[] dictionary)
6
),
default window bits (15
), default memory level (8
),
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 JZlibEncoder(int compressionLevel, byte[] dictionary)
compressionLevel
,
default window bits (15
), default memory level (8
),
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 JZlibEncoder(int compressionLevel, int windowBits, int memLevel, byte[] dictionary)
compressionLevel
,
the specified windowBits
, the specified memLevel
,
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
.windowBits
- The base two logarithm of the size of the history buffer. The
value should be in the range 9
to 15
inclusive.
Larger values result in better compression at the expense of
memory usage. The default value is 15
.memLevel
- How much memory should be allocated for the internal compression
state. 1
uses minimum memory and 9
uses maximum
memory. Larger values result in better and faster compression
at the expense of memory usage. The default value is 8
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 promise)
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
MessageToByteEncoder
ByteBuf
. This method will be called for each written message that can be handled
by this encoder.encode
in class MessageToByteEncoder<io.netty.buffer.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 void close(io.netty.channel.ChannelHandlerContext ctx, io.netty.channel.ChannelPromise promise)
close
in interface io.netty.channel.ChannelOutboundHandler
close
in class io.netty.channel.ChannelOutboundHandlerAdapter
Copyright © 2008–2019 The Netty Project. All rights reserved.