Enum ZipArchiveEntry.ExtraFieldParsingMode
- java.lang.Object
-
- java.lang.Enum<ZipArchiveEntry.ExtraFieldParsingMode>
-
- org.apache.commons.compress.archivers.zip.ZipArchiveEntry.ExtraFieldParsingMode
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Comparable<ZipArchiveEntry.ExtraFieldParsingMode>
,ExtraFieldParsingBehavior
,UnparseableExtraFieldBehavior
- Enclosing class:
- ZipArchiveEntry
public static enum ZipArchiveEntry.ExtraFieldParsingMode extends java.lang.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'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 Constants Enum Constant Description 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
.DRACONIC
Throw an exception if any of the recognized extra fields cannot be parsed or any extra field violates the recommended pattern.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
.ONLY_PARSEABLE_STRICT
Try to parse as many extra fields as possible and wrap unknown extra fields inUnrecognizedExtraField
.STRICT_FOR_KNOW_EXTRA_FIELDS
Try to parse as many extra fields as possible and wrap unknown extra fields inUnrecognizedExtraField
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ZipExtraField
createExtraField(ZipShort headerId)
Creates an instance of ZipExtraField for the given id.ZipExtraField
fill(ZipExtraField field, byte[] data, int off, int len, boolean local)
Fills in the extra field data for a single extra field.ZipExtraField
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.static ZipArchiveEntry.ExtraFieldParsingMode
valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name.static ZipArchiveEntry.ExtraFieldParsingMode[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
BEST_EFFORT
public static final ZipArchiveEntry.ExtraFieldParsingMode 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
public static final ZipArchiveEntry.ExtraFieldParsingMode 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
public static final ZipArchiveEntry.ExtraFieldParsingMode 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
public static final ZipArchiveEntry.ExtraFieldParsingMode 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
public static final ZipArchiveEntry.ExtraFieldParsingMode DRACONIC
Throw an exception if any of the recognized extra fields cannot be parsed or any extra field violates the recommended pattern.
-
-
Method Detail
-
values
public static ZipArchiveEntry.ExtraFieldParsingMode[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (ZipArchiveEntry.ExtraFieldParsingMode c : ZipArchiveEntry.ExtraFieldParsingMode.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static ZipArchiveEntry.ExtraFieldParsingMode valueOf(java.lang.String name)
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:
java.lang.IllegalArgumentException
- if this enum type has no constant with the specified namejava.lang.NullPointerException
- if the argument is null
-
onUnparseableExtraField
public ZipExtraField onUnparseableExtraField(byte[] data, int off, int len, boolean local, int claimedLength) throws java.util.zip.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:
java.util.zip.ZipException
- if an error occurs or unparseable extra fields must not be accepted
-
createExtraField
public ZipExtraField createExtraField(ZipShort headerId) throws java.util.zip.ZipException, java.lang.InstantiationException, java.lang.IllegalAccessException
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
- Throws:
java.util.zip.ZipException
- if an error occursjava.lang.InstantiationException
- if unable to instantiate the classjava.lang.IllegalAccessException
- if not allowed to instantiate the class
-
fill
public ZipExtraField fill(ZipExtraField field, byte[] data, int off, int len, boolean local) throws java.util.zip.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:
java.util.zip.ZipException
- if an error occurs
-
-