Top Description Inners Fields Constructors Methods
org.apache.tools.zip

public Class ExtraFieldUtils

extends Object
Class Inheritance
Imports
java.lang.reflect.InvocationTargetException, java.util.ArrayList, .List, .Map, java.util.concurrent.ConcurrentHashMap, java.util.zip.ZipException

ZipExtraField related methods

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
ExtraFieldUtils.UnparseableExtraField

"enum" for the possible actions to take if the extra field cannot be parsed.

Field Summary

Modifier and TypeField and Description
private static final Map<ZipShort, Class<?>>
implementations

Static registry of known extra fields.

private static final int

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static ZipExtraField

Returns:

an instance of the appropriate ExtraField
createExtraField
(ZipShort
the header identifier
headerId
)

Create an instance of the appropriate ExtraField, falls back to UnrecognizedExtraField.

public static byte[]

Returns:

an array of bytes
mergeCentralDirectoryData
(ZipExtraField[]
an array of ExtraFields
data
)

Merges the central directory fields of the given ZipExtraFields.

public static byte[]

Returns:

an array of bytes
mergeLocalFileDataData
(ZipExtraField[]
an array of ExtraFiles
data
)

Merges the local file data fields of the given ZipExtraFields.

public static ZipExtraField[]

Returns:

an array of ExtraFields
parse
(byte[]
an array of bytes as it appears in local file data
data
)

Split the array into ExtraFields and populate them with the given data as local file data, throwing an exception if the data cannot be parsed.

public static ZipExtraField[]

Returns:

an array of ExtraFields
parse
(byte[]
an array of bytes
data
,
boolean
whether data originates from the local file data or the central directory
local
)

Split the array into ExtraFields and populate them with the given data, throwing an exception if the data cannot be parsed.

public static ZipExtraField[]

Returns:

an array of ExtraFields
parse
(byte[]
an array of bytes
data
,
boolean
whether data originates from the local file data or the central directory
local
,
ExtraFieldUtils.UnparseableExtraField
what to do if the extra field data cannot be parsed.
onUnparseableData
)

Split the array into ExtraFields and populate them with the given data.

public static void
register(Class<?>
the class to register
c
)

Register a ZipExtraField implementation.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

implementationsback to summary
private static final Map<ZipShort, Class<?>> implementations

Static registry of known extra fields.

Since
1.1
WORDback to summary
private static final int WORD

Constructor Detail

ExtraFieldUtilsback to summary
public ExtraFieldUtils()

Method Detail

createExtraFieldback to summary
public static ZipExtraField createExtraField(ZipShort headerId) throws InstantiationException, IllegalAccessException

Create an instance of the appropriate ExtraField, falls back to UnrecognizedExtraField.

Parameters
headerId:ZipShort

the header identifier

Returns:ZipExtraField

an instance of the appropriate ExtraField

Exceptions
InstantiationException:
if unable to instantiate the class
IllegalAccessException:
if not allowed to instantiate the class
Since
1.1
mergeCentralDirectoryDataback to summary
public static byte[] mergeCentralDirectoryData(ZipExtraField[] data)

Merges the central directory fields of the given ZipExtraFields.

Parameters
data:ZipExtraField[]

an array of ExtraFields

Returns:byte[]

an array of bytes

Since
1.1
mergeLocalFileDataDataback to summary
public static byte[] mergeLocalFileDataData(ZipExtraField[] data)

Merges the local file data fields of the given ZipExtraFields.

Parameters
data:ZipExtraField[]

an array of ExtraFiles

Returns:byte[]

an array of bytes

Since
1.1
parseback to summary
public static ZipExtraField[] parse(byte[] data) throws ZipException

Split the array into ExtraFields and populate them with the given data as local file data, throwing an exception if the data cannot be parsed.

Parameters
data:byte[]

an array of bytes as it appears in local file data

Returns:ZipExtraField[]

an array of ExtraFields

Exceptions
ZipException:
on error
parseback to summary
public static ZipExtraField[] parse(byte[] data, boolean local) throws ZipException

Split the array into ExtraFields and populate them with the given data, throwing an exception if the data cannot be parsed.

Parameters
data:byte[]

an array of bytes

local:boolean

whether data originates from the local file data or the central directory

Returns:ZipExtraField[]

an array of ExtraFields

Exceptions
ZipException:
on error
Since
1.1
parseback to summary
public static ZipExtraField[] parse(byte[] data, boolean local, ExtraFieldUtils.UnparseableExtraField onUnparseableData) throws ZipException

Split the array into ExtraFields and populate them with the given data.

Parameters
data:byte[]

an array of bytes

local:boolean

whether data originates from the local file data or the central directory

onUnparseableData:ExtraFieldUtils.UnparseableExtraField

what to do if the extra field data cannot be parsed.

Returns:ZipExtraField[]

an array of ExtraFields

Exceptions
ZipException:
on error
Since
Ant 1.8.1
registerback to summary
public static void register(Class<?> c)

Register a ZipExtraField implementation.

The given class must have a no-arg constructor and implement the ZipExtraField interface.

Parameters
c:Class<?>

the class to register

Since
1.1
org.apache.tools.zip back to summary

public final Class ExtraFieldUtils.UnparseableExtraField

extends Object
Class Inheritance

"enum" for the possible actions to take if the extra field cannot be parsed.

Field Summary

Modifier and TypeField and Description
private final int
public static final ExtraFieldUtils.UnparseableExtraField
READ

Read the extra field data into an instance of UnparseableExtraFieldData.

public static final int
READ_KEY

Key for "read" action.

public static final ExtraFieldUtils.UnparseableExtraField
SKIP

Skip the extra field entirely and don't make its data available - effectively removing the extra field data.

public static final int
SKIP_KEY

Key for "skip" action.

public static final ExtraFieldUtils.UnparseableExtraField
THROW

Throw an exception if field cannot be parsed.

public static final int
THROW_KEY

Key for "throw an exception" action.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public int

Returns:

int
getKey
()

Key of the action to take.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

keyback to summary
private final int key
READback to summary
public static final ExtraFieldUtils.UnparseableExtraField READ

Read the extra field data into an instance of UnparseableExtraFieldData.

READ_KEYback to summary
public static final int READ_KEY

Key for "read" action.

SKIPback to summary
public static final ExtraFieldUtils.UnparseableExtraField SKIP

Skip the extra field entirely and don't make its data available - effectively removing the extra field data.

SKIP_KEYback to summary
public static final int SKIP_KEY

Key for "skip" action.

THROWback to summary
public static final ExtraFieldUtils.UnparseableExtraField THROW

Throw an exception if field cannot be parsed.

THROW_KEYback to summary
public static final int THROW_KEY

Key for "throw an exception" action.

Constructor Detail

UnparseableExtraFieldback to summary
private UnparseableExtraField(int k)

Method Detail

getKeyback to summary
public int getKey()

Key of the action to take.

Returns:int

int