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

public Class AsiExtraField

extends Object
implements ZipExtraField, UnixStat, Cloneable
Class Inheritance
All Implemented Interfaces
java.lang.Cloneable, org.apache.commons.compress.archivers.zip.UnixStat, org.apache.commons.compress.archivers.zip.ZipExtraField
Static Imports
org.apache.commons.compress.archivers.zip.ZipConstants.SHORT, .ZipConstants.WORD

Adds Unix file permission and UID/GID fields as well as symbolic link handling.

This class uses the ASi extra field in the format:

        Value         Size            Description
        -----         ----            -----------
(Unix3) 0x756e        Short           tag for this extra block type
        TSize         Short           total data size for this block
        CRC           Long            CRC-32 of the remaining data
        Mode          Short           file permissions
        SizDev        Long            symlink'd size OR major/minor dev num
        UID           Short           user ID
        GID           Short           group ID
        (var.)        variable        symbolic link file name

taken from appnote.iz (Info-ZIP note, 981119) found at ftp://ftp.uu.net/pub/archiving/zip/doc/

Short is two bytes and Long is four bytes in big-endian byte and word order, device numbers are currently not supported.

Field Summary

Modifier and TypeField and Description
private CRC32
crc

Instance used to calculate checksums.

private boolean
dirFlag

Is this an entry for a directory?

private int
gid

Group ID.

pack-priv static final ZipShort
private String
link

File this entry points to, if it is a symbolic link.

private static final int
private int
mode

Standard Unix stat(2) file mode.

private int
uid

User ID.

Constructor Summary

AccessConstructor and Description
public
AsiExtraField()

Constructor for AsiExtraField.

Method Summary

Modifier and TypeMethod and Description
public Object
clone()

Overrides java.lang.Object.clone.

Creates and returns a copy of this object.
public byte[]

Returns:

the local file data
getCentralDirectoryData
()

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

Delegate to local file data.
public ZipShort

Returns:

the centralDirectory length
getCentralDirectoryLength
()

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

Delegate to local file data.
public int

Returns:

the group id
getGroupId
()

Gets the group id.

public ZipShort

Returns:

the value for the header id for this extrafield
getHeaderId
()

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

The Header-ID.
public String

Returns:

name of the file this entry links to if it is a symbolic link, the empty string otherwise.
getLinkedFile
()

Name of linked file

public byte[]

Returns:

get the data
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

Returns:

a ZipShort for the length of the data of this extra field
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 int

Returns:

the file mode
getMode
()

File mode of this file.

protected int

Returns:

the type with the mode
getMode
(final int
the mode
mode
)

Gets the file mode for given permissions with the correct file type.

public int

Returns:

the user id
getUserId
()

Gets the user id.

public boolean

Returns:

true if this entry is a directory
isDirectory
()

Is this entry a directory?

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

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

