|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.mucommander.file.impl.zip.provider.ZipEntry
public class ZipEntry
Extension that adds better handling of extra fields and provides access to the internal and external file attributes.
--------------------------------------------------------------------------------------------------------------
This class is based off the org.apache.tools.zip package of the Apache Ant project. The Ant
code has been modified under the terms of the Apache License which you can find in the bundled muCommander license
file. It was forked at version 1.7.0 of Ant.
| Field Summary | |
|---|---|
protected static java.util.Calendar |
CALENDAR
An instance of Calendar shared through all instances of this class and used for Java<->DOS time conversion |
protected java.lang.String |
comment
An optional comment for this entry |
protected long |
compressedSize
Compressed size of the entry data |
protected long |
crc
CRC-32 checksum of the uncompressed entry data |
protected long |
dosTime
Data/time of this entry, in the DOS time format |
protected com.mucommander.file.impl.zip.provider.ZipEntryInfo |
entryInfo
Contains info about how this entry is stored in the zip file |
protected long |
externalAttributes
External attributes (4 bytes) |
protected java.util.Vector |
extraFields
List of extra fields, as ZipEntraField instances |
protected int |
internalAttributes
Internal attributes (2 bytes) |
protected long |
javaTime
Data/time of this entry, in the Java time format |
protected int |
method
Compression method that was used for the entry data |
protected static long |
MIN_DOS_TIME
Smallest DOS time (Epoch 1980) |
protected static int |
MSDOS_DIRECTORY_FLAG
Value of the bit flag that denotes an MS-DOS directory in the external attributes |
protected static int |
MSDOS_READ_ONLY_FLAG
Value of the bit flag that denotes a read-only MS-DOS file in the external attributes |
protected java.lang.String |
name
Name/path of this entry |
protected int |
platform
Platform, part of the 'version made by' central directory field |
protected static int |
PLATFORM_FAT
Value of the MSDOS/OS-2 platform (FAT filesystem) used in the 'version made by' central directory field |
protected static int |
PLATFORM_UNIX
Value of the Unix platform used in the 'version made by' central directory field |
protected long |
size
Uncompressed size of the entry data |
protected static int |
UNIX_DIRECTORY_FLAG
Value of the bit flag that denotes a Unix directory in the external attributes |
protected static int |
UNIX_FILE_FLAG
Value of the bit flag that denotes a Unix file in the external attributes |
protected static int |
USER_WRITE_PERMISSION_BIT
Value of the user write permission bit |
| Constructor Summary | |
|---|---|
ZipEntry()
Creates a new Zip entry with an empty name. |
|
ZipEntry(java.lang.String name)
Creates a new Zip entry with the specified name. |
|
ZipEntry(java.util.zip.ZipEntry entry)
Creates a new Zip entry with fields taken from the specified zip entry. |
|
| Method Summary | |
|---|---|
void |
addExtraField(ZipExtraField ze)
Adds an extra fields, replacing any extra field of the same type previously added. |
java.lang.Object |
clone()
Returns a cloned instance of this entry. |
protected static long |
dosToJavaTime(long dosTime)
|
boolean |
equals(java.lang.Object o)
Returns true if the given object is a ZipEntry that has the same name as this one. |
byte[] |
getCentralDirectoryExtra()
Returns the data of the central directory extra fields. |
java.lang.String |
getComment()
Returns the comment string for the entry, or null if there is none. |
long |
getCompressedSize()
Returns the size of the compressed entry data, or -1 if not known. |
long |
getCrc()
Returns the CRC-32 checksum of the uncompressed entry data, or -1 if not known. |
protected long |
getDosTime()
Returns this entry's date/time expressed in the DOS time format. |
protected com.mucommander.file.impl.zip.provider.ZipEntryInfo |
getEntryInfo()
Returns the ZipEntryInfo instance that contains info about how this entry is stored in the zip file. |
long |
getExternalAttributes()
Retrieves the external file attributes. |
ZipExtraField[] |
getExtraFields()
Returns the extra fields of this entry. |
int |
getInternalAttributes()
Retrieves the internal file attributes. |
byte[] |
getLocalFileDataExtra()
Returns the data of the local file extra fields. |
int |
getMethod()
Returns the compression method of the entry, or -1 if not specified. |
java.lang.String |
getName()
Returns the name of this entry. |
int |
getPlatform()
Returns the platform specification to put into the 'version made by' part of the central file header. |
long |
getSize()
Returns the uncompressed size of the entry data, or -1 if not known. |
long |
getTime()
Returns this entry's date/time expressed in the Java time format, i.e. |
int |
getUnixMode()
Unix permission. |
protected static int |
getUTF8Length(java.lang.String s)
|
int |
hashCode()
Returns a hash of this entry's name. |
boolean |
hasUnixMode()
Returns true if this ZipEntry has Unix mode/permissions. |
boolean |
isDirectory()
Returns true if the entry is a directory. |
protected boolean |
isValidUnsignedInt(long l)
Returns true if the given long is a valid unsigned int value, i.e. |
protected static long |
javaToDosTime(long javaTime)
Converts Java time (Epoch=1970) to DOS time (Epoch=1980). |
boolean |
removeExtraField(ZipShort type)
Removes the first extra field corresponding to the given type. |
void |
setComment(java.lang.String comment)
Sets the optional comment string for the entry. |
void |
setCompressedSize(long csize)
Sets the size of the compressed entry data. |
void |
setCrc(long crc)
Sets the CRC-32 checksum of the uncompressed entry data. |
protected void |
setDosTime(long dosTime)
Sets this entry's date/time to the specified one. |
protected void |
setEntryInfo(com.mucommander.file.impl.zip.provider.ZipEntryInfo entryInfo)
Sets the ZipEntryInfo instance that contains info about how this entry is stored in the zip file. |
void |
setExternalAttributes(long value)
Sets the external file attributes. |
void |
setExtra(byte[] extra)
Throws an IllegalArgumentException if byte array cannot be parsed into extra fields. |
void |
setExtraFields(ZipExtraField[] fields)
Replaces all current extra fields with the specified ones. |
void |
setInternalAttributes(int value)
Sets the internal file attributes. |
void |
setMethod(int method)
Sets the compression method for the entry. |
protected void |
setName(java.lang.String name)
Sets the name of this entry. |
protected void |
setPlatform(int platform)
Sets the platform: PLATFORM_FAT or PLATFORM_UNIX. |
void |
setSize(long size)
Sets the uncompressed size of the entry data. |
void |
setTime(long javaTime)
Sets this entry's date/time to the specified one. |
void |
setUnixMode(int mode)
Sets Unix permissions in a way that is understood by Info-Zip's unzip command. |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected java.lang.String name
protected long size
protected long compressedSize
protected long crc
protected long dosTime
protected long javaTime
protected int method
protected java.lang.String comment
protected int platform
protected int internalAttributes
protected long externalAttributes
protected java.util.Vector extraFields
protected com.mucommander.file.impl.zip.provider.ZipEntryInfo entryInfo
protected static final java.util.Calendar CALENDAR
protected static final long MIN_DOS_TIME
protected static final int UNIX_DIRECTORY_FLAG
protected static final int UNIX_FILE_FLAG
protected static final int MSDOS_DIRECTORY_FLAG
protected static final int MSDOS_READ_ONLY_FLAG
protected static final int USER_WRITE_PERMISSION_BIT
protected static final int PLATFORM_UNIX
protected static final int PLATFORM_FAT
| Constructor Detail |
|---|
public ZipEntry()
public ZipEntry(java.lang.String name)
name - the name of the entry
public ZipEntry(java.util.zip.ZipEntry entry)
throws java.util.zip.ZipException
entry - the entry to get fields from
java.util.zip.ZipException - on error| Method Detail |
|---|
public int getInternalAttributes()
public void setInternalAttributes(int value)
value - an int valuepublic long getExternalAttributes()
public void setExternalAttributes(long value)
value - an long valuepublic void setUnixMode(int mode)
mode - an int valuepublic int getUnixMode()
public boolean hasUnixMode()
true if this ZipEntry has Unix mode/permissions.
If that's not the case, the value returned by getUnixMode() has no meaning.
true if this ZipEntry has Unix mode/permissionspublic int getPlatform()
PLATFORM_FAT unless setUnixMode has been called,
in which case PLATFORM_UNIX will be returned.protected void setPlatform(int platform)
PLATFORM_FAT or PLATFORM_UNIX.
platform - PLATFORM_FAT or PLATFORM_UNIXpublic void setExtraFields(ZipExtraField[] fields)
fields - an array of extra fieldspublic ZipExtraField[] getExtraFields()
public void addExtraField(ZipExtraField ze)
ze - the extra field to addpublic boolean removeExtraField(ZipShort type)
type - the type of extra field to remove
true if an extra field corresponding to given type was removed, false if no
matching field was foundpublic byte[] getLocalFileDataExtra()
null.
public byte[] getCentralDirectoryExtra()
null.
public java.lang.String getName()
protected void setName(java.lang.String name)
name - the new name for this entrypublic boolean isDirectory()
true if the entry is a directory. Directory entries are characterized by their name
ending with a '/' character.
true if the entry is a directoryprotected com.mucommander.file.impl.zip.provider.ZipEntryInfo getEntryInfo()
ZipEntryInfo instance that contains info about how this entry is stored in the zip file.
ZipEntryInfo instance that contains info about how this entry is stored in the zip fileprotected void setEntryInfo(com.mucommander.file.impl.zip.provider.ZipEntryInfo entryInfo)
ZipEntryInfo instance that contains info about how this entry is stored in the zip file.
entryInfo - the ZipEntryInfo instance that contains info about how this entry is stored in the zip filepublic long getSize()
-1 if not known.
-1 if not knownpublic void setSize(long size)
size - the uncompressed size in bytes
java.lang.IllegalArgumentException - if the specified size is less than 0 or greater than 0xFFFFFFFF bytespublic long getCompressedSize()
-1 if not known. In the case of a stored entry,
the compressed size will be the same as the uncompressed size of the entry.
-1 if not knownpublic void setCompressedSize(long csize)
csize - the compressed size to set topublic long getCrc()
-1 if not known.
-1 if not knownpublic void setCrc(long crc)
crc - the new CRC-32 value
java.lang.IllegalArgumentException - if the specified CRC-32 value is less than 0 or greater than 0xFFFFFFFFpublic long getTime()
public void setTime(long javaTime)
javaTime - the new time of this entry, expressed in the Java time formatprotected long getDosTime()
protected void setDosTime(long dosTime)
dosTime - the new time of this entry, expressed in the DOS time formatpublic int getMethod()
-1 if not specified.
-1 if not specifiedpublic void setMethod(int method)
method - the compression method, either ZipConstants.STORED or ZipConstants.DEFLATED
java.lang.IllegalArgumentException - if the specified compression method is invalidpublic java.lang.String getComment()
null if there is none.
null if there is nonepublic void setComment(java.lang.String comment)
comment - the comment string
java.lang.IllegalArgumentException - if the length of the specified comment string is greater than 0xFFFF bytes
public void setExtra(byte[] extra)
throws java.lang.IllegalArgumentException
IllegalArgumentException if byte array cannot be parsed into extra fields.
extra - an array of bytes to be parsed into extra fields
java.lang.IllegalArgumentException - if the byte array cannot be parsed into extra fieldsprotected static long dosToJavaTime(long dosTime)
protected static long javaToDosTime(long javaTime)
javaTime - number of milliseconds since the epoch
protected static int getUTF8Length(java.lang.String s)
protected boolean isValidUnsignedInt(long l)
true if the given long is a valid unsigned int value, i.e. comprised between 0 and 2^32-1.
l - the long value to test
true if the given long is a valid unsigned int value, i.e. comprised between 0 and 2^32-1
public java.lang.Object clone()
throws java.lang.CloneNotSupportedException
clone in class java.lang.Objectjava.lang.CloneNotSupportedException - should never happenpublic int hashCode()
hashCode in class java.lang.Objectpublic boolean equals(java.lang.Object o)
true if the given object is a ZipEntry that has the same name as this one.
equals in class java.lang.Objecto - the object to test for equality
true if the given object is a ZipEntry that has the same name as this one
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
This file is part of muCommander - Copyright (C) 2002-2008 Maxence Bernard