org.apache.commons.compress.archivers.zip
Class Zip64ExtendedInformationExtraField

java.lang.Object
  extended by org.apache.commons.compress.archivers.zip.Zip64ExtendedInformationExtraField
All Implemented Interfaces:
ZipExtraField

public class Zip64ExtendedInformationExtraField
extends Object
implements ZipExtraField

Holds size and other extended information for entries that use Zip64 features.

From PKWARE's APPNOTE.TXT

 Zip64 Extended Information Extra Field (0x0001):

          The following is the layout of the zip64 extended 
          information "extra" block. If one of the size or
          offset fields in the Local or Central directory
          record is too small to hold the required data,
          a Zip64 extended information record is created.
          The order of the fields in the zip64 extended 
          information record is fixed, but the fields will
          only appear if the corresponding Local or Central
          directory record field is set to 0xFFFF or 0xFFFFFFFF.

          Note: all fields stored in Intel low-byte/high-byte order.

          Value      Size       Description
          -----      ----       -----------
  (ZIP64) 0x0001     2 bytes    Tag for this "extra" block type
          Size       2 bytes    Size of this "extra" block
          Original 
          Size       8 bytes    Original uncompressed file size
          Compressed
          Size       8 bytes    Size of compressed data
          Relative Header
          Offset     8 bytes    Offset of local header record
          Disk Start
          Number     4 bytes    Number of the disk on which
                                this file starts 

          This entry in the Local header must include BOTH original
          and compressed file size fields. If encrypting the 
          central directory and bit 13 of the general purpose bit
          flag is set indicating masking, the value stored in the
          Local Header for the original file size will be zero.
 

Currently Commons Compress doesn't support encrypting the central directory so the not about masking doesn't apply.

The implementation relies on data being read from the local file header and assumes that both size values are always present.

Since:
Apache Commons Compress 1.2
This class is not thread-safe

Constructor Summary
Zip64ExtendedInformationExtraField()
          This constructor should only be used by the code that reads archives inside of Commons Compress.
Zip64ExtendedInformationExtraField(ZipEightByteInteger size, ZipEightByteInteger compressedSize)
          Creates an extra field based on the original and compressed size.
Zip64ExtendedInformationExtraField(ZipEightByteInteger size, ZipEightByteInteger compressedSize, ZipEightByteInteger relativeHeaderOffset, ZipLong diskStart)
          Creates an extra field based on all four possible values.
 
Method Summary
 byte[] getCentralDirectoryData()
          The actual data to put into central directory - without Header-ID or length specifier.
 ZipShort getCentralDirectoryLength()
          Length of the extra field in the central directory - without Header-ID or length specifier.
 ZipEightByteInteger getCompressedSize()
          The compressed size stored in this extra field.
 ZipLong getDiskStartNumber()
          The disk start number stored in this extra field.
 ZipShort getHeaderId()
          The Header-ID.
 byte[] getLocalFileDataData()
          The actual data to put into local file data - without Header-ID or length specifier.
 ZipShort getLocalFileDataLength()
          Length of the extra field in the local file data - without Header-ID or length specifier.
 ZipEightByteInteger getRelativeHeaderOffset()
          The relative header offset stored in this extra field.
 ZipEightByteInteger getSize()
          The uncompressed size stored in this extra field.
 void parseFromCentralDirectoryData(byte[] buffer, int offset, int length)
          Populate data from this array as if it was in central directory data.
 void parseFromLocalFileData(byte[] buffer, int offset, int length)
          Populate data from this array as if it was in local file data.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Zip64ExtendedInformationExtraField

public Zip64ExtendedInformationExtraField()
This constructor should only be used by the code that reads archives inside of Commons Compress.


Zip64ExtendedInformationExtraField

public Zip64ExtendedInformationExtraField(ZipEightByteInteger size,
                                          ZipEightByteInteger compressedSize)
Creates an extra field based on the original and compressed size.

Parameters:
size - the entry's original size
compressedSize - the entry's compressed size
Throws:
IllegalArgumentException - if size or compressedSize is null

Zip64ExtendedInformationExtraField

public Zip64ExtendedInformationExtraField(ZipEightByteInteger size,
                                          ZipEightByteInteger compressedSize,
                                          ZipEightByteInteger relativeHeaderOffset,
                                          ZipLong diskStart)
Creates an extra field based on all four possible values.

Parameters:
size - the entry's original size
compressedSize - the entry's compressed size
Throws:
IllegalArgumentException - if size or compressedSize is null
Method Detail

getHeaderId

public ZipShort getHeaderId()
The Header-ID.

Specified by:
getHeaderId in interface ZipExtraField
Returns:
The HeaderId value

getLocalFileDataLength

public ZipShort getLocalFileDataLength()
Length of the extra field in the local file data - without Header-ID or length specifier.

Specified by:
getLocalFileDataLength in interface ZipExtraField
Returns:
The LocalFileDataLength value

getCentralDirectoryLength

public ZipShort getCentralDirectoryLength()
Length of the extra field in the central directory - without Header-ID or length specifier.

Specified by:
getCentralDirectoryLength in interface ZipExtraField
Returns:
The CentralDirectoryLength value

getLocalFileDataData

public byte[] getLocalFileDataData()
The actual data to put into local file data - without Header-ID or length specifier.

Specified by:
getLocalFileDataData in interface ZipExtraField
Returns:
The LocalFileDataData value

getCentralDirectoryData

public byte[] getCentralDirectoryData()
The actual data to put into central directory - without Header-ID or length specifier.

Specified by:
getCentralDirectoryData in interface ZipExtraField
Returns:
The CentralDirectoryData value

parseFromLocalFileData

public void parseFromLocalFileData(byte[] buffer,
                                   int offset,
                                   int length)
                            throws ZipException
Populate data from this array as if it was in local file data.

Specified by:
parseFromLocalFileData in interface ZipExtraField
Parameters:
buffer - the buffer to read data from
offset - offset into buffer to read data
length - the length of data
Throws:
ZipException - on error

parseFromCentralDirectoryData

public void parseFromCentralDirectoryData(byte[] buffer,
                                          int offset,
                                          int length)
                                   throws ZipException
Populate data from this array as if it was in central directory data.

Specified by:
parseFromCentralDirectoryData in interface ZipExtraField
Parameters:
buffer - the buffer to read data from
offset - offset into buffer to read data
length - the length of data
Throws:
ZipException - on error

getSize

public ZipEightByteInteger getSize()
The uncompressed size stored in this extra field.


getCompressedSize

public ZipEightByteInteger getCompressedSize()
The compressed size stored in this extra field.


getRelativeHeaderOffset

public ZipEightByteInteger getRelativeHeaderOffset()
The relative header offset stored in this extra field.


getDiskStartNumber

public ZipLong getDiskStartNumber()
The disk start number stored in this extra field.



Copyright © 2011 The Apache Software Foundation. All Rights Reserved.