Package 

Enum ZipArchiveEntry.ExtraFieldParsingMode

  • All Implemented Interfaces:
    java.io.Serializable , java.lang.Comparable , org.readium.r2.shared.util.zip.compress.archivers.zip.ExtraFieldParsingBehavior , org.readium.r2.shared.util.zip.compress.archivers.zip.UnparseableExtraFieldBehavior

    
    public enum ZipArchiveEntry.ExtraFieldParsingMode
     implements ExtraFieldParsingBehavior
                        

    How to try to parse the extra fields.

    Configures the behavior for:

    • What shall happen if the extra field content doesn'tfollow the recommended pattern of two-byte id followed by atwo-byte length?
    • What shall happen if an extra field is generally supportedby Commons Compress but its content cannot be parsedcorrectly? This may for example happen if the archive iscorrupt, it triggers a bug in Commons Compress or the extrafield uses a version not (yet) supported by CommonsCompress.
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
      DRACONIC

      Throw an exception if any of the recognized extra fieldscannot be parsed or any extra field violates therecommended pattern.

      ONLY_PARSEABLE_STRICT

      Try to parse as many extra fields as possible and wrapunknown extra fields in UnrecognizedExtraField.

      Ignore extra data that doesn't follow the recommendedpattern.

      Throw an exception if an extra field that is generallysupported cannot be parsed.

      ONLY_PARSEABLE_LENIENT

      Try to parse as many extra fields as possible and wrapunknown extra fields as well as supported extra fields thatcannot be parsed in UnrecognizedExtraField.

      Ignore extra data that doesn't follow the recommendedpattern.

      STRICT_FOR_KNOW_EXTRA_FIELDS

      Try to parse as many extra fields as possible and wrapunknown extra fields in UnrecognizedExtraField.

      Wrap extra data that doesn't follow the recommendedpattern in an UnparseableExtraFieldData instance.

      Throw an exception if an extra field that is generallysupported cannot be parsed.

      This used to be the default behavior prior to CommonsCompress 1.19.

      BEST_EFFORT

      Try to parse as many extra fields as possible and wrapunknown extra fields as well as supported extra fields thatcannot be parsed in UnrecognizedExtraField.

      Wrap extra data that doesn't follow the recommendedpattern in an UnparseableExtraFieldData instance.

      This is the default behavior starting with Commons Compress 1.19.

    • Method Detail

      • createExtraField

         ZipExtraField createExtraField(ZipShort headerId)

        Creates an instance of ZipExtraField for the given id.

        A good default implementation would be .

        Parameters:
        headerId - the id for the extra field
      • fill

         ZipExtraField fill(ZipExtraField field, Array<byte> data, int off, int len, boolean local)

        Fills in the extra field data for a single extra field.

        A good default implementation would be .

        Parameters:
        field - the extra field instance to fill
        data - the array of extra field data
        off - offset into data where this field's data starts
        len - the length of this field's data
        local - whether the extra field data stems from the localfile header.
      • onUnparseableExtraField

         ZipExtraField onUnparseableExtraField(Array<byte> data, int off, int len, boolean local, int claimedLength)

        Decides what to do with extra field data that doesn't follow the recommended pattern.

        Parameters:
        data - the array of extra field data
        off - offset into data where the unparseable data starts
        len - the length of unparseable data
        local - whether the extra field data stems from the localfile header.
        claimedLength - length of the extra field claimed by thethird and forth byte if it did follow the recommended pattern