Top Description Fields Constructors Methods
org.apache.commons.compress.archivers.zip

public Class Zip64ExtendedInformationExtraField

extends Object
implements ZipExtraField
Class Inheritance
All Implemented Interfaces
org.apache.commons.compress.archivers.zip.ZipExtraField
Static Imports
org.apache.commons.compress.archivers.zip.ZipConstants.DWORD, .ZipConstants.WORD

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

Currently Commons Compress doesn't support encrypting the central directory so the note in APPNOTE.TXT 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
1.2
See Also
PKWARE APPNOTE.TXT, section 4.5.3

Field Summary

Modifier and TypeField and Description
private ZipEightByteInteger
private ZipLong
pack-priv static final ZipShort
private static final String
private byte[]
private ZipEightByteInteger
private ZipEightByteInteger

Constructor Summary

AccessConstructor and Description
public
Zip64ExtendedInformationExtraField()

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

public
Zip64ExtendedInformationExtraField(final ZipEightByteInteger
the entry's original size
size
,
final ZipEightByteInteger
the entry's compressed size
compressedSize
)

Creates an extra field based on the original and compressed size.

public
Zip64ExtendedInformationExtraField(final ZipEightByteInteger
the entry's original size
size
,
final ZipEightByteInteger
the entry's compressed size
compressedSize
,
final ZipEightByteInteger
the entry's offset
relativeHeaderOffset
,
final ZipLong
the disk start
diskStart
)

Creates an extra field based on all four possible values.

Method Summary

Modifier and TypeMethod and Description
private int
addSizes(final byte[] data)

public byte[]
getCentralDirectoryData()

Implements org.apache.commons.compress.archivers.zip.ZipExtraField.getCentralDirectoryData.

The actual data to put into central directory - without Header-ID or length specifier.
public ZipShort
getCentralDirectoryLength()

Implements org.apache.commons.compress.archivers.zip.ZipExtraField.getCentralDirectoryLength.

Length of the extra field in the central directory - without Header-ID or length specifier.
public ZipEightByteInteger

Returns:

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

The compressed size stored in this extra field.

public ZipLong

Returns:

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

The disk start number stored in this extra field.

public ZipShort
public byte[]
getLocalFileDataData()

Implements org.apache.commons.compress.archivers.zip.ZipExtraField.getLocalFileDataData.

The actual data to put into local file data - without Header-ID or length specifier.
public ZipShort
getLocalFileDataLength()

Implements org.apache.commons.compress.archivers.zip.ZipExtraField.getLocalFileDataLength.

Length of the extra field in the local file data - without Header-ID or length specifier.
public ZipEightByteInteger

Returns:

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

The relative header offset stored in this extra field.

public ZipEightByteInteger

Returns:

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

The uncompressed size stored in this extra field.

public void
parseFromCentralDirectoryData(final byte[]
the buffer to read data from
buffer
,
int
offset into buffer to read data
offset
,
final int
the length of data
length
)

Implements org.apache.commons.compress.archivers.zip.ZipExtraField.parseFromCentralDirectoryData.

Populate data from this array as if it was in central directory data.
public void
parseFromLocalFileData(final byte[]
the buffer to read data from
buffer
,
int
offset into buffer to read data
offset
,
final int
the length of data
length
)

Implements org.apache.commons.compress.archivers.zip.ZipExtraField.parseFromLocalFileData.

Populate data from this array as if it was in local file data.
public void
reparseCentralDirectoryData(final boolean
flag to read from central directory
hasUncompressedSize
,
final boolean
flag to read from central directory
hasCompressedSize
,
final boolean
flag to read from central directory
hasRelativeHeaderOffset
,
final boolean
flag to read from central directory
hasDiskStart
)

Parses the raw bytes read from the central directory extra field with knowledge which fields are expected to be there.

public void
setCompressedSize(final ZipEightByteInteger
The uncompressed size stored in this extra field.
compressedSize
)

The uncompressed size stored in this extra field.

