public class ZlibEncoder extends ZlibCodec implements IEncoder<byte[],ByteBuffer>, IEventDrivenCodec
ZlibCodec.Mode| Modifier and Type | Field and Description |
|---|---|
protected Deflater |
deflater
The compressor used by this class to compress data.
|
| Modifier | Constructor and Description |
|---|---|
|
ZlibEncoder()
Creates a new zlib encoder with the default compression level (
6) and
the default mode (ZLIB). |
|
ZlibEncoder(byte[] dictionary)
Creates a new zlib encoder with a preset dictionary for compression, the
default compression level (
6) and the default mode
(ZLIB). |
|
ZlibEncoder(int level)
Creates a new zlib encoder with the specified compression level and the
default mode (
ZLIB). |
|
ZlibEncoder(int level,
byte[] dictionary)
Creates a new zlib encoder with the specified compression level and a preset
dictionary.
|
protected |
ZlibEncoder(int level,
byte[] dictionary,
ZlibCodec.Mode mode)
Creates a new zlib encoder with the specified compression level, a preset
dictionary and the mode.
|
|
ZlibEncoder(int level,
ZlibCodec.Mode mode)
Creates a new zlib encoder with the specified compression level and the mode.
|
| Modifier and Type | Method and Description |
|---|---|
void |
added(ISession session,
ICodecPipeline pipeline)
Does nothing.
|
protected int |
deflateBound(int len)
Returns upper bound on the compressed size.
|
void |
encode(ISession session,
byte[] data,
List<ByteBuffer> out)
Compresses the input data.
|
void |
event(ISession session,
SessionEvent event)
Finishes the compression when the associated session is ending
(
SessionEvent.ENDING). |
void |
finish()
Requests finishing of the compression.
|
boolean |
isFinished()
Tells if the compression has been finished.
|
protected void |
postFinish(ISession session,
ByteBuffer out)
Called right after the compression has been finished.
|
protected void |
preDeflate(ISession session,
byte[] in,
ByteBuffer out)
Called right before compression of a portion of uncompressed data.
|
protected void |
preFinish(ISession session,
ByteBuffer out)
Called right before finishing of the compression.
|
void |
removed(ISession session,
ICodecPipeline pipeline)
Does nothing.
|
getInboundType, getOutboundTypeclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetInboundType, getOutboundTypeprotected Deflater deflater
public ZlibEncoder()
6) and
the default mode (ZLIB).public ZlibEncoder(int level)
ZLIB).level - the compression level (0 - 9). 1 yields
the fastest compression and 9 yields the best
compression. 0 means no compression. The default
compression level is 6.IllegalArgumentException - if the compression level is out of rangepublic ZlibEncoder(byte[] dictionary)
6) and the default mode
(ZLIB).dictionary - the preset dictionary or null if no preset
dictionary should be usedpublic ZlibEncoder(int level,
ZlibCodec.Mode mode)
level - the compression level (0 - 9). 1 yields
the fastest compression and 9 yields the best
compression. 0 means no compression. The default
compression level is 6.mode - the mode for the zlib encoder (AUTO means
ZLIB)IllegalArgumentException - if the compression level is out of rangeNullPointerException - if the mode is nullpublic ZlibEncoder(int level,
byte[] dictionary)
level - the compression level (0 - 9). 1
yields the fastest compression and 9 yields the
best compression. 0 means no compression. The
default compression level is 6.dictionary - the preset dictionary or null if no preset
dictionary should be usedIllegalArgumentException - if the compression level is out of rangeprotected ZlibEncoder(int level,
byte[] dictionary,
ZlibCodec.Mode mode)
level - the compression level (0 - 9). 1
yields the fastest compression and 9 yields the
best compression. 0 means no compression. The
default compression level is 6.dictionary - the preset dictionary or null if no preset
dictionary should be usedmode - the mode for the zlib encoder (AUTO means
ZLIB)IllegalArgumentException - if the compression level is out of rangeNullPointerException - if the mode is nullprotected int deflateBound(int len)
len - the length of the uncompressed data.protected void preDeflate(ISession session, byte[] in, ByteBuffer out) throws Exception
session - the session object the encoder is associated within - the uncompressed input dataout - the output bufferException - if an error has occurredprotected void preFinish(ISession session, ByteBuffer out) throws Exception
session - the session object the encoder is associated without - the output bufferException - if an error has occurredprotected void postFinish(ISession session, ByteBuffer out) throws Exception
session - the session object the encoder is associated without - the output bufferException - if an error has occurredpublic void finish()
public boolean isFinished()
true if the compression has been finished.public void encode(ISession session, byte[] data, List<ByteBuffer> out) throws Exception
public void added(ISession session, ICodecPipeline pipeline)
added in interface IEventDrivenCodecsession - the session the pipeline is associated withpipeline - the pipeline the codec has been added topublic void event(ISession session, SessionEvent event)
SessionEvent.ENDING).event in interface IEventDrivenCodecsession - the session which state is changingevent - the session eventpublic void removed(ISession session, ICodecPipeline pipeline)
removed in interface IEventDrivenCodecsession - the session the pipeline is associated withpipeline - the pipeline the codec has been removed fromCopyright © 2017–2022 SNF4J.ORG. All rights reserved.