@NotThreadSafe @DefaultAnnotation(value=edu.umd.cs.findbugs.annotations.NonNull.class) final class ExtraFields extends Object implements Cloneable
Extra Fields as they may
be present at several locations in ZIP files.| 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 |
|---|---|
(package private) ExtraField |
add(ExtraField ef)
Stores the given Extra Field in this collection.
|
ExtraFields |
clone()
Returns a shallow clone of this collection.
|
(package private) 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.
|
(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. |
(package private) ExtraField |
remove(int headerId)
Removes the Extra Field with the given Header ID.
|
(package private) 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.ExtraField add(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 ExtraFields clone()
@CheckForNull 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).byte[] getExtra()
null is never returned.getExtraLength()int getExtraLength()
0.getExtra()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()@Nullable 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 size()
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 © 2004-2011 Schlichtherle IT Services. All Rights Reserved.