|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.bolet.jgz.GZipDecoder
public class GZipDecoder
This class implements a generic decoder for gzip
stream headers. A gzip
stream is a concatenation of
"members". Each member is compressed with a method (the only
currently defined method is number 8, for the "deflate" algorithm)
and is associated with some meta-information, such as the source file
name or last modification time.
A GZipDecoder
instance can be used to decode the
member headers. Note that this class does not handle decompression
itself: the decompressor must be invoked externally. The
gzip
format (documented in RFC 1952) assumes that
compressed data is self-terminated; hence, the member header does not
contain any indication as to the compressed data length.
Each member begins with a header, followed by the compressed data, and then a member footer. The member footer contains the uncompressed data length (truncated to 32-bit) and a 32-bit CRC checksum on the uncompressed data; both values shall be used to check successful decompression. The stream processing should go thus:
Check of length and CRC are
The get*()
methods provide access to data obtained by
decoding the member header or footer. Unless otherwise specified, the
data is made available when the header has been decoded; the
uncompressed data size and CRC are decoded from the footer, which means
that their value becomes available only after a call to
closeMember()
.
Field Summary | |
---|---|
static int |
DEFLATE
Compression method: "deflate" algorithm (RFC 1951). |
static int |
FCOMMENT
Header flag: there is a comment field. |
static int |
FEXTRA
Header flag: there is some extra data. |
static int |
FHCRC
Header flag: header has its own CRC checksum. |
static int |
FNAME
Header flag: there is a source file name. |
static int |
FTEXT
Header flag: compressed data is probably an ASCII text. |
Constructor Summary | |
---|---|
GZipDecoder(java.io.InputStream sub)
Build the decoder over the provided stream for compressed data. |
Method Summary | |
---|---|
void |
closeMember()
Decode the member footer. |
java.lang.String |
getComment()
Get the member comment (optional). |
int |
getCompressionMethod()
Get the compression method. |
int |
getFlags()
Get the header flags (8-bit value). |
int |
getFlagsExtra()
Get the extra flags (8 bits). |
int |
getMTime()
Get the source file last modification time (32-bit "unix" time, as a number of seconds since the Epoch). |
java.lang.String |
getOriginalFileName()
Get the data source file name (optional). |
int |
getOS()
Get the stream producer operating system (1-byte identifier). |
java.io.InputStream |
getSubStream()
Get the underlying stream which this decoder uses. |
int |
getUncompressedCRC()
Get the CRC over uncompressed data (32-bit value, from the member footer). |
int |
getUncompressedSize()
Get the uncompressed data size for this member (truncated to 32 bits). |
java.io.InputStream |
nextMember()
Decode the next member header. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int FTEXT
public static final int FHCRC
public static final int FEXTRA
public static final int FNAME
public static final int FCOMMENT
public static final int DEFLATE
Constructor Detail |
---|
public GZipDecoder(java.io.InputStream sub)
sub
- the compressed data streamMethod Detail |
---|
public java.io.InputStream nextMember() throws java.io.IOException
null
is returned. Otherwise (at least one byte was read but no
valid header was found), an IOException
is thrown.
null
java.io.IOException
- on I/O or format errorpublic void closeMember() throws java.io.IOException
java.io.IOException
- on I/O or format errorpublic int getCompressionMethod()
public int getFlags()
public int getMTime()
public int getFlagsExtra()
public int getOS()
public java.lang.String getOriginalFileName()
null
public java.lang.String getComment()
null
public int getUncompressedCRC()
public int getUncompressedSize()
public java.io.InputStream getSubStream()
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |