From ee2f99a584736be0ab4013ae9f1ae820fbc4cadc Mon Sep 17 00:00:00 2001 From: Bryce McKinlay Date: Sat, 20 May 2000 05:46:20 +0000 Subject: [PATCH] ZipEntry.java: Implement Cloneable, per JDK1.2 docs. 2000-05-20 Bryce McKinlay * java/util/zip/ZipEntry.java: Implement Cloneable, per JDK1.2 docs. (ZipEntry): Copy the Name' field. (clone): Implement JDK1.2 method. (setCompressedSize): ditto. (hashCode): ditto. From-SVN: r34043 --- libjava/ChangeLog | 8 ++++++++ libjava/java/util/zip/ZipEntry.java | 21 ++++++++++++++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/libjava/ChangeLog b/libjava/ChangeLog index d1b0493a47a..80fb004421e 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -1,3 +1,11 @@ +2000-05-20 Bryce McKinlay + + * java/util/zip/ZipEntry.java: Implement Cloneable, per JDK1.2 docs. + (ZipEntry): Copy the `name' field. + (clone): Implement JDK1.2 method. + (setCompressedSize): ditto. + (hashCode): ditto. + 2000-05-19 Tom Tromey * java/io/BufferedWriter.java: Merged with Classpath. diff --git a/libjava/java/util/zip/ZipEntry.java b/libjava/java/util/zip/ZipEntry.java index 9ff7f4d7c66..cf8d98b4445 100644 --- a/libjava/java/util/zip/ZipEntry.java +++ b/libjava/java/util/zip/ZipEntry.java @@ -19,7 +19,7 @@ package java.util.zip; * Status: Believed complete and correct. */ -public class ZipEntry implements ZipConstants +public class ZipEntry implements ZipConstants, Cloneable { // These values were determined using a simple test program. public static final int STORED = 0; @@ -51,10 +51,20 @@ public class ZipEntry implements ZipConstants crc = ent.crc; extra = ent.extra; method = ent.method; + name = ent.name; size = ent.size; time = ent.time; relativeOffset = ent.relativeOffset; } + + public Object clone () + { + // JCL defines this as being the same as the copy constructor above, + // except that value of the "extra" field is also copied. + ZipEntry clone = new ZipEntry (this); + clone.extra = (byte[]) extra.clone (); + return clone; + } public String getComment () { return comment; } @@ -89,6 +99,13 @@ public class ZipEntry implements ZipConstants throw new IllegalArgumentException (); this.comment = comment; } + + public void setCompressedSize (long compressedSize) + { + if (size < 0 || size > 0xffffffffL) + throw new IllegalArgumentException (); + this.compressedSize = compressedSize; + } public void setCrc (long crc) { @@ -155,4 +172,6 @@ public class ZipEntry implements ZipConstants } public String toString () { return name; } + + public int hashCode () { return name.hashCode (); } }