TrueZIP 6.8.2

de.schlichtherle.util.zip
Class ExtraFields

java.lang.Object
  extended by de.schlichtherle.util.zip.ExtraFields
All Implemented Interfaces:
Cloneable

final class ExtraFields
extends Object
implements Cloneable

Represents a collection of Extra Fields as they may be present at several locations in ZIP archive files.

This class is not thread-safe.

Since:
TrueZIP 6.7
Version:
$Id: ExtraFields.java 5e709f50671d 2010/11/05 11:52:07 christian $
Author:
Christian Schlichtherle

Field Summary
private  Map extra
          The map of Extra Fields.
 
Constructor Summary
ExtraFields()
           
 
Method Summary
 Object 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.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

extra

private Map extra
The map of Extra Fields. Maps from Header ID [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.

Constructor Detail

ExtraFields

ExtraFields()
Method Detail

clone

public Object clone()
Returns a shallow clone of this collection.

Overrides:
clone in class Object

size

public int size()
Returns the number of Extra Fields in this collection.


get

public ExtraField get(int headerID)
Returns the Extra Field with the given Header ID or null if no such Extra Field exists.

Parameters:
headerID - The requested Header ID.
Returns:
The Extra Field with the given Header ID or null if no such Extra Field exists.
Throws:
IllegalArgumentException - If headerID is not in the range of 0 to UShort.MAX_VALUE (65535).

put

public ExtraField put(ExtraField ef)
Stores the given Extra Field in this collection.

Parameters:
ef - The Extra Field to store in this collection.
Returns:
The Extra Field previously associated with the Header ID of of the given Extra Field or null if no such Extra Field existed.
Throws:
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).

remove

public ExtraField remove(int headerID)
Removes the Extra Field with the given Header ID.

Parameters:
headerID - The requested Header ID.
Returns:
The Extra Field with the given Header ID or null if no such Extra Field exists.
Throws:
IllegalArgumentException - If headerID is not in the range of 0 to UShort.MAX_VALUE (65535).

getExtraLength

int getExtraLength()
Returns the number of bytes required to hold the Extra Fields.

Returns:
The length of the Extra Fields in bytes. May be 0.
See Also:
getExtra()

getExtra

byte[] getExtra()
Returns a protective copy of the Extra Fields. null is never returned.

See Also:
getExtraLength()

readFrom

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. Upon return, this collection shall not access data subsequently and getExtraLength() must equal size.

Parameters:
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.
Throws:
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.
See Also:
getExtraLength()

writeTo

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. Upon return, this collection shall not access data subsequently.

Parameters:
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.
Throws:
IndexOutOfBoundsException - If the byte array data does not hold at least getExtraLength() bytes at the zero based offset off.
See Also:
getExtraLength()

TrueZIP 6.8.2

Copyright © 2005-2011 Schlichtherle IT Services. All Rights Reserved.