@DefaultAnnotation(value=edu.umd.cs.findbugs.annotations.NonNull.class) @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 |
|---|---|
private String |
comment
Comment field.
|
private int |
crc |
private static int |
CRC |
private long |
csize |
static int |
DEFLATED
Compression method for compressed (deflated) entries.
|
private ExtraFields |
fields
The map of Extra Fields.
|
private short |
general |
private static int |
GENERAL |
private byte |
init |
private long |
jTime |
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 static int |
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
Compression method for uncompressed (stored) entries.
|
static byte |
UNKNOWN
The unknown value for numeric properties.
|
| Constructor and Description |
|---|
ZipEntry(String name)
Constructs a new ZIP entry with the specified name.
|
ZipEntry(String name,
ZipEntry template)
Constructs a new ZIP entry with the given name which has all other
properties copied from the given template.
|
| Modifier and Type | Method and Description |
|---|---|
ZipEntry |
clone() |
private ExtraField |
compileZip64ExtraField()
Compiles a ZIP64 Extended Information Extra Field from the properties
of this entry.
|
String |
getComment() |
(package private) int |
getCommentLength(Charset charset) |
long |
getCompressedSize()
Returns the compressed size of this entry.
|
(package private) long |
getCompressedSize32() |
long |
getCrc() |
protected DateTimeConverter |
getDateTimeConverter()
Returns a
DateTimeConverter for the conversion of Java time
to DOS date/time fields and vice versa. |
protected long |
getDosTime() |
byte[] |
getExtra()
Returns a protective copy of the serialized Extra Fields.
|
(package private) byte[] |
getExtra(boolean zip64)
Returns a protective copy of the serialized Extra Fields.
|
(package private) int |
getExtraLength()
Returns the length of the serialized Extra Fields in bytes.
|
private ExtraFields |
getFields(boolean zip64) |
(package private) int |
getGeneral() |
(package private) boolean |
getGeneralBit(int index) |
int |
getMethod()
Returns the compression method for this entry.
|
String |
getName()
Returns the ZIP entry name.
|
(package private) int |
getNameLength(Charset charset) |
(package private) long |
getOffset() |
(package private) long |
getOffset32() |
short |
getPlatform() |
long |
getSize()
Returns the uncompressed size of this entry.
|
(package private) long |
getSize32() |
long |
getTime() |
boolean |
isDirectory()
Returns true if and only if this ZIP entry represents a directory entry
(i.e. end with
'/'). |
private boolean |
isInit(int index) |
private void |
parseZip64ExtraField()
Parses the properties of this entry from the ZIP64 Extended Information
Extra Field, if present.
|
void |
setComment(String comment) |
void |
setCompressedSize(long csize)
Sets the compressed size of this entry.
|
(package private) void |
setCompressedSize32(long csize) |
private void |
setCompressedSize64(long csize) |
void |
setCrc(long crc) |
protected void |
setDosTime(long dTime) |
void |
setExtra(byte[] data)
Sets the serialized Extra Fields by making a protective copy.
|
private void |
setExtra0(byte[] data) |
(package private) void |
setGeneral(int general) |
(package private) void |
setGeneralBit(int index,
boolean bit) |
private void |
setInit(int index,
boolean init) |
void |
setMethod(int method)
Sets the compression method for this entry.
|
private void |
setName0(String name) |
(package private) void |
setOffset(long offset) |
(package private) void |
setOffset32(long offset) |
private void |
setOffset64(long offset) |
void |
setPlatform(short platform) |
void |
setSize(long size)
Sets the uncompressed size of this entry.
|
(package private) void |
setSize32(long size) |
private void |
setSize64(long size) |
void |
setTime(long jTime) |
String |
toString()
Returns a string representation of this object.
|
private static final int NAME
private static final int PLATFORM
private static final int GENERAL
private static final int METHOD
private static final int CRC
public static final byte UNKNOWN
public static final short PLATFORM_FAT
public static final short PLATFORM_UNIX
public static final int STORED
public static final int DEFLATED
public static final long MIN_DOS_TIME
private byte init
private String name
private byte platform
private short general
private short method
private long jTime
private int crc
private long csize
private long size
private long offset
@CheckForNull private ExtraFields fields
null or may be empty if no Extra Fields are used.@CheckForNull private String comment
public ZipEntry(String name)
private boolean isInit(int index)
private void setInit(int index,
boolean init)
public String getName()
final int getNameLength(Charset charset)
private void setName0(String name)
public boolean isDirectory()
'/').public short getPlatform()
public void setPlatform(short platform)
int getGeneral()
void setGeneral(int general)
final boolean getGeneralBit(int index)
final void setGeneralBit(int index,
boolean bit)
public int getMethod()
setMethod(int),
ZipOutputStream.getMethod()public void setMethod(int method)
IllegalArgumentException - If method is not
STORED, DEFLATED or UNKNOWN.getMethod(),
ZipOutputStream.setMethod(int)protected long getDosTime()
protected void setDosTime(long dTime)
public long getTime()
public void setTime(long jTime)
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 long getCrc()
public void setCrc(long crc)
long getCompressedSize32()
void setCompressedSize32(long csize)
public long getCompressedSize()
setCompressedSize(long)public void setCompressedSize(long csize)
csize - The Compressed Size.IllegalArgumentException - If csize is not in the
range from 0 to ULong.MAX_VALUE
(9223372036854775807L).getCompressedSize()private void setCompressedSize64(long csize)
long getSize32()
void setSize32(long size)
public long getSize()
setCompressedSize(long)public void setSize(long size)
size - The (Uncompressed) Size.IllegalArgumentException - If size is not in the
range from 0 to ULong.MAX_VALUE
(9223372036854775807L).getCompressedSize()private void setSize64(long size)
long getOffset32()
void setOffset32(long offset)
long getOffset()
void setOffset(long offset)
private void setOffset64(long offset)
public byte[] getExtra()
ZipEntry.getExtra(),
this method never returns null.null is never returned.byte[] getExtra(boolean zip64)
zip64 - Whether or not a ZIP64 Extended Information Extra Field,
if present, shall be included in the return data or not.null is never returned.getExtra()@CheckForNull private ExtraFields getFields(boolean zip64)
final int getExtraLength()
public void setExtra(@CheckForNull
byte[] data)
data - The byte array holding the serialized Extra Fields.private void setExtra0(@CheckForNull
byte[] data)
private void parseZip64ExtraField()
@CheckForNull private ExtraField compileZip64ExtraField()
@CheckForNull public String getComment()
final int getCommentLength(Charset charset)
public void setComment(@CheckForNull
String comment)
Copyright © 2005-2011 Schlichtherle IT Services. All Rights Reserved.