public void
setDiskStartNumber(final ZipLong
The disk start number stored in this extra field.
ds
)

The disk start number stored in this extra field.

public void
setRelativeHeaderOffset(final ZipEightByteInteger
The relative header offset stored in this extra field.
rho
)

The relative header offset stored in this extra field.

public void
setSize(final ZipEightByteInteger
The uncompressed size stored in this extra field.
size
)

The uncompressed size stored in this extra field.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

compressedSizeback to summary
private ZipEightByteInteger compressedSize
diskStartback to summary
private ZipLong diskStart
HEADER_IDback to summary
pack-priv static final ZipShort HEADER_ID
LFH_MUST_HAVE_BOTH_SIZES_MSGback to summary
private static final String LFH_MUST_HAVE_BOTH_SIZES_MSG
rawCentralDirectoryDataback to summary
private byte[] rawCentralDirectoryData

Stored in parseFromCentralDirectoryData so it can be reused when ZipFile calls reparseCentralDirectoryData.

Not used for anything else

Since
1.3
relativeHeaderOffsetback to summary
private ZipEightByteInteger relativeHeaderOffset
sizeback to summary
private ZipEightByteInteger size

Constructor Detail

Zip64ExtendedInformationExtraFieldback to summary
public Zip64ExtendedInformationExtraField()

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

Zip64ExtendedInformationExtraFieldback to summary
public Zip64ExtendedInformationExtraField(final ZipEightByteInteger size, final ZipEightByteInteger compressedSize)

Creates an extra field based on the original and compressed size.

Parameters
size:ZipEightByteInteger

the entry's original size

compressedSize:ZipEightByteInteger

the entry's compressed size

Exceptions
IllegalArgumentException:
if size or compressedSize is null
Zip64ExtendedInformationExtraFieldback to summary
public Zip64ExtendedInformationExtraField(final ZipEightByteInteger size, final ZipEightByteInteger compressedSize, final ZipEightByteInteger relativeHeaderOffset, final ZipLong diskStart)

Creates an extra field based on all four possible values.

Parameters
size:ZipEightByteInteger

the entry's original size

compressedSize:ZipEightByteInteger

the entry's compressed size

relativeHeaderOffset:ZipEightByteInteger

the entry's offset

diskStart:ZipLong

the disk start

Exceptions
IllegalArgumentException:
if size or compressedSize is null

Method Detail

addSizesback to summary
private int addSizes(final byte[] data)
getCentralDirectoryDataback to summary
public byte[] getCentralDirectoryData()

Implements org.apache.commons.compress.archivers.zip.ZipExtraField.getCentralDirectoryData.

Doc from org.apache.commons.compress.archivers.zip.ZipExtraField.getCentralDirectoryData.

The actual data to put into central directory - without Header-ID or length specifier.

Returns:byte[]

the data

Annotations
@Override
getCentralDirectoryLengthback to summary
public ZipShort getCentralDirectoryLength()

Implements org.apache.commons.compress.archivers.zip.ZipExtraField.getCentralDirectoryLength.

Doc from org.apache.commons.compress.archivers.zip.ZipExtraField.getCentralDirectoryLength.

Length of the extra field in the central directory - without Header-ID or length specifier.

Returns:ZipShort

the length of the field in the central directory

Annotations
@Override
getCompressedSizeback to summary
public ZipEightByteInteger getCompressedSize()

The compressed size stored in this extra field.

Returns:ZipEightByteInteger

The compressed size stored in this extra field.

getDiskStartNumberback to summary
public ZipLong getDiskStartNumber()

The disk start number stored in this extra field.

Returns:ZipLong

The disk start number stored in this extra field.

getHeaderIdback to summary
public ZipShort getHeaderId()

Implements org.apache.commons.compress.archivers.zip.ZipExtraField.getHeaderId.

Doc from org.apache.commons.compress.archivers.zip.ZipExtraField.getHeaderId.

The Header-ID.

Returns:ZipShort

The HeaderId value

