Package tigase.util
Class ZLibWrapper
java.lang.Object
tigase.util.ZLibWrapper
This is a warpper for java.util.zip package and Deflater/Inflater classes specifically. This implementation allows for easy interaction between Deflater/Inflater and java.nio API which operates on ByteBuffer data. It also does some tricky stuff to flush Deflater without reseting it and allow a better compression ration on the data.
There are a few convenience methods allowing to directly compress String to ByteBuffer and other way around - from ByteBuffer to String decompression. For these methods data are assumed to be UTF-8 character String.
Created: Jul 30, 2009 11:46:55 AM
- Version:
- $Rev$
- Author:
- Artur Hefczyc
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
static final int
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfloat
float
compress
(ByteBuffer input) decompress
(ByteBuffer input) decompressToString
(ByteBuffer input) void
end()
float
float
static void
void
setIOListener
(IOListener listener)
-
Field Details
-
COMPRESSED_BUFF_SIZE
public static final int COMPRESSED_BUFF_SIZE- See Also:
-
DECOMPRESSED_BUFF_SIZE
public static final int DECOMPRESSED_BUFF_SIZE- See Also:
-
-
Constructor Details
-
ZLibWrapper
public ZLibWrapper() -
ZLibWrapper
public ZLibWrapper(int level) -
ZLibWrapper
public ZLibWrapper(int level, int comp_buff_size)
-
-
Method Details
-
main
- Throws:
Exception
-
averageCompressionRate
public float averageCompressionRate() -
averageDecompressionRate
public float averageDecompressionRate() -
compress
-
compress
- Throws:
CharacterCodingException
-
decompress
- Throws:
IOException
-
decompressToString
- Throws:
CharacterCodingException
IOException
-
end
public void end() -
lastCompressionRate
public float lastCompressionRate() -
lastDecompressionRate
public float lastDecompressionRate() -
setIOListener
-