Methods Summary |
---|
public java.lang.Object | clone()Returns a shallow copy of this entry.
return new ZipEntry(this);
|
public java.lang.String | getComment()Gets the comment for this {@code ZipEntry}.
return comment;
|
public long | getCompressedSize()Gets the compressed size of this {@code ZipEntry}.
return compressedSize;
|
public long | getCrc()Gets the checksum for this {@code ZipEntry}.
return crc;
|
public byte[] | getExtra()Gets the extra information for this {@code ZipEntry}.
return extra;
|
int | getGPBitFlag()
return mGPBitFlag;
|
long | getLocalHeaderRelOffset()
return mLocalHeaderRelOffset;
|
public int | getMethod()Gets the compression method for this {@code ZipEntry}.
return compressionMethod;
|
public java.lang.String | getName()Gets the name of this {@code ZipEntry}.
return name;
|
public long | getSize()Gets the uncompressed size of this {@code ZipEntry}.
return size;
|
public long | getTime()Gets the last modification time of this {@code ZipEntry}.
if (time != -1) {
GregorianCalendar cal = new GregorianCalendar();
cal.set(Calendar.MILLISECOND, 0);
cal.set(1980 + ((modDate >> 9) & 0x7f), ((modDate >> 5) & 0xf) - 1,
modDate & 0x1f, (time >> 11) & 0x1f, (time >> 5) & 0x3f,
(time & 0x1f) << 1);
return cal.getTime().getTime();
}
return -1;
|
public int | hashCode()Returns the hash code for this {@code ZipEntry}.
return name.hashCode();
|
public boolean | isDirectory()Determine whether or not this {@code ZipEntry} is a directory.
return name.charAt(name.length() - 1) == '/";
|
private void | myReadFully(java.io.InputStream in, byte[] b)
int count;
int len = b.length;
int off = 0;
while (len > 0) {
count = in.read(b, off, len);
if (count <= 0)
throw new EOFException();
off += count;
len -= count;
}
|
static long | readIntLE(java.io.RandomAccessFile raf)
int b0, b1, b2, b3;
b0 = raf.read();
b1 = raf.read();
b2 = raf.read();
b3 = raf.read();
if (b3 < 0)
throw new EOFException("in ZipEntry.readIntLE(RandomAccessFile)");
return b0 | (b1 << 8) | (b2 << 16) | (b3 << 24); // ATTENTION: DOES SIGN EXTENSION: IS THIS WANTED?
|
static int | readShortLE(java.io.RandomAccessFile raf)
int b0, b1;
b0 = raf.read();
b1 = raf.read();
if (b1 < 0)
throw new EOFException("in ZipEntry.readShortLE(RandomAccessFile)");
return b0 | (b1 << 8);
|
public void | setComment(java.lang.String string)Sets the comment for this {@code ZipEntry}.
if (string == null || string.length() <= 0xFFFF) {
comment = string;
} else {
throw new IllegalArgumentException();
}
|
public void | setCompressedSize(long value)Sets the compressed size for this {@code ZipEntry}.
compressedSize = value;
|
public void | setCrc(long value)Sets the checksum for this {@code ZipEntry}.
if (value >= 0 && value <= 0xFFFFFFFFL) {
crc = value;
} else {
throw new IllegalArgumentException();
}
|
void | setDateTime(int lastModFileDate, int lastModFileTime)
time = lastModFileTime;
modDate = lastModFileDate;
|
public void | setExtra(byte[] data)Sets the extra information for this {@code ZipEntry}.
if (data == null || data.length <= 0xFFFF) {
extra = data;
} else {
throw new IllegalArgumentException();
}
|
void | setGPBitFlag(int flags)
mGPBitFlag = flags;
|
void | setLocalHeaderRelOffset(long offset)
mLocalHeaderRelOffset = offset;
|
public void | setMethod(int value)Sets the compression method for this {@code ZipEntry}.
if (value != STORED && value != DEFLATED) {
throw new IllegalArgumentException();
}
compressionMethod = value;
|
public void | setSize(long value)Sets the uncompressed size of this {@code ZipEntry}.
if (value >= 0 && value <= 0xFFFFFFFFL) {
size = value;
} else {
throw new IllegalArgumentException();
}
|
public void | setTime(long value)Sets the modification time of this {@code ZipEntry}.
GregorianCalendar cal = new GregorianCalendar();
cal.setTime(new Date(value));
int year = cal.get(Calendar.YEAR);
if (year < 1980) {
modDate = 0x21;
time = 0;
} else {
modDate = cal.get(Calendar.DATE);
modDate = (cal.get(Calendar.MONTH) + 1 << 5) | modDate;
modDate = ((cal.get(Calendar.YEAR) - 1980) << 9) | modDate;
time = cal.get(Calendar.SECOND) >> 1;
time = (cal.get(Calendar.MINUTE) << 5) | time;
time = (cal.get(Calendar.HOUR_OF_DAY) << 11) | time;
}
|
void | setVersionToExtract(int version)
mVersionToExtract = version;
|
public java.lang.String | toString()Returns the string representation of this {@code ZipEntry}.
return name;
|
int | writeCDE(java.io.OutputStream out)
writeIntLE(out, CENSIG);
writeShortLE(out, mVersionMadeBy);
writeShortLE(out, mVersionToExtract);
writeShortLE(out, mGPBitFlag);
writeShortLE(out, compressionMethod);
writeShortLE(out, time);
writeShortLE(out, modDate);
writeIntLE(out, crc);
writeIntLE(out, compressedSize);
writeIntLE(out, size);
byte[] nameBytes = null, commentBytes = null;
try {
nameBytes = name.getBytes("ISO-8859-1");
if (comment != null)
commentBytes = comment.getBytes("ISO-8859-1");
}
catch (UnsupportedEncodingException uee) {
throw new InternalError(uee.getMessage());
}
int extraLen = 0, commentLen = 0;
if (extra != null)
extraLen = extra.length;
if (commentBytes != null)
commentLen = commentBytes.length;
writeShortLE(out, nameBytes.length);
writeShortLE(out, extraLen);
writeShortLE(out, commentLen);
writeShortLE(out, mDiskNumberStart);
writeShortLE(out, mInternalAttrs);
writeIntLE(out, mExternalAttrs);
writeIntLE(out, mLocalHeaderRelOffset);
out.write(nameBytes);
if (extra != null)
out.write(extra);
if (commentBytes != null)
out.write(commentBytes);
return CENHDR + nameBytes.length + extraLen + commentLen;
|
int | writeDD(java.io.OutputStream out)
writeIntLE(out, EXTSIG);
writeIntLE(out, crc);
writeIntLE(out, compressedSize);
writeIntLE(out, size);
return EXTHDR;
|
static void | writeIntLE(java.io.OutputStream out, long val)
if (val < 0)
throw new InternalError();
out.write((int) val & 0xff);
out.write(((int) val >> 8) & 0xff);
out.write(((int) val >> 16) & 0xff);
out.write(((int) val >> 24) & 0xff);
|
int | writeLFH(java.io.OutputStream out)
if (compressionMethod < 0 ||
time < 0 ||
modDate < 0 ||
crc < 0 ||
compressedSize < 0 ||
size < 0)
throw new InternalError();
writeIntLE(out, LOCSIG);
writeShortLE(out, mVersionToExtract);
writeShortLE(out, mGPBitFlag);
writeShortLE(out, compressionMethod);
writeShortLE(out, time);
writeShortLE(out, modDate);
writeIntLE(out, crc);
writeIntLE(out, compressedSize);
writeIntLE(out, size);
byte[] nameBytes;
try {
nameBytes = name.getBytes("ISO-8859-1");
}
catch (UnsupportedEncodingException uee) {
throw new InternalError(uee.getMessage());
}
int extraLen = 0;
if (extra != null)
extraLen = extra.length;
writeShortLE(out, nameBytes.length);
writeShortLE(out, extraLen);
out.write(nameBytes);
if (extra != null)
out.write(extra);
return LOCHDR + nameBytes.length + extraLen;
|
static void | writeShortLE(java.io.OutputStream out, int val)
out.write(val & 0xff);
out.write((val >> 8) & 0xff);
|