Annotations
@Override
getLocalFileDataDataback to summary
public byte[] getLocalFileDataData()

Implements org.apache.commons.compress.archivers.zip.ZipExtraField.getLocalFileDataData.

Doc from org.apache.commons.compress.archivers.zip.ZipExtraField.getLocalFileDataData.

The actual data to put into local file data - without Header-ID or length specifier.

Returns:byte[]

the data

Annotations
@Override
getLocalFileDataLengthback to summary
public ZipShort getLocalFileDataLength()

Implements org.apache.commons.compress.archivers.zip.ZipExtraField.getLocalFileDataLength.

Doc from org.apache.commons.compress.archivers.zip.ZipExtraField.getLocalFileDataLength.

Length of the extra field in the local file data - without Header-ID or length specifier.

Returns:ZipShort

the length of the field in the local file data

Annotations
@Override
getRelativeHeaderOffsetback to summary
public ZipEightByteInteger getRelativeHeaderOffset()

The relative header offset stored in this extra field.

Returns:ZipEightByteInteger

The relative header offset stored in this extra field.

getSizeback to summary
public ZipEightByteInteger getSize()

The uncompressed size stored in this extra field.

Returns:ZipEightByteInteger

The uncompressed size stored in this extra field.

parseFromCentralDirectoryDataback to summary
public void parseFromCentralDirectoryData(final byte[] buffer, int offset, final int length) throws ZipException

Implements org.apache.commons.compress.archivers.zip.ZipExtraField.parseFromCentralDirectoryData.

Doc from org.apache.commons.compress.archivers.zip.ZipExtraField.parseFromCentralDirectoryData.

Populate data from this array as if it was in central directory data.

Parameters
buffer:byte[]

the buffer to read data from

offset:int

offset into buffer to read data

length:int

the length of data

Annotations
@Override
Exceptions
ZipException:
on error
parseFromLocalFileDataback to summary
public void parseFromLocalFileData(final byte[] buffer, int offset, final int length) throws ZipException

Implements org.apache.commons.compress.archivers.zip.ZipExtraField.parseFromLocalFileData.

Doc from org.apache.commons.compress.archivers.zip.ZipExtraField.parseFromLocalFileData.

Populate data from this array as if it was in local file data.

Parameters
buffer:byte[]

the buffer to read data from

offset:int

offset into buffer to read data

length:int

the length of data

Annotations
@Override
Exceptions
ZipException:
on error
reparseCentralDirectoryDataback to summary
public void reparseCentralDirectoryData(final boolean hasUncompressedSize, final boolean hasCompressedSize, final boolean hasRelativeHeaderOffset, final boolean hasDiskStart) throws ZipException

Parses the raw bytes read from the central directory extra field with knowledge which fields are expected to be there.

All four fields inside the zip64 extended information extra field are optional and must only be present if their corresponding entry inside the central directory contains the correct magic value.

Parameters
hasUncompressedSize:boolean

flag to read from central directory

hasCompressedSize:boolean

flag to read from central directory

hasRelativeHeaderOffset:boolean

flag to read from central directory

hasDiskStart:boolean

flag to read from central directory

Exceptions
ZipException:
on error
setCompressedSizeback to summary
public void setCompressedSize(final ZipEightByteInteger compressedSize)

The uncompressed size stored in this extra field.

Parameters
compressedSize:ZipEightByteInteger

The uncompressed size stored in this extra field.

setDiskStartNumberback to summary
public void setDiskStartNumber(final ZipLong ds)

The disk start number stored in this extra field.

Parameters
ds:ZipLong

The disk start number stored in this extra field.

setRelativeHeaderOffsetback to summary
public void setRelativeHeaderOffset(final ZipEightByteInteger rho)

The relative header offset stored in this extra field.

Parameters
rho:ZipEightByteInteger

The relative header offset stored in this extra field.

setSizeback to summary
public void setSize(final ZipEightByteInteger size)

The uncompressed size stored in this extra field.

Parameters
size:ZipEightByteInteger

The uncompressed size stored in this extra field.