Top Description Fields Constructors Methods
org.apache.tools.zip

public Class AsiExtraField

extends Object
implements ZipExtraField, UnixStat, Cloneable
Class Inheritance
All Implemented Interfaces
java.lang.Cloneable, org.apache.tools.zip.UnixStat, org.apache.tools.zip.ZipExtraField
Imports
java.util.zip.CRC32, .ZipException

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 filename
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.

Since the documentation this class is based upon doesn't mention the character encoding of the file name at all, it is assumed that it uses the current platform's default encoding.

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.

private static final ZipShort
private String
link

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

private int
mode

Standard Unix stat(2) file mode.

private int
uid

User ID.

private static final int

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.tools.zip.ZipExtraField.getCentralDirectoryData.

Delegate to local file data.
public ZipShort

Returns:

the centralDirectory length
getCentralDirectoryLength
()

Implements org.apache.tools.zip.ZipExtraField.getCentralDirectoryLength.

Delegate to local file data.
public int

Returns:

the group id
getGroupId
()

Get the group id.

public ZipShort

Returns:

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

Implements org.apache.tools.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.tools.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.tools.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
(int
the mode
mode
)

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

public int

Returns:

the user id
getUserId
()

Get the user id.

public boolean

Returns:

true if this entry is a directory
isDirectory
()

Is this entry a directory?

public void
parseFromLocalFileData(byte[]
an array of bytes
data
,
int
the start offset
offset
,
int
the number of bytes in the array from offset
length
)

Implements org.apache.tools.zip.ZipExtraField.parseFromLocalFileData.

Populate data from this array as if it was in local file data.
public void
setDirectory(boolean
if true, this entry is a directory
dirFlag
)

Indicate whether this entry is a directory.

public void
setGroupId(int
the group id
gid
)

Set the group id.

public void
setLinkedFile(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 filename.

public void
setMode(int
the file mode
mode
)

File mode of this file.

public void
setUserId(int
the user id
uid
)

Set the user id.

Inherited from java.lang.Object:
equalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

crcback to summary
private CRC32 crc

Instance used to calculate checksums.

Since
1.1
dirFlagback to summary
private boolean dirFlag

Is this an entry for a directory?

Since
1.1
gidback to summary
private int gid

Group ID.

Since
1.1
HEADER_IDback to summary
private static final ZipShort HEADER_ID
modeback to summary
private int mode

Standard Unix stat(2) file mode.

Since
1.1
uidback to summary
private int uid

User ID.

Since
1.1
WORDback to summary
private static final int WORD

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.tools.zip.ZipExtraField.getCentralDirectoryData.

Delegate to local file data.

Returns:byte[]

the local file data

Since
1.1
getCentralDirectoryLengthback to summary
public ZipShort getCentralDirectoryLength()

Implements org.apache.tools.zip.ZipExtraField.getCentralDirectoryLength.

Delegate to local file data.

Returns:ZipShort

the centralDirectory length

Since
1.1
getGroupIdback to summary
public int getGroupId()

Get the group id.

Returns:int

the group id

Since
1.1
getHeaderIdback to summary
public ZipShort getHeaderId()

Implements org.apache.tools.zip.ZipExtraField.getHeaderId.

The Header-ID.

Returns:ZipShort

the value for the header id for this extrafield

Since
1.1
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.

Since
1.1
getLocalFileDataDataback to summary
public byte[] getLocalFileDataData()

Implements org.apache.tools.zip.ZipExtraField.getLocalFileDataData.

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

Returns:byte[]

get the data

Since
1.1
getLocalFileDataLengthback to summary
public ZipShort getLocalFileDataLength()

Implements org.apache.tools.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

Since
1.1
getModeback to summary
public int getMode()

File mode of this file.

Returns:int

the file mode

Since
1.1
getModeback to summary
protected int getMode(int mode)

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

Parameters
mode:int

the mode

Returns:int

the type with the mode

Since
1.1
getUserIdback to summary
public int getUserId()

Get the user id.

Returns:int

the user id

Since
1.1
isDirectoryback to summary
public boolean isDirectory()

Is this entry a directory?

Returns:boolean

true if this entry is a directory

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

Implements org.apache.tools.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

Exceptions
ZipException:
on error
Since
1.1
setDirectoryback to summary
public void setDirectory(boolean dirFlag)

Indicate whether this entry is a directory.

Parameters
dirFlag:boolean

if true, this entry is a directory

Since
1.1
setGroupIdback to summary
public void setGroupId(int gid)

Set the group id.

Parameters
gid:int

the group id

Since
1.1
setLinkedFileback to summary
public void setLinkedFile(String name)

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

Parameters
name:String

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

Since
1.1
setModeback to summary
public void setMode(int mode)

File mode of this file.

Parameters
mode:int

the file mode

Since
1.1
setUserIdback to summary
public void setUserId(int uid)

Set the user id.

Parameters
uid:int

the user id

Since
1.1