Class GZIPMemberSeries

java.lang.Object
java.io.InputStream
org.archive.format.gzip.GZIPMemberSeries
All Implemented Interfaces:
Closeable, AutoCloseable, GZIPConstants

public class GZIPMemberSeries extends InputStream implements GZIPConstants
Class which encapsulates all the logic in reading multiple gzip members from a single stream. The class supports as it's main method, "nextMember()" which returns a GZIPSeriesMember. The class allows configuration as to the robustness, namely the handling of errors in the underlying gzip stream. Regardless of robustness - an IOException from the underlying Stream will cause this class to throw an IOException whenever nextMember() is called. In Strict mode, any GZ error within a member will cause the object to behave as if an IOException was detected - nextMember() will repeatedly throw more IOExceptions. In Lax mode, a GZ error in a single member will cause this class to attempt to skip that failing member, and find the next gzip member in the series. This class maintains the state of the underlying gzip Stream: ) Deflating - a gzip header and some amount of deflate information has been read, without errors ) IOError - an IOException has been detected on the underlying Stream ) Aligned - the gzip footer of a record has *just* been read, and it is expected that the underlying Stream is either at EOF, or at the start of another gzip member. In Strict Mode this is the initial state. ) Scanning - The underlying Stream is in an unknown state - either because of a GZ error in the previous member, and we're now attempting to locate the next member. In Lax Mode, this is the initial state. The member returned by nextMember() is an InputStream, which also allows access to information about the specific record, namely information in the gzip header, as well as context information about the record within the series: filename and offset. The Member also provides information about the amount of compressed and uncompressed data read thus far. If a gzip format exception is detected while in a read() call of the gzip member, it will throw an IOException.GZIPFormatException to the caller. when the end of the deflate stream is found in a read() call, the member will also silently read the gzip footer, and check the length and CRC. A failure to read the footer, or a bad comparison between length or CRC will cause a GZIPFormatException to be thrown on that read() call. if nextMember() is called and the previous member has not been completely read, this class will automatically attempt to skip the previous record. If an error is encountered, the class either either throw an exception, or attempt to find the next member in the series.
Author:
brad
  • Field Details

    • STATE_DEFLATING

      public static int STATE_DEFLATING
    • STATE_IOERROR

      public static int STATE_IOERROR
    • STATE_ALIGNED

      public static int STATE_ALIGNED
    • STATE_SCANNING

      public static int STATE_SCANNING
    • STATE_START

      public static int STATE_START
    • state

      public int state
  • Constructor Details

    • GZIPMemberSeries

      public GZIPMemberSeries(Stream bis)
    • GZIPMemberSeries

      public GZIPMemberSeries(Stream bis, String context)
    • GZIPMemberSeries

      public GZIPMemberSeries(Stream bis, String context, long offset)
    • GZIPMemberSeries

      public GZIPMemberSeries(Stream bis, String context, long offset, boolean strict)
  • Method Details