This is the mail archive of the
java-patches@sourceware.cygnus.com
mailing list for the Java project.
Patch: java.util.ZipEntry fix and JDK1.2 update
- To: java-patches at sourceware dot cygnus dot com
- Subject: Patch: java.util.ZipEntry fix and JDK1.2 update
- From: Bryce McKinlay <bryce at albatross dot co dot nz>
- Date: Sat, 20 May 2000 17:42:55 +1200
I'm committing this patch.
regards
[ bryce ]
2000-05-20 Bryce McKinlay <bryce@albatross.co.nz>
* 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.
Index: libjava/java/util/zip/ZipEntry.java
===================================================================
RCS file: /cvs/java/libgcj/libjava/java/util/zip/ZipEntry.java,v
retrieving revision 1.9
diff -u -r1.9 ZipEntry.java
--- ZipEntry.java 2000/05/04 15:50:34 1.9
+++ ZipEntry.java 2000/05/20 05:35:54
@@ -19,7 +19,7 @@
* 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 @@
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 @@
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 String toString () { return name; }
+
+ public int hashCode () { return name.hashCode (); }
}