Doesn't do anything special since this class always uses the same data in central directory and local file data.
public void
parseFromLocalFileData(final byte[]
an array of bytes
data
,
final int
the start offset
offset
,
final int
the number of bytes in the array from offset
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
setDirectory(final boolean
if true, this entry is a directory
dirFlag
)

Indicate whether this entry is a directory.

public void
setGroupId(final int
the group id
gid
)

Sets the group id.

public void
setLinkedFile(final String
Name of the file this entry links to, empty String if it is not a symbolic link.
name
)

Indicate that this entry is a symbolic link to the given file name.

public void
setMode(final int
the file mode
mode
)

File mode of this file.

public void
setUserId(final int
the user id
uid
)

Sets the user id.

Inherited from java.lang.Object:
equalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

crcback to summary
private CRC32 crc

Instance used to calculate checksums.

dirFlagback to summary
private boolean dirFlag

Is this an entry for a directory?

gidback to summary
private int gid

Group ID.

HEADER_IDback to summary
pack-priv static final ZipShort HEADER_ID
MIN_SIZEback to summary
private static final int MIN_SIZE
modeback to summary
private int mode

Standard Unix stat(2) file mode.

uidback to summary
private int uid

User ID.

Constructor Detail

AsiExtraFieldback to summary
public AsiExtraField()

Constructor for AsiExtraField.

Method Detail

cloneback to summary
public Object clone()

Overrides java.lang.Object.clone.

Doc from java.lang.Object.clone.

Creates and returns a copy of this object. The precise meaning of "copy" may depend on the class of the object. The general intent is that, for any object x, the expression:

x.clone() != x
will be true, and that the expression:
x.clone().getClass() == x.getClass()
will be true, but these are not absolute requirements. While it is typically the case that:
x.clone().equals(x)
will be true, this is not an absolute requirement.

By convention, the returned object should be obtained by calling super.clone. If a class and all of its superclasses (except Object) obey this convention, it will be the case that x.clone().getClass() == x.getClass().

By convention, the object returned by this method should be independent of this object (which is being cloned). To achieve this independence, it may be necessary to modify one or more fields of the object returned by super.clone before returning it. Typically, this means copying any mutable objects that comprise the internal "deep structure" of the object being cloned and replacing the references to these objects with references to the copies. If a class contains only primitive fields or references to immutable objects, then it is usually the case that no fields in the object returned by super.clone need to be modified.

Returns:Object

a clone of this instance.

Annotations
@Override
getCentralDirectoryDataback to summary
public byte[] getCentralDirectoryData()

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

Delegate to local file data.

Returns:byte[]

the local file data

Annotations
@Override
getCentralDirectoryLengthback to summary
public ZipShort getCentralDirectoryLength()

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

Delegate to local file data.

Returns:ZipShort

the centralDirectory length

Annotations
@Override
getGroupIdback to summary
public int getGroupId()

Gets the group id.

Returns:int

the group id

getHeaderIdback to summary
public ZipShort getHeaderId()

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

The Header-ID.

Returns:ZipShort

the value for the header id for this extrafield

Annotations
@Override
getLinkedFileback to summary
public String getLinkedFile()

Name of linked file

Returns:String

name of the file this entry links to if it is a symbolic link, the empty string otherwise.

getLocalFileDataDataback to summary
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.

Returns:byte[]

get the data

Annotations
@Override
getLocalFileDataLengthback to summary
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.

Returns:ZipShort

a ZipShort for the length of the data of this extra field

Annotations
@Override
getModeback to summary
public int getMode()

File mode of this file.

Returns:int

the file mode

getModeback to summary
protected int getMode(final int mode)

Gets the file mode for given permissions with the correct file type.

Parameters
mode:int

the mode

Returns:int

the type with the mode

getUserIdback to summary
public int getUserId()

Gets the user id.

Returns:int

the user id

isDirectoryback to summary
public boolean isDirectory()

Is this entry a directory?

Returns:boolean

true if this entry is a directory

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

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

Doesn't do anything special since this class always uses the same data in central directory and local file data.

Parameters
buffer:byte[]

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

the buffer to read data from

offset:int

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

offset into buffer to read data

length:int

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

the length of data

Annotations
@Override
Exceptions
ZipException:

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

on error

parseFromLocalFileDataback to summary
public void parseFromLocalFileData(final byte[] data, final int offset, final int length) throws ZipException

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

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

Parameters
data:byte[]

an array of bytes

offset:int

the start offset

length:int

the number of bytes in the array from offset

Annotations
@Override
Exceptions
ZipException:
on error
setDirectoryback to summary
public void setDirectory(final boolean dirFlag)

Indicate whether this entry is a directory.

Parameters
dirFlag:boolean

if true, this entry is a directory

setGroupIdback to summary
public void setGroupId(final int gid)

Sets the group id.

Parameters
gid:int

the group id

setLinkedFileback to summary
public void setLinkedFile(final String name)

Indicate that this entry is a symbolic link to the given file name.

Parameters
name:String

Name of the file this entry links to, empty String if it is not a symbolic link.

setModeback to summary
public void setMode(final int mode)

File mode of this file.

Parameters
mode:int

the file mode

setUserIdback to summary
public void setUserId(final int uid)

Sets the user id.

Parameters
uid:int

the user id