Enum ZipArchiveEntry.ExtraFieldParsingMode
- All Implemented Interfaces:
Serializable
,Comparable<ZipArchiveEntry.ExtraFieldParsingMode>
,ExtraFieldParsingBehavior
,UnparseableExtraFieldBehavior
- Enclosing class:
- ZipArchiveEntry
Configures the behavior for:
- What shall happen if the extra field content doesn't follow the recommended pattern of two-byte id followed by a two-byte length?
- What shall happen if an extra field is generally supported by Commons Compress but its content cannot be parsed correctly? This may for example happen if the archive is corrupt, it triggers a bug in Commons Compress or the extra field uses a version not (yet) supported by Commons Compress.
- Since:
- 1.19
-
Enum Constant Summary
Enum ConstantDescriptionTry to parse as many extra fields as possible and wrap unknown extra fields as well as supported extra fields that cannot be parsed inUnrecognizedExtraField
.Throw an exception if any of the recognized extra fields cannot be parsed or any extra field violates the recommended pattern.Try to parse as many extra fields as possible and wrap unknown extra fields as well as supported extra fields that cannot be parsed inUnrecognizedExtraField
.Try to parse as many extra fields as possible and wrap unknown extra fields inUnrecognizedExtraField
.Try to parse as many extra fields as possible and wrap unknown extra fields inUnrecognizedExtraField
. -
Method Summary
Modifier and TypeMethodDescriptioncreateExtraField
(ZipShort headerId) Creates an instance of ZipExtraField for the given id.fill
(ZipExtraField field, byte[] data, int off, int len, boolean local) Fills in the extra field data for a single extra field.onUnparseableExtraField
(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.Returns the enum constant of this type with the specified name.values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
Enum Constant Details
-
BEST_EFFORT
Try to parse as many extra fields as possible and wrap unknown extra fields as well as supported extra fields that cannot be parsed inUnrecognizedExtraField
.Wrap extra data that doesn't follow the recommended pattern in an
UnparseableExtraFieldData
instance.This is the default behavior starting with Commons Compress 1.19.
-
STRICT_FOR_KNOW_EXTRA_FIELDS
Try to parse as many extra fields as possible and wrap unknown extra fields inUnrecognizedExtraField
.Wrap extra data that doesn't follow the recommended pattern in an
UnparseableExtraFieldData
instance.Throw an exception if an extra field that is generally supported cannot be parsed.
This used to be the default behavior prior to Commons Compress 1.19.
-
ONLY_PARSEABLE_LENIENT
Try to parse as many extra fields as possible and wrap unknown extra fields as well as supported extra fields that cannot be parsed inUnrecognizedExtraField
.Ignore extra data that doesn't follow the recommended pattern.
-
ONLY_PARSEABLE_STRICT
Try to parse as many extra fields as possible and wrap unknown extra fields inUnrecognizedExtraField
.Ignore extra data that doesn't follow the recommended pattern.
Throw an exception if an extra field that is generally supported cannot be parsed.
-
DRACONIC
Throw an exception if any of the recognized extra fields cannot be parsed or any extra field violates the recommended pattern.
-
-
Method Details
-
values
Returns an array containing the constants of this enum type, in the order they are declared.- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is null
-
createExtraField
Description copied from interface:ExtraFieldParsingBehavior
Creates an instance of ZipExtraField for the given id.A good default implementation would be
ExtraFieldUtils.createExtraField(org.apache.commons.compress.archivers.zip.ZipShort)
.- Specified by:
createExtraField
in interfaceExtraFieldParsingBehavior
- Parameters:
headerId
- the id for the extra field- Returns:
- an instance of ZipExtraField, must not be
null
-
fill
public ZipExtraField fill(ZipExtraField field, byte[] data, int off, int len, boolean local) throws ZipException Description copied from interface:ExtraFieldParsingBehavior
Fills in the extra field data for a single extra field.A good default implementation would be
ExtraFieldUtils.fillExtraField(org.apache.commons.compress.archivers.zip.ZipExtraField, byte[], int, int, boolean)
.- Specified by:
fill
in interfaceExtraFieldParsingBehavior
- Parameters:
field
- the extra field instance to filldata
- the array of extra field dataoff
- offset into data where this field's data startslen
- the length of this field's datalocal
- whether the extra field data stems from the local file header. If this is false then the data is part if the central directory header extra data.- Returns:
- the filled field. Usually this is the same as
field
but it could be a replacement extra field as well. Must not benull
. - Throws:
ZipException
- if an error occurs
-
onUnparseableExtraField
public ZipExtraField onUnparseableExtraField(byte[] data, int off, int len, boolean local, int claimedLength) throws ZipException Description copied from interface:UnparseableExtraFieldBehavior
Decides what to do with extra field data that doesn't follow the recommended pattern.- Specified by:
onUnparseableExtraField
in interfaceUnparseableExtraFieldBehavior
- Parameters:
data
- the array of extra field dataoff
- offset into data where the unparseable data startslen
- the length of unparseable datalocal
- whether the extra field data stems from the local file header. If this is false then the data is part if the central directory header extra data.claimedLength
- length of the extra field claimed by the third and forth byte if it did follow the recommended pattern- Returns:
- null if the data should be ignored or an extra field implementation that represents the data
- Throws:
ZipException
- if an error occurs or unparseable extra fields must not be accepted
-