TrueZIP 6.8.2

de.schlichtherle.util.zip
Class DefaultExtraField

java.lang.Object
  extended by de.schlichtherle.util.zip.ExtraField
      extended by de.schlichtherle.util.zip.DefaultExtraField

final class DefaultExtraField
extends ExtraField

Default implementation for an Extra Field in a Local or Central Header of a ZIP archive.

This class is not thread-safe.

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

Field Summary
private  byte[] data
           
private  int headerID
           
 
Fields inherited from class de.schlichtherle.util.zip.ExtraField
ZIP64_HEADER_ID
 
Constructor Summary
DefaultExtraField(int headerID)
          Creates a new instance of the default Extra Field implementation.
 
Method Summary
(package private)  int getDataSize()
          Returns the Data Size of this Extra Field.
 int getHeaderID()
          Returns the Header ID (type) of this Extra Field.
(package private)  void readFrom(byte[] data, int off, int size)
          Initializes this Extra Field by deserializing a Data Block of size bytes from the byte array data at the zero based offset off.
(package private)  void writeTo(byte[] data, int off)
          Serializes a Data Block of ExtraField.getDataSize() bytes to the byte array data at the zero based offset off.
 
Methods inherited from class de.schlichtherle.util.zip.ExtraField
create, getDataBlock, register
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

headerID

private final int headerID

data

private byte[] data
Constructor Detail

DefaultExtraField

DefaultExtraField(int headerID)
Creates a new instance of the default Extra Field implementation.

Parameters:
headerID - An unsigned short integer (two bytes) indicating the type of the Extra Field.
Throws:
IllegalArgumentException - If
Method Detail

getHeaderID

public int getHeaderID()
Description copied from class: ExtraField
Returns the Header ID (type) of this Extra Field. The Header ID is an unsigned short integer (two bytes) which must be constant during the life cycle of this object.

Specified by:
getHeaderID in class ExtraField

getDataSize

int getDataSize()
Description copied from class: ExtraField
Returns the Data Size of this Extra Field. The Data Size is an unsigned short integer (two bytes) which indicates the length of the Data Block in bytes and does not include its own size in this Extra Field. This property may be initialized by calling ExtraField.readFrom(byte[], int, int).

Specified by:
getDataSize in class ExtraField
Returns:
The size of the Data Block in bytes or 0 if unknown.
See Also:
ExtraField.getDataBlock()

readFrom

void readFrom(byte[] data,
              int off,
              int size)
Description copied from class: ExtraField
Initializes this Extra Field by deserializing a Data Block of size bytes from the byte array data at the zero based offset off. Upon return, this Extra Field shall not access data subsequently and ExtraField.getDataSize() must equal size.

Specified by:
readFrom in class ExtraField
Parameters:
data - The byte array to read the Data Block from.
off - The zero based offset in the byte array where the first byte of the Data Block is read from.
size - The length of the Data Block in bytes.
See Also:
ExtraField.getDataSize()

writeTo

void writeTo(byte[] data,
             int off)
Description copied from class: ExtraField
Serializes a Data Block of ExtraField.getDataSize() bytes to the byte array data at the zero based offset off. Upon return, this Extra Field shall not access data subsequently.

Specified by:
writeTo in class ExtraField
Parameters:
data - The byte array to write the Data Block to.
off - The zero based offset in the byte array where the first byte of the Data Block is written to.
See Also:
ExtraField.getDataSize()

TrueZIP 6.8.2

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