final class ExtraFields extends Object implements Cloneable
Extra Fields as they may
be present at several locations in ZipConstants archive files.
This class is not thread-safe.
| Modifier and Type | Field and Description |
|---|---|
private Map<Integer,ExtraField> |
extra
The map of Extra Fields.
|
| Constructor and Description |
|---|
ExtraFields() |
| Modifier and Type | Method and Description |
|---|---|
ExtraFields |
clone()
Returns a shallow clone of this collection.
|
ExtraField |
get(int headerID)
Returns the Extra Field with the given Header ID or
null
if no such Extra Field exists. |
(package private) byte[] |
getExtra()
Returns a protective copy of the Extra Fields.
|
(package private) int |
getExtraLength()
Returns the number of bytes required to hold the Extra Fields.
|
ExtraField |
put(ExtraField ef)
Stores the given Extra Field in this collection.
|
(package private) void |
readFrom(byte[] data,
int off,
int size)
Initializes this collection by deserializing a list of Extra Fields
of
size bytes from the
byte array data at the zero based offset off. |
ExtraField |
remove(int headerID)
Removes the Extra Field with the given Header ID.
|
int |
size()
Returns the number of Extra Fields in this collection.
|
(package private) void |
writeTo(byte[] data,
int off)
Serializes a list of Extra Fields of
getExtraLength() bytes to the
byte array data at the zero based offset off. |
private Map<Integer,ExtraField> extra
Integer] to Extra Field [ExtraField].
Must not be null, but may be empty if no Extra Fields are used.
The map is sorted by Header IDs in ascending order.public ExtraFields clone()
public int size()
public ExtraField get(int headerID)
null
if no such Extra Field exists.headerID - The requested Header ID.null
if no such Extra Field exists.IllegalArgumentException - If headerID is not in
the range of 0 to UShort.MAX_VALUE
(65535).public ExtraField put(ExtraField ef)
ef - The Extra Field to store in this collection.null if no such
Extra Field existed.NullPointerException - If ef is null.IllegalArgumentException - If the Header ID of the given Extra
Field is not in the range of 0 to
UShort.MAX_VALUE
(65535).public ExtraField remove(int headerID)
headerID - The requested Header ID.null
if no such Extra Field exists.IllegalArgumentException - If headerID is not in
the range of 0 to UShort.MAX_VALUE
(65535).int getExtraLength()
0.getExtra()byte[] getExtra()
null is never returned.getExtraLength()void readFrom(byte[] data,
int off,
int size)
size bytes from the
byte array data at the zero based offset off.
Upon return, this collection shall not access data
subsequently and getExtraLength() must equal size.data - The byte array to read the list of Extra Fields from.off - The zero based offset in the byte array where the first byte
of the list of Extra Fields is read from.size - The length of the list of Extra Fields in bytes.IndexOutOfBoundsException - If the byte array
data does not hold at least size
bytes at the zero based offset off.RuntimeException - If size is illegal or the
deserialized list of Extra Fields contains illegal data.getExtraLength()void writeTo(byte[] data,
int off)
getExtraLength() bytes to the
byte array data at the zero based offset off.
Upon return, this collection shall not access data
subsequently.data - The byte array to write the list of Extra Fields to.off - The zero based offset in the byte array where the first byte
of the list of Extra Fields is written to.IndexOutOfBoundsException - If the byte array
data does not hold at least getExtraLength()
bytes at the zero based offset off.getExtraLength()Copyright © 2005-2011 Schlichtherle IT Services. All Rights Reserved.