Methods Summary |
---|
public void | addExtraField(ZipExtraField ze)Adds an extra fields - replacing an already present extra field
of the same type.
if (extraFields == null) {
extraFields = new Vector();
}
ZipShort type = ze.getHeaderId();
boolean done = false;
for (int i = 0, fieldsSize = extraFields.size(); !done && i < fieldsSize; i++) {
if (((ZipExtraField) extraFields.elementAt(i)).getHeaderId().equals(type)) {
extraFields.setElementAt(ze, i);
done = true;
}
}
if (!done) {
extraFields.addElement(ze);
}
setExtra();
|
public java.lang.Object | clone()Overwrite clone.
ZipEntry e = (ZipEntry) super.clone();
e.extraFields = extraFields != null ? (Vector) extraFields.clone() : null;
e.setInternalAttributes(getInternalAttributes());
e.setExternalAttributes(getExternalAttributes());
e.setExtraFields(getExtraFields());
return e;
|
public boolean | equals(java.lang.Object o)The equality method. In this case, the implementation returns 'this == o'
which is basically the equals method of the Object class.
return (this == o);
|
public byte[] | getCentralDirectoryExtra()Retrieves the extra data for the central directory.
return ExtraFieldUtils.mergeCentralDirectoryData(getExtraFields());
|
public long | getExternalAttributes()Retrieves the external file attributes.
return externalAttributes;
|
public ZipExtraField[] | getExtraFields()Retrieves extra fields.
if (extraFields == null) {
return new ZipExtraField[0];
}
ZipExtraField[] result = new ZipExtraField[extraFields.size()];
extraFields.copyInto(result);
return result;
|
public int | getInternalAttributes()Retrieves the internal file attributes.
return internalAttributes;
|
public byte[] | getLocalFileDataExtra()Retrieves the extra data for the local file data.
byte[] extra = getExtra();
return extra != null ? extra : new byte[0];
|
public java.lang.String | getName()Get the name of the entry.
return name == null ? super.getName() : name;
|
public int | getPlatform()Platform specification to put into the "version made
by" part of the central file header.
return platform;
|
public int | getUnixMode()Unix permission.
return (int) ((getExternalAttributes() >> 16) & 0xFFFF);
|
public int | hashCode()Get the hashCode of the entry.
This uses the name as the hashcode.
// this method has severe consequences on performance. We cannot rely
// on the super.hashCode() method since super.getName() always return
// the empty string in the current implemention (there's no setter)
// so it is basically draining the performance of a hashmap lookup
return getName().hashCode();
|
public boolean | isDirectory()Is this entry a directory?
return getName().endsWith("/");
|
public void | removeExtraField(ZipShort type)Remove an extra fields.
if (extraFields == null) {
extraFields = new Vector();
}
boolean done = false;
for (int i = 0, fieldsSize = extraFields.size(); !done && i < fieldsSize; i++) {
if (((ZipExtraField) extraFields.elementAt(i)).getHeaderId().equals(type)) {
extraFields.removeElementAt(i);
done = true;
}
}
if (!done) {
throw new java.util.NoSuchElementException();
}
setExtra();
|
public void | setComprSize(long size)Make this class work in JDK 1.1 like a 1.2 class.
This either stores the size for later usage or invokes
setCompressedSize via reflection.
setCompressedSize(size);
|
public void | setExternalAttributes(long value)Sets the external file attributes.
externalAttributes = value;
|
public void | setExtra(byte[] extra)Throws an Exception if extra data cannot be parsed into extra fields.
try {
setExtraFields(ExtraFieldUtils.parse(extra));
} catch (Exception e) {
throw new RuntimeException(e.getMessage());
}
|
protected void | setExtra()Unfortunately {@link java.util.zip.ZipOutputStream
java.util.zip.ZipOutputStream} seems to access the extra data
directly, so overriding getExtra doesn't help - we need to
modify super's data directly.
super.setExtra(ExtraFieldUtils.mergeLocalFileDataData(getExtraFields()));
|
public void | setExtraFields(ZipExtraField[] fields)Replaces all currently attached extra fields with the new array.
extraFields = new Vector();
for (int i = 0; i < fields.length; i++) {
extraFields.addElement(fields[i]);
}
setExtra();
|
public void | setInternalAttributes(int value)Sets the internal file attributes.
internalAttributes = value;
|
protected void | setName(java.lang.String name)Set the name of the entry.
this.name = name;
|
protected void | setPlatform(int platform)Set the platform (UNIX or FAT).
this.platform = platform;
|
public void | setUnixMode(int mode)Sets Unix permissions in a way that is understood by Info-Zip's
unzip command.
setExternalAttributes((mode << 16)
// MS-DOS read-only attribute
| ((mode & 0200) == 0 ? 1 : 0)
// MS-DOS directory flag
| (isDirectory() ? 0x10 : 0));
platform = PLATFORM_UNIX;
|