Package se.digg.dgc.encoding
Class Zlib
- java.lang.Object
-
- se.digg.dgc.encoding.Zlib
-
public class Zlib extends Object
Compression/de-compression support.- Author:
- Martin Lindström (martin@idsec.se), Henrik Bengtsson (extern.henrik.bengtsson@digg.se), Henric Norlander (extern.henric.norlander@digg.se)
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static byte[]
compress(byte[] data)
Compresses the supplied data.static byte[]
decompress(byte[] data, boolean requireCompressed)
De-compresses the supplied data.static boolean
isCompressed(byte[] data)
Predicate that checks if the supplied data is compressed using the ZLIB algorithm.
-
-
-
Method Detail
-
compress
public static byte[] compress(byte[] data)
Compresses the supplied data.- Parameters:
data
- the data to compress- Returns:
- the compressed data
-
decompress
public static byte[] decompress(byte[] data, boolean requireCompressed) throws ZipException
De-compresses the supplied data.If
requireCompressed
istrue
we require the input data to contain a ZLIB header (i.e., be compressed using the ZLIB algorithm). If it isfalse
and aZipException
is caught, the input data is assumed to be un-compressed, and the method will returndata
.- Parameters:
data
- the data to de-compressrequireCompressed
- boolean telling whether we require the supplied data to be compressed- Returns:
- the de-compressed data
- Throws:
ZipException
- if requireCompressed is true and an inflate error occurs
-
isCompressed
public static boolean isCompressed(byte[] data)
Predicate that checks if the supplied data is compressed using the ZLIB algorithm.- Parameters:
data
- the data to check- Returns:
- true if the supplied data is compressed and false otherwise
-
-