Class Compression
java.lang.Object
uk.ac.starlink.util.Compression
Characterises the compression status of a stream, and provides methods
for decompressing it.
- Author:
- Mark Taylor (Starlink)
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final CompressionA Compression object representing BZip2 compression.static final CompressionA Compression object representing Unix compress-type compression.static final CompressionA Compression object representing GZip compression.static final intNumber of bytes needed to determine compression type (magic number).static final CompressionA Compression object representing no compression (or perhaps an unknown one). -
Method Summary
Modifier and TypeMethodDescriptionabstract InputStreamdecompress(InputStream raw) Returns a stream which is a decompressed version of the input stream, according to this objects compression type.static InputStreamReturns a decompressed version of the given input stream.static CompressiongetCompression(byte[] magic) Returns a Compression object characterising the compression (if any) represented by a given magic number.toString()Returns the name of this compression type.
-
Field Details
-
MAGIC_SIZE
public static final int MAGIC_SIZENumber of bytes needed to determine compression type (magic number).- See Also:
-
NONE
A Compression object representing no compression (or perhaps an unknown one). Thedecompressmethod will return the raw input stream unchanged. -
GZIP
A Compression object representing GZip compression. -
BZIP2
A Compression object representing BZip2 compression. -
COMPRESS
A Compression object representing Unix compress-type compression.
-
-
Method Details
-
decompress
Returns a stream which is a decompressed version of the input stream, according to this objects compression type.- Parameters:
raw- the raw input stream- Returns:
- a stream giving the decompressed version of
raw - Throws:
IOException
-
getCompression
Returns a Compression object characterising the compression (if any) represented by a given magic number.- Parameters:
magic- a buffer containing the firstMAGIC_SIZEbytes of input of the stream to be characterised- Returns:
- a
Compressionobject of the type represented bymagic - Throws:
IllegalArgumentException- ifmagic.length<MAGIC_SIZE
-
decompressStatic
Returns a decompressed version of the given input stream.- Parameters:
raw- the raw input stream- Returns:
- the decompressed version of
raw - Throws:
IOException
-
toString
-