@NotThreadSafe 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.
|
static int |
DEFLATED
Method for Deflated compressed entries.
|
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.
|
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.
|
static short |
PLATFORM_FAT
Windows platform.
|
static short |
PLATFORM_UNIX
Unix platform.
|
static int |
STORED
Method for Stored (uncompressed) entries.
|
static byte |
UNKNOWN
The unknown value for numeric properties.
|
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 |
---|---|
void |
clearEncryption()
Sets the encryption property to
false and removes any other
encryption artifacts, e.g. |
ZipEntry |
clone() |
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.
|
int |
getMethod()
Returns the compression method for this entry.
|
String |
getName()
Returns the ZIP entry name.
|
int |
getPlatform() |
long |
getSize()
Returns the uncompressed size of this entry.
|
long |
getTime() |
boolean |
isDirectory()
Returns true if and only if this ZIP entry represents a directory entry
(i.e.
|
boolean |
isEncrypted()
Returns
true if and only if this ZIP entry is encrypted. |
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[] buf)
Sets the serialized extra fields by making a protective copy.
|
void |
setMethod(int method)
Sets the compression method for this entry.
|
void |
setPlatform(int platform) |
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 Valuespublic static final int DEFLATED
setMethod(int)
,
Constant Field Valuespublic static final long MAX_DOS_TIME
public static final long MIN_DOS_TIME
public static final short PLATFORM_FAT
public static final short PLATFORM_UNIX
public static final int STORED
setMethod(int)
,
Constant Field Valuespublic static final byte UNKNOWN
public ZipEntry(String name)
public final void clearEncryption()
false
and removes any other
encryption artifacts, e.g. a WinZip AES extra field.@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
for the conversion of Java time
to DOS date/time fields and vice versa.public final long getExternalAttributes()
public final byte[] getExtra()
ZipEntry.getExtra()
,
this method never returns null
.null
is never returned.public final int getMethod()
public final String getName()
public final int getPlatform()
public final long getSize()
setCompressedSize(long)
public final long getTime()
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.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[] buf) throws IllegalArgumentException
buf
- The byte array holding the serialized extra fields.IllegalArgumentException
- if the serialized extra fields exceed
64 KB or do not conform to the ZIP File Format Specification.public final void setMethod(int method)
IllegalArgumentException
- If method
is not
STORED
, DEFLATED
, BZIP2
or
UNKNOWN
.getMethod()
,
AbstractZipOutputStream.setMethod(int)
public final void setPlatform(int platform)
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 © 2005–2018 Schlichtherle IT Services. All rights reserved.