@NotThreadSafe @DefaultAnnotation(value=edu.umd.cs.findbugs.annotations.NonNull.class) public class ZipEntry extends Object implements Cloneable
java.util.zip.ZipEntry.
For every numeric property of this class, the default value is
UNKNOWN in order to indicate an unknown state and it's
permitted to set this value explicitly in order to reset the property.
Note that a ZipEntry object can be used with only one
ZipFile or ZipOutputStream instance.
Reusing the same ZipEntry object with a second object of these
classes is an error and may result in unpredictable behaviour.
In general, this class is not thread-safe. However, it is safe to call only the getters of this class from multiple threads concurrently.
| Modifier and Type | Field and Description |
|---|---|
static int |
BZIP2
Method for BZIP2 compressed entries.
|
private String |
comment
Comment field.
|
private int |
crc |
private static int |
CRC |
private long |
csize |
static int |
DEFLATED
Method for Deflated compressed entries.
|
private int |
dtime |
private static int |
DTIME |
private int |
eattr |
private static int |
EATTR |
private ExtraFields |
fields
The map of Extra Fields.
|
private short |
general |
(package private) static int |
GPBF_DATA_DESCRIPTOR |
(package private) static int |
GPBF_ENCRYPTED
General Purpose Bit Flag mask for encrypted data.
|
(package private) static int |
GPBF_UTF8 |
private byte |
init |
static long |
MAX_DOS_TIME
Largest supported DOS date/time value in a ZIP file,
which is December 31st, 2107 AD 23:59:58 local time.
|
private short |
method |
private static int |
METHOD |
static long |
MIN_DOS_TIME
Smallest supported DOS date/time value in a ZIP file,
which is January 1st, 1980 AD 00:00:00 local time.
|
private String |
name |
private long |
offset
Relative Offset Of Local File Header.
|
private byte |
platform |
private static int |
PLATFORM |
static short |
PLATFORM_FAT
Windows platform.
|
static short |
PLATFORM_UNIX
Unix platform.
|
private long |
size |
static int |
STORED
Method for Stored (uncompressed) entries.
|
static byte |
UNKNOWN
The unknown value for numeric properties.
|
(package private) static int |
WINZIP_AES
Pseudo compression method for WinZip AES encrypted entries.
|
| Modifier | Constructor and Description |
|---|---|
|
ZipEntry(String name)
Constructs a new ZIP entry with the given name.
|
protected |
ZipEntry(String name,
ZipEntry template)
Constructs a new ZIP entry with the given name and all other properties
copied from the given template.
|
| Modifier and Type | Method and Description |
|---|---|
(package private) ExtraField |
addExtraField(ExtraField field) |
void |
clearEncryption()
Sets the encryption property to
false and removes any other
encryption artifacts, e.g. a WinZip AES extra field. |
ZipEntry |
clone() |
private ExtraField |
composeZip64ExtraField()
Composes a ZIP64 Extended Information Extra Field from the properties
of this entry.
|
String |
getComment() |
long |
getCompressedSize()
Returns the compressed size of this entry.
|
long |
getCrc() |
protected DateTimeConverter |
getDateTimeConverter()
Returns a
DateTimeConverter for the conversion of Java time
to DOS date/time fields and vice versa. |
long |
getExternalAttributes()
Returns the external file attributes.
|
byte[] |
getExtra()
Returns a protective copy of the serialized Extra Fields.
|
(package private) ExtraField |
getExtraField(int headerId) |
private byte[] |
getExtraFields(boolean zip64) |
(package private) boolean |
getGeneralPurposeBitFlag(int mask)
Returns the indexed General Purpose Bit Flag.
|
(package private) int |
getGeneralPurposeBitFlags()
Returns the General Purpose Bit Flags.
|
int |
getMethod()
Returns the compression method for this entry.
|
String |
getName()
Returns the ZIP entry name.
|
(package private) long |
getOffset() |
short |
getPlatform() |
(package private) String |
getRawComment() |
(package private) long |
getRawCompressedSize() |
(package private) long |
getRawCrc() |
(package private) long |
getRawExternalAttributes() |
(package private) byte[] |
getRawExtraFields()
Returns a protective copy of the serialized Extra Fields.
|
(package private) int |
getRawMethod() |
(package private) long |
getRawOffset() |
(package private) short |
getRawPlatform() |
(package private) long |
getRawSize() |
(package private) long |
getRawTime() |
(package private) int |
getRawVersionNeededToExtract() |
long |
getSize()
Returns the uncompressed size of this entry.
|
long |
getTime() |
(package private) boolean |
isDataDescriptorRequired() |
boolean |
isDirectory()
Returns true if and only if this ZIP entry represents a directory entry
(i.e. end with
'/'). |
boolean |
isEncrypted()
Returns
true if and only if this ZIP entry is encrypted. |
private boolean |
isInit(int mask) |
(package private) boolean |
isZip64ExtensionsRequired() |
private void |
parseZip64ExtraField()
Parses the properties of this entry from the ZIP64 Extended Information
Extra Field, if present.
|
(package private) ExtraField |
removeExtraField(int headerId) |
void |
setComment(String comment)
Sets the entry comment.
|
void |
setCompressedSize(long csize)
Sets the compressed size of this entry.
|
void |
setCrc(long crc) |
void |
setEncrypted(boolean encrypted)
Sets the encryption flag for this ZIP entry.
|
void |
setExternalAttributes(long eattr)
Sets the external file attributes.
|
void |
setExtra(byte[] data)
Sets the serialized Extra Fields by making a protective copy.
|
private void |
setExtraFields(byte[] data,
boolean zip64) |
(package private) void |
setGeneralPurposeBitFlag(int mask,
boolean bit)
Sets the indexed General Purpose Bit Flag.
|
(package private) void |
setGeneralPurposeBitFlags(int general)
Sets the General Purpose Bit Flags.
|
private void |
setInit(int mask,
boolean init) |
void |
setMethod(int method)
Sets the compression method for this entry.
|
void |
setPlatform(short platform) |
(package private) void |
setRawComment(String comment) |
(package private) void |
setRawCompressedSize(long csize) |
(package private) void |
setRawCrc(long crc) |
(package private) void |
setRawExternalAttributes(long eattr) |
(package private) void |
setRawExtraFields(byte[] data)
Sets extra fields and parses ZIP64 extra field.
|
(package private) void |
setRawMethod(int method) |
(package private) void |
setRawOffset(long offset) |
(package private) void |
setRawPlatform(int platform) |
(package private) void |
setRawSize(long size) |
(package private) void |
setRawTime(long dtime) |
void |
setSize(long size)
Sets the uncompressed size of this entry.
|
void |
setTime(long jtime) |
String |
toString()
Returns a string representation of this object for debugging and logging
purposes.
|
public static final int BZIP2
setMethod(int),
Constant Field Values@CheckForNull private String comment
private int crc
private static final int CRC
private long csize
public static final int DEFLATED
setMethod(int),
Constant Field Valuesprivate int dtime
private static final int DTIME
private int eattr
private static final int EATTR
@CheckForNull private ExtraFields fields
null or may be empty if no Extra Fields are used.private short general
static int GPBF_DATA_DESCRIPTOR
static int GPBF_ENCRYPTED
static int GPBF_UTF8
private byte init
public static final long MAX_DOS_TIME
private short method
private static final int METHOD
public static final long MIN_DOS_TIME
private String name
private long offset
private byte platform
private static final int PLATFORM
public static final short PLATFORM_FAT
public static final short PLATFORM_UNIX
private long size
public static final int STORED
setMethod(int),
Constant Field Valuespublic static final byte UNKNOWN
static final int WINZIP_AES
public ZipEntry(String name)
@Nullable final ExtraField addExtraField(ExtraField field)
public final void clearEncryption()
false and removes any other
encryption artifacts, e.g. a WinZip AES extra field.@CheckForNull private ExtraField composeZip64ExtraField()
@CheckForNull public final String getComment()
public final long getCompressedSize()
setCompressedSize(long)public final long getCrc()
protected DateTimeConverter getDateTimeConverter()
DateTimeConverter for the conversion of Java time
to DOS date/time fields and vice versa.
The implementation in the class ZipEntry returns
DateTimeConverter.JAR.
DateTimeConverter - never null.DateTimeConverterpublic final long getExternalAttributes()
public final byte[] getExtra()
ZipEntry.getExtra(),
this method never returns null.null is never returned.@Nullable final ExtraField getExtraField(int headerId)
private byte[] getExtraFields(boolean zip64)
final boolean getGeneralPurposeBitFlag(int mask)
final int getGeneralPurposeBitFlags()
public final int getMethod()
setMethod(int),
ZipOutputStream.getMethod()public final String getName()
final long getOffset()
public final short getPlatform()
final String getRawComment()
final long getRawCompressedSize()
final long getRawCrc()
final long getRawExternalAttributes()
final byte[] getRawExtraFields()
null is never returned.getRawExtraFields()final int getRawMethod()
final long getRawOffset()
final short getRawPlatform()
final long getRawSize()
final long getRawTime()
final int getRawVersionNeededToExtract()
public final long getSize()
setCompressedSize(long)public final long getTime()
final boolean isDataDescriptorRequired()
public final boolean isDirectory()
'/').public final boolean isEncrypted()
true if and only if this ZIP entry is encrypted.
Note that only WinZip AES encryption is currently supported.true if and only if this ZIP entry is encrypted.private boolean isInit(int mask)
final boolean isZip64ExtensionsRequired()
private void parseZip64ExtraField()
@Nullable final ExtraField removeExtraField(int headerId)
public final void setComment(@CheckForNull String comment)
comment - The entry comment.RuntimeException - if the entry comment exceeds 64 KB.public final void setCompressedSize(long csize)
csize - The Compressed Size.IllegalArgumentException - If csize is not in the
range from 0 to ULong.MAX_VALUE
(9223372036854775807L).getCompressedSize()public final void setCrc(long crc)
public final void setEncrypted(boolean encrypted)
true, you will also need to provide
crypto parameters.
Note that only WinZip AES encryption is
currently supported.
encrypted - whether or not this ZIP entry should get encrypted.public final void setExternalAttributes(long eattr)
eattr - the external file attributes.public final void setExtra(@CheckForNull byte[] data)
data - The byte array holding the serialized Extra Fields.RuntimeException - if the serialized Extra Fields exceed 64 KB
or do not conform to the ZIP File Format Specificationprivate void setExtraFields(byte[] data,
boolean zip64)
final void setGeneralPurposeBitFlag(int mask,
boolean bit)
final void setGeneralPurposeBitFlags(int general)
private void setInit(int mask,
boolean init)
public final void setMethod(int method)
IllegalArgumentException - If method is not
STORED, DEFLATED, BZIP2 or
UNKNOWN.getMethod(),
ZipOutputStream.setMethod(int)public final void setPlatform(short platform)
final void setRawComment(String comment)
final void setRawCompressedSize(long csize)
final void setRawCrc(long crc)
final void setRawExternalAttributes(long eattr)
final void setRawExtraFields(byte[] data)
final void setRawMethod(int method)
final void setRawOffset(long offset)
final void setRawPlatform(int platform)
final void setRawSize(long size)
final void setRawTime(long dtime)
public final void setSize(long size)
size - The (Uncompressed) Size.IllegalArgumentException - If size is not in the
range from 0 to ULong.MAX_VALUE
(9223372036854775807L).getCompressedSize()public final void setTime(long jtime)
Copyright © 2004-2011 Schlichtherle IT Services. All Rights Reserved.