Return-Path:
Short is two bytes and Long is four bytes in big endian byte and
* word order, device numbers are currently not supported. Since the documentation this class is based upon doesn't mention
+ * the character encoding of the file name at all, it is assumed that
+ * it uses the current platform's default encoding.
Furthermore this implementation is unable to tell, whether a + *
Furthermore this implementation is unable to tell whether a * given name can be safely encoded or not.
* *This implementation acts as a last resort implementation, when
@@ -53,7 +53,7 @@ class FallbackZipEncoding implements Zip
/**
* Construct a fallback zip encoding, which uses the given charset.
*
- * @param charset The name of the charset or null
for
+ * @param charset The name of the charset or {@code null} for
* the platform's default character set.
*/
public FallbackZipEncoding(String charset) {
@@ -73,7 +73,7 @@ class FallbackZipEncoding implements Zip
* org.apache.tools.zip.ZipEncoding#encode(java.lang.String)
*/
public ByteBuffer encode(String name) throws IOException {
- if (this.charset == null) {
+ if (this.charset == null) { // i.e. use default charset, see no-args constructor
return ByteBuffer.wrap(name.getBytes());
} else {
return ByteBuffer.wrap(name.getBytes(this.charset));
@@ -85,7 +85,7 @@ class FallbackZipEncoding implements Zip
* org.apache.tools.zip.ZipEncoding#decode(byte[])
*/
public String decode(byte[] data) throws IOException {
- if (this.charset == null) {
+ if (this.charset == null) { // i.e. use default charset, see no-args constructor
return new String(data);
} else {
return new String(data,this.charset);
Copied: ant/core/trunk/src/main/org/apache/tools/zip/GeneralPurposeBit.java (from r1345686, commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/GeneralPurposeBit.java)
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/zip/GeneralPurposeBit.java?p2=ant/core/trunk/src/main/org/apache/tools/zip/GeneralPurposeBit.java&p1=commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/GeneralPurposeBit.java&r1=1345686&r2=1346025&rev=1346025&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/GeneralPurposeBit.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/zip/GeneralPurposeBit.java Mon Jun 4 16:35:06 2012
@@ -15,13 +15,13 @@
* limitations under the License.
*
*/
-package org.apache.commons.compress.archivers.zip;
+package org.apache.tools.zip;
/**
* Parser/encoder for the "general purpose bit" field in ZIP's local
* file and central directory headers.
- * @since 1.1
- * @NotThreadSafe
+ *
+ * @since Ant 1.9.0
*/
public final class GeneralPurposeBit {
/**
@@ -44,8 +44,8 @@ public final class GeneralPurposeBit {
* Indicates that filenames are written in utf-8.
*
*
The only reason this is public is that {@link - * ZipArchiveOutputStream#EFS_FLAG} was public in Apache Commons - * Compress 1.0 and we needed a substitute for it.
+ * ZipOutputStream#EFS_FLAG} was public in several versions of + * Apache Ant and we needed a substitute for it. */ public static final int UFT8_NAMES_FLAG = 1 << 11; Modified: ant/core/trunk/src/main/org/apache/tools/zip/Simple8BitZipEncoding.java URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/zip/Simple8BitZipEncoding.java?rev=1346025&r1=1346024&r2=1346025&view=diff ============================================================================== --- ant/core/trunk/src/main/org/apache/tools/zip/Simple8BitZipEncoding.java (original) +++ ant/core/trunk/src/main/org/apache/tools/zip/Simple8BitZipEncoding.java Mon Jun 4 16:35:06 2012 @@ -49,7 +49,7 @@ class Simple8BitZipEncoding implements Z * A character entity, which is put to the reverse mapping table * of a simple encoding. */ - private static final class Simple8BitChar implements Comparable { + private static final class Simple8BitChar implements Comparablefalse
is returned, nothing is pushed to the
+ * If {@code false} is returned, nothing is pushed to the
* byte buffer.
*/
public boolean pushEncodedChar(ByteBuffer bb, char c) {
@@ -158,7 +172,7 @@ class Simple8BitZipEncoding implements Z
/**
* @param c A unicode character in the range from 0x0080 to 0x7f00
* @return A Simple8BitChar, if this character is covered by this encoding.
- * A null
value is returned, if this character is not
+ * A {@code null} value is returned, if this character is not
* covered by this encoding.
*/
private Simple8BitChar encodeHighChar(char c) {
@@ -171,7 +185,7 @@ class Simple8BitZipEncoding implements Z
int i = i0 + (i1 - i0) / 2;
- Simple8BitChar m = (Simple8BitChar) this.reverseMapping.get(i);
+ Simple8BitChar m = this.reverseMapping.get(i);
if (m.unicode == c) {
return m;
@@ -188,7 +202,7 @@ class Simple8BitZipEncoding implements Z
return null;
}
- Simple8BitChar r = (Simple8BitChar) this.reverseMapping.get(i0);
+ Simple8BitChar r = this.reverseMapping.get(i0);
if (r.unicode != c) {
return null;
Modified: ant/core/trunk/src/main/org/apache/tools/zip/UnicodeCommentExtraField.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/zip/UnicodeCommentExtraField.java?rev=1346025&r1=1346024&r2=1346025&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/zip/UnicodeCommentExtraField.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/zip/UnicodeCommentExtraField.java Mon Jun 4 16:35:06 2012
@@ -67,6 +67,7 @@ public class UnicodeCommentExtraField ex
super(comment, bytes);
}
+ /** {@inheritDoc} */
public ZipShort getHeaderId() {
return UCOM_ID;
}
Modified: ant/core/trunk/src/main/org/apache/tools/zip/UnicodePathExtraField.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/zip/UnicodePathExtraField.java?rev=1346025&r1=1346024&r2=1346025&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/zip/UnicodePathExtraField.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/zip/UnicodePathExtraField.java Mon Jun 4 16:35:06 2012
@@ -66,6 +66,7 @@ public class UnicodePathExtraField exten
super(name, bytes);
}
+ /** {@inheritDoc} */
public ZipShort getHeaderId() {
return UPATH_ID;
}
Modified: ant/core/trunk/src/main/org/apache/tools/zip/UnparseableExtraFieldData.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/zip/UnparseableExtraFieldData.java?rev=1346025&r1=1346024&r2=1346025&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/zip/UnparseableExtraFieldData.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/zip/UnparseableExtraFieldData.java Mon Jun 4 16:35:06 2012
@@ -21,12 +21,11 @@ package org.apache.tools.zip;
/**
* Wrapper for extra field data that doesn't conform to the recommended format of header-tag + size + data.
*
- * The header-id is artificial (and not listed as a know ID in - * the .ZIP File Format Specification). - * Since it isn't used anywhere except to satisfy the + *
The header-id is artificial (and not listed as a known ID in + * {@link + * APPNOTE.TXT}). Since it isn't used anywhere except to satisfy the * ZipExtraField contract it shouldn't matter anyway.
- * @see .ZIP File Format Specification + * * @since Ant 1.8.1 */ public final class UnparseableExtraFieldData @@ -103,7 +102,6 @@ public final class UnparseableExtraField * @param buffer the buffer to read data from * @param offset offset into buffer to read data * @param length the length of data - * @exception ZipException on error */ public void parseFromCentralDirectoryData(byte[] buffer, int offset, int length) { Copied: ant/core/trunk/src/main/org/apache/tools/zip/UnsupportedZipFeatureException.java (from r1345686, commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/UnsupportedZipFeatureException.java) URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/zip/UnsupportedZipFeatureException.java?p2=ant/core/trunk/src/main/org/apache/tools/zip/UnsupportedZipFeatureException.java&p1=commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/UnsupportedZipFeatureException.java&r1=1345686&r2=1346025&rev=1346025&view=diff ============================================================================== --- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/UnsupportedZipFeatureException.java (original) +++ ant/core/trunk/src/main/org/apache/tools/zip/UnsupportedZipFeatureException.java Mon Jun 4 16:35:06 2012 @@ -16,19 +16,19 @@ * */ -package org.apache.commons.compress.archivers.zip; +package org.apache.tools.zip; import java.util.zip.ZipException; /** * Exception thrown when attempting to read or write data for a zip * entry that uses ZIP features not supported by this library. - * @since Commons Compress 1.1 + * @since Ant 1.9.0 */ public class UnsupportedZipFeatureException extends ZipException { private final Feature reason; - private final ZipArchiveEntry entry; + private final ZipEntry entry; private static final long serialVersionUID = 4430521921766595597L; /** @@ -37,7 +37,7 @@ public class UnsupportedZipFeatureExcept * @param entry the entry using the feature */ public UnsupportedZipFeatureException(Feature reason, - ZipArchiveEntry entry) { + ZipEntry entry) { super("unsupported feature " + reason + " used in entry " + entry.getName()); this.reason = reason; @@ -54,13 +54,12 @@ public class UnsupportedZipFeatureExcept /** * The entry using the unsupported feature. */ - public ZipArchiveEntry getEntry() { + public ZipEntry getEntry() { return entry; } /** * ZIP Features that may or may not be supported. - * @since Commons Compress 1.1 */ public static class Feature { /** Copied: ant/core/trunk/src/main/org/apache/tools/zip/Zip64ExtendedInformationExtraField.java (from r1345686, commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/Zip64ExtendedInformationExtraField.java) URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/zip/Zip64ExtendedInformationExtraField.java?p2=ant/core/trunk/src/main/org/apache/tools/zip/Zip64ExtendedInformationExtraField.java&p1=commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/Zip64ExtendedInformationExtraField.java&r1=1345686&r2=1346025&rev=1346025&view=diff ============================================================================== --- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/Zip64ExtendedInformationExtraField.java (original) +++ ant/core/trunk/src/main/org/apache/tools/zip/Zip64ExtendedInformationExtraField.java Mon Jun 4 16:35:06 2012 @@ -16,12 +16,12 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.commons.compress.archivers.zip; +package org.apache.tools.zip; import java.util.zip.ZipException; -import static org.apache.commons.compress.archivers.zip.ZipConstants.DWORD; -import static org.apache.commons.compress.archivers.zip.ZipConstants.WORD; +import static org.apache.tools.zip.ZipConstants.DWORD; +import static org.apache.tools.zip.ZipConstants.WORD; /** * Holds size and other extended information for entries that use Zip64 @@ -64,16 +64,16 @@ import static org.apache.commons.compres * Local Header for the original file size will be zero. * * - *Currently Commons Compress doesn't support encrypting the - * central directory so the not about masking doesn't apply.
+ *Currently Ant doesn't support encrypting the + * central directory so the note about masking doesn't apply.
* *The implementation relies on data being read from the local file * header and assumes that both size values are always present.
* - * @since 1.2 - * @NotThreadSafe + * @since Ant 1.9.0 */ -public class Zip64ExtendedInformationExtraField implements ZipExtraField { +public class Zip64ExtendedInformationExtraField + implements CentralDirectoryParsingZipExtraField { static final ZipShort HEADER_ID = new ZipShort(0x0001); @@ -91,14 +91,12 @@ public class Zip64ExtendedInformationExt * reparseCentralDirectoryData}. * *Not used for anything else
- * - * @since 1.3 */ private byte[] rawCentralDirectoryData; /** * This constructor should only be used by the code that reads - * archives inside of Commons Compress. + * archives inside of Ant. */ public Zip64ExtendedInformationExtraField() { } Copied: ant/core/trunk/src/main/org/apache/tools/zip/Zip64Mode.java (from r1345686, commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/Zip64Mode.java) URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/zip/Zip64Mode.java?p2=ant/core/trunk/src/main/org/apache/tools/zip/Zip64Mode.java&p1=commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/Zip64Mode.java&r1=1345686&r2=1346025&rev=1346025&view=diff ============================================================================== --- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/Zip64Mode.java (original) +++ ant/core/trunk/src/main/org/apache/tools/zip/Zip64Mode.java Mon Jun 4 16:35:06 2012 @@ -16,14 +16,14 @@ * */ -package org.apache.commons.compress.archivers.zip; +package org.apache.tools.zip; /** - * The different modes {@link ZipArchiveOutputStream} can operate in. + * The different modes {@link ZipOutputStream} can operate in. * - * @see ZipArchiveOutputStream#setUseZip64 + * @see ZipOutputStream#setUseZip64 * - * @since 1.3 + * @since Ant 1.9.0 */ public enum Zip64Mode { /** @@ -35,7 +35,7 @@ public enum Zip64Mode { * Don't use Zip64 extensions for any entries. * *This will cause a {@link Zip64RequiredException} to be - * thrown if {@link ZipArchiveOutputStream} detects it needs Zip64 + * thrown if {@link ZipOutputStream} detects it needs Zip64 * support.
*/ Never, Copied: ant/core/trunk/src/main/org/apache/tools/zip/Zip64RequiredException.java (from r1345686, commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/Zip64RequiredException.java) URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/zip/Zip64RequiredException.java?p2=ant/core/trunk/src/main/org/apache/tools/zip/Zip64RequiredException.java&p1=commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/Zip64RequiredException.java&r1=1345686&r2=1346025&rev=1346025&view=diff ============================================================================== --- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/Zip64RequiredException.java (original) +++ ant/core/trunk/src/main/org/apache/tools/zip/Zip64RequiredException.java Mon Jun 4 16:35:06 2012 @@ -16,15 +16,15 @@ * */ -package org.apache.commons.compress.archivers.zip; +package org.apache.tools.zip; import java.util.zip.ZipException; /** * Exception thrown when attempting to write data that requires Zip64 - * support to an archive and {@link ZipArchiveOutputStream#setUseZip64 + * support to an archive and {@link ZipOutputStream#setUseZip64 * UseZip64} has been set to {@link Zip64Mode#Never Never}. - * @since 1.3 + * @since Ant 1.9.0 */ public class Zip64RequiredException extends ZipException { @@ -33,7 +33,7 @@ public class Zip64RequiredException exte /** * Helper to format "entry too big" messages. */ - static String getEntryTooBigMessage(ZipArchiveEntry ze) { + static String getEntryTooBigMessage(ZipEntry ze) { return ze.getName() + "'s size exceeds the limit of 4GByte."; } Copied: ant/core/trunk/src/main/org/apache/tools/zip/ZipConstants.java (from r1345686, commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipConstants.java) URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/zip/ZipConstants.java?p2=ant/core/trunk/src/main/org/apache/tools/zip/ZipConstants.java&p1=commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipConstants.java&r1=1345686&r2=1346025&rev=1346025&view=diff ============================================================================== --- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipConstants.java (original) +++ ant/core/trunk/src/main/org/apache/tools/zip/ZipConstants.java Mon Jun 4 16:35:06 2012 @@ -15,12 +15,10 @@ * limitations under the License. * */ -package org.apache.commons.compress.archivers.zip; +package org.apache.tools.zip; /** * Various constants used throughout the package. - * - * @since 1.3 */ final class ZipConstants { private ZipConstants() { } Copied: ant/core/trunk/src/main/org/apache/tools/zip/ZipEightByteInteger.java (from r1345686, commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipEightByteInteger.java) URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/zip/ZipEightByteInteger.java?p2=ant/core/trunk/src/main/org/apache/tools/zip/ZipEightByteInteger.java&p1=commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipEightByteInteger.java&r1=1345686&r2=1346025&rev=1346025&view=diff ============================================================================== --- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipEightByteInteger.java (original) +++ ant/core/trunk/src/main/org/apache/tools/zip/ZipEightByteInteger.java Mon Jun 4 16:35:06 2012 @@ -15,18 +15,15 @@ * limitations under the License. * */ -package org.apache.commons.compress.archivers.zip; +package org.apache.tools.zip; import java.math.BigInteger; -import static org.apache.commons.compress.archivers.zip.ZipConstants.BYTE_MASK; +import static org.apache.tools.zip.ZipConstants.BYTE_MASK; /** * Utility class that represents an eight byte integer with conversion * rules for the big endian byte order of ZIP files. - * @Immutable - * - * @since 1.2 */ public final class ZipEightByteInteger { Modified: ant/core/trunk/src/main/org/apache/tools/zip/ZipEncoding.java URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/zip/ZipEncoding.java?rev=1346025&r1=1346024&r2=1346025&view=diff ============================================================================== --- ant/core/trunk/src/main/org/apache/tools/zip/ZipEncoding.java (original) +++ ant/core/trunk/src/main/org/apache/tools/zip/ZipEncoding.java Mon Jun 4 16:35:06 2012 @@ -68,7 +68,7 @@ interface ZipEncoding { * character sequences are mapped to a sequence of utf-16 * words encoded in the format%Uxxxx
. It is
* assumed, that the byte buffer is positioned at the
- * beinning of the encoded result, the byte buffer has a
+ * beginning of the encoded result, the byte buffer has a
* backing array and the limit of the byte buffer points
* to the end of the encoded result.
* @throws IOException
Modified: ant/core/trunk/src/main/org/apache/tools/zip/ZipEncodingHelper.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/zip/ZipEncodingHelper.java?rev=1346025&r1=1346024&r2=1346025&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/zip/ZipEncodingHelper.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/zip/ZipEncodingHelper.java Mon Jun 4 16:35:06 2012
@@ -62,10 +62,10 @@ abstract class ZipEncodingHelper {
}
}
- private static final Map simpleEncodings;
+ private static final Mapnull
for
+ * @param name The name of the zip encoding. Specify {@code null} for
* the platform's default encoding.
* @return A zip encoding for the given encoding name.
*/
@@ -218,8 +218,7 @@ abstract class ZipEncodingHelper {
return new FallbackZipEncoding();
}
- SimpleEncodingHolder h =
- (SimpleEncodingHolder) simpleEncodings.get(name);
+ SimpleEncodingHolder h = simpleEncodings.get(name);
if (h!=null) {
return h.getEncoding();
Modified: ant/core/trunk/src/main/org/apache/tools/zip/ZipEntry.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/zip/ZipEntry.java?rev=1346025&r1=1346024&r2=1346025&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/zip/ZipEntry.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/zip/ZipEntry.java Mon Jun 4 16:35:06 2012
@@ -18,7 +18,10 @@
package org.apache.tools.zip;
+import java.io.File;
import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Date;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.zip.ZipException;
@@ -28,7 +31,8 @@ import java.util.zip.ZipException;
* access to the internal and external file attributes.
*
* The extra data is expected to follow the recommendation of - * the .ZIP File Format Specification created by PKWARE Inc. :
+ * {@link + * APPNOTE.txt}: *Any extra data that cannot be parsed by the rules above will be * consumed as "unparseable" extra data and treated differently by the - * methods of this class. Versions prior to Apache Commons Compress - * 1.1 would have thrown an exception if any attempt was made to read - * or write extra data not conforming to the recommendation.
- * @see - * .ZIP File Format Specification + * methods of this class. Older versions would have thrown an + * exception if any attempt was made to read or write extra data not + * conforming to the recommendation. * */ public class ZipEntry extends java.util.zip.ZipEntry implements Cloneable { @@ -52,30 +54,59 @@ public class ZipEntry extends java.util. private static final int SHORT_MASK = 0xFFFF; private static final int SHORT_SHIFT = 16; + /** + * The {@link java.util.zip.ZipEntry} base class only supports + * the compression methods STORED and DEFLATED. We override the + * field so that any compression methods can be used. + *
+ * The default value -1 means that the method has not been specified.
+ */
+ private int method = -1;
+
+ /**
+ * The {@link java.util.zip.ZipEntry#setSize} method in the base
+ * class throws an IllegalArgumentException if the size is bigger
+ * than 2GB for Java versions < 7. Need to keep our own size
+ * information for Zip64 support.
+ */
+ private long size = -1;
+
private int internalAttributes = 0;
private int platform = PLATFORM_FAT;
private long externalAttributes = 0;
- private LinkedHashMap/* Assumes the entry represents a directory if and only if the
+ * name ends with a forward slash "/". Assumes the entry represents a directory if and only if the
+ * name ends with a forward slash "/". Assumes the entry represents a directory if and only if the
+ * name ends with a forward slash "/". The name will be adjusted to end with a forward slash "/" if
+ * the file is a directory. If the file is not a directory a
+ * potential trailing forward slash will be stripped from the
+ * entry name. This method will return null if this instance has not been
+ * read from an archive.o
- * @since Ant 1.7
+ * The "general purpose bit" field.
+ */
+ public GeneralPurposeBit getGeneralPurposeBit() {
+ return gpb;
+ }
+
+ /**
+ * The "general purpose bit" field.
*/
- public boolean equals(Object o) {
- return (this == o);
+ public void setGeneralPurposeBit(GeneralPurposeBit b) {
+ gpb = b;
}
/**
@@ -489,23 +635,23 @@ public class ZipEntry extends java.util.
if (extraFields == null) {
setExtraFields(f);
} else {
- for (int i = 0; i < f.length; i++) {
+ for (ZipExtraField element : f) {
ZipExtraField existing;
- if (f[i] instanceof UnparseableExtraFieldData) {
+ if (element instanceof UnparseableExtraFieldData) {
existing = unparseableExtra;
} else {
- existing = getExtraField(f[i].getHeaderId());
+ existing = getExtraField(element.getHeaderId());
}
if (existing == null) {
- addExtraField(f[i]);
+ addExtraField(element);
} else {
if (local
|| !(existing
instanceof CentralDirectoryParsingZipExtraField)) {
- byte[] b = f[i].getLocalFileDataData();
+ byte[] b = element.getLocalFileDataData();
existing.parseFromLocalFileData(b, 0, b.length);
} else {
- byte[] b = f[i].getCentralDirectoryData();
+ byte[] b = element.getCentralDirectoryData();
((CentralDirectoryParsingZipExtraField) existing)
.parseFromCentralDirectoryData(b, 0, b.length);
}
@@ -514,4 +660,54 @@ public class ZipEntry extends java.util.
setExtra();
}
}
+
+ /** {@inheritDoc} */
+ public Date getLastModifiedDate() {
+ return new Date(getTime());
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null || getClass() != obj.getClass()) {
+ return false;
+ }
+ ZipEntry other = (ZipEntry) obj;
+ String myName = getName();
+ String otherName = other.getName();
+ if (myName == null) {
+ if (otherName != null) {
+ return false;
+ }
+ } else if (!myName.equals(otherName)) {
+ return false;
+ }
+ String myComment = getComment();
+ String otherComment = other.getComment();
+ if (myComment == null) {
+ myComment = "";
+ }
+ if (otherComment == null) {
+ otherComment = "";
+ }
+ return getTime() == other.getTime()
+ && myComment.equals(otherComment)
+ && getInternalAttributes() == other.getInternalAttributes()
+ && getPlatform() == other.getPlatform()
+ && getExternalAttributes() == other.getExternalAttributes()
+ && getMethod() == other.getMethod()
+ && getSize() == other.getSize()
+ && getCrc() == other.getCrc()
+ && getCompressedSize() == other.getCompressedSize()
+ && Arrays.equals(getCentralDirectoryExtra(),
+ other.getCentralDirectoryExtra())
+ && Arrays.equals(getLocalFileDataExtra(),
+ other.getLocalFileDataExtra())
+ && gpb.equals(other.gpb);
+ }
}