[kaffe] CVS kaffe (dalibor): Merged in java.util.jar from GNU Classpath
Kaffe CVS
cvs-commits at kaffe.org
Mon Oct 27 08:00:04 PST 2003
PatchSet 4127
Date: 2003/10/27 15:44:18
Author: dalibor
Branch: HEAD
Tag: (none)
Log:
Merged in java.util.jar from GNU Classpath
Members:
ChangeLog:1.1719->1.1720
libraries/javalib/java/util/jar/Attributes.java:1.6->1.7
libraries/javalib/java/util/jar/JarEntry.java:1.2->1.3
libraries/javalib/java/util/jar/JarFile.java:1.1->1.2
libraries/javalib/java/util/jar/JarInputStream.java:1.1->1.2
libraries/javalib/java/util/jar/JarOutputStream.java:1.4->1.5
libraries/javalib/java/util/jar/Manifest.java:1.7->1.8
Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.1719 kaffe/ChangeLog:1.1720
--- kaffe/ChangeLog:1.1719 Mon Oct 27 02:12:57 2003
+++ kaffe/ChangeLog Mon Oct 27 15:44:18 2003
@@ -1,3 +1,14 @@
+2003-10-27 Dalibor Topic <robilad at kafe.org>
+
+ * libraries/javalib/java/util/jar/Attributes.java,
+ libraries/javalib/java/util/jar/JarEntry.java,
+ libraries/javalib/java/util/jar/JarException.java,
+ libraries/javalib/java/util/jar/JarFile.java,
+ libraries/javalib/java/util/jar/JarInputStream.java,
+ libraries/javalib/java/util/jar/JarOutputStream.java,
+ libraries/javalib/java/util/jar/Manifest.java:
+ Replaced by implementation from GNU Classpath.
+
2003-10-26 Mark Wielaard <mark at klomp.org>
* libraries/javalib/java/util/zip/ZipFile.java
Index: kaffe/libraries/javalib/java/util/jar/Attributes.java
diff -u kaffe/libraries/javalib/java/util/jar/Attributes.java:1.6 kaffe/libraries/javalib/java/util/jar/Attributes.java:1.7
--- kaffe/libraries/javalib/java/util/jar/Attributes.java:1.6 Fri May 24 14:34:11 2002
+++ kaffe/libraries/javalib/java/util/jar/Attributes.java Mon Oct 27 15:44:19 2003
@@ -1,175 +1,625 @@
-/* Class : Attributes
+/* Attributes.java -- Represents attribute name/value pairs from a Manifest
+ Copyright (C) 2000, 2002 Free Software Foundation, Inc.
- Implementation of the 1.2 Java class Attributes.
+This file is part of GNU Classpath.
- Copyright : Moses DeJong, dejong at cs.umn.edu, 1998.
- Source code licensed under the GPL.
- You can get a copy of the license from www.gnu.org.
-
- This code is intended for use in the Kaffe project but you can use
- it in other projects as long as you follow the license rules.
-*/
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
package java.util.jar;
import java.util.Collection;
-import java.util.HashMap;
+import java.util.Hashtable;
import java.util.Map;
import java.util.Set;
-public class Attributes implements Map, Cloneable {
- protected Map map;
-
- public Attributes() {
- map = new HashMap();
- }
-
- public Attributes(Attributes attr) {
- map = new HashMap(attr.map);
- }
-
- public Attributes(int size) {
- map = new HashMap(size);
- }
-
- public Object clone() {
- return new Attributes(this);
- }
-
- public Set entrySet() {
- return map.entrySet();
- }
-
- public boolean equals(Object o) {
- return map.equals(o);
- }
-
- public Object get(Object name) {
- return map.get(name);
- }
-
- public String getValue(String name) {
- return getValue(new Attributes.Name(name));
- }
-
- public String getValue(Attributes.Name name) {
- return (String) get(name);
- }
-
- public int hashCode() {
- return map.hashCode();
- }
-
- public Object put(Object name, Object value) {
- return map.put((Attributes.Name)name, (String)value);
- }
-
- public String putValue(String name, String value) {
- return (String)put(new Attributes.Name(name), value);
- }
-
- public Object remove(Object name) {
- return map.remove(name);
- }
-
- public boolean containsValue(Object value) {
- return map.containsValue(value);
- }
-
- public boolean containsKey(Object name) {
- return map.containsKey(name);
- }
-
- public void putAll(Map attr) {
- map.putAll((Attributes)attr);
- }
-
- public void clear() {
- map.clear();
- }
-
- public int size() {
- return map.size();
- }
-
- public boolean isEmpty() {
- return map.isEmpty();
- }
-
- public Set keySet() {
- return map.keySet();
- }
-
- public Collection values() {
- return map.values();
- }
-
- public static class Name {
- private final String name;
-
- public static final Name
- MANIFEST_VERSION = new Name("Manifest-Version");
- public static final Name
- SIGNATURE_VERSION = new Name("Signature-Version");
- public static final Name
- CONTENT_TYPE = new Name("Content-Type");
- public static final Name
- CLASS_PATH = new Name("Class-Path");
- public static final Name
- MAIN_CLASS = new Name("Main-Class");
- public static final Name
- SEALED = new Name("Sealed");
- public static final Name
- IMPLEMENTATION_TITLE = new Name("Implementation-Title");
- public static final Name
- IMPLEMENTATION_VERSION = new Name("Implementation-Version");
- public static final Name
- IMPLEMENTATION_VENDOR = new Name("Implementation-Vendor");
- public static final Name
- IMPLEMENTATION_VENDOR_ID= new Name("Implementation-Vendor-Id");
- public static final Name
- IMPLEMENTATION_VENDOR_URL=new Name("Implementation-Vendor-URL");
- public static final Name
- SPECIFICATION_TITLE = new Name("Specification-Title");
- public static final Name
- SPECIFICATION_VERSION = new Name("Specification-Version");
- public static final Name
- SPECIFICATION_VENDOR = new Name("Specification-Vendor");
- public static final Name
- EXTENSION_LIST = new Name("Extension-List");
- public static final Name
- EXTENSION_INSTALLATION = new Name("Extension-Installation");
-
- public Name(String name) {
- if (name.length() == 0) {
- throw new IllegalArgumentException("empty attribute name");
- }
- for (int i = 0; i < name.length(); i++) {
- char c = name.charAt(i);
-
- if (!((c >= '0' && c <= '9') ||
- (c >= 'A' && c <= 'Z') ||
- (c >= 'a' && c <= 'z') ||
- c == '_' || c == '-' )) {
- throw new IllegalArgumentException("bogus attribute name: "
- + name);
- }
- }
- this.name = name;
+/**
+ * Represents attribute name/value pairs from a Manifest as a Map.
+ * The names of an attribute are represented by the
+ * <code>Attributes.Name</code> class and should confirm to the restrictions
+ * described in that class. Note that the Map interface that Attributes
+ * implements allows you to put names and values into the attribute that don't
+ * follow these restriction (and are not really Atrribute.Names, but if you do
+ * that it might cause undefined behaviour later).
+ * <p>
+ * If you use the constants defined in the inner class Name then you can be
+ * sure that you always access the right attribute names. This makes
+ * manipulating the Attributes more or less type safe.
+ * <p>
+ * Most of the methods are wrappers to implement the Map interface. The really
+ * useful and often used methods are <code>getValue(Name)</code> and
+ * <code>getValue(String)</code>. If you actually want to set attributes you
+ * may want to use the <code>putValue(String, String)</code> method
+ * (sorry there is no public type safe <code>putValue(Name, String)</code>
+ * method).
+ *
+ * @see java.util.jar.Attributes.Name
+ * @author Mark Wielaard (mark at klomp.org)
+ */
+public class Attributes implements Cloneable, Map
+{
+
+ // Fields
+
+ /**
+ * The map that holds all the attribute name/value pairs. In this
+ * implementation it is actually a Hashtable, but that can be different in
+ * other implementations.
+ */
+ protected Map map;
+
+ // Inner class
+
+ /**
+ * Represents a name of a Manifest Attribute. Defines a couple of well
+ * know names for the general main attributes, stand alone application
+ * attributes, applet attributes, extension identification attributes,
+ * package versioning and sealing attributes, file contents attributes,
+ * bean objects attribute and signing attributes. See the
+ * <p>
+ * The characters of a Name must obey the following restrictions:
+ * <ul>
+ * <li> Must contain at least one character
+ * <li> The first character must be alphanumeric (a-z, A-Z, 0-9)
+ * <li> All other characters must be alphanumeric, a '-' or a '_'
+ * </ul>
+ * <p>
+ * When comparing Names (with <code>equals</code>) all characters are
+ * converted to lowercase. But you can get the original case sensitive
+ * string with the <code>toString()</code> method.
+ *
+ * @since 1.2
+ * @author Mark Wielaard (mark at klomp.org)
+ */
+ public static class Name
+ {
+
+ // Fields
+
+ // General Main Attributes
+
+ /**
+ * General main attribute -
+ * the version of this Manifest file.
+ */
+ public static final Name MANIFEST_VERSION = new Name("Manifest-Version");
+ /**
+ * General main attribute -
+ * tool and version that created this Manifest file.
+ */
+ public static final Name CREATED_BY = new Name("Created-By");
+ /**
+ * General main attribute -
+ * the version of the jar file signature.
+ */
+ public static final Name SIGNATURE_VERSION
+ = new Name("Signature-Version");
+ /**
+ * General main attribute -
+ * (relative) URLs of the libraries/classpaths that the Classes in
+ * this jar file depend on.
+ */
+ public static final Name CLASS_PATH = new Name("Class-Path");
+
+ /**
+ * Stand alone application attribute -
+ * the entry (without the .class ending) that is the main
+ * class of this jar file.
+ */
+ public static final Name MAIN_CLASS = new Name("Main-Class");
+
+ /**
+ * Applet attribute -
+ * a list of extension libraries that the applet in this
+ * jar file depends on.
+ * For every named extension there should be some Attributes in the
+ * Manifest manifest file with the following Names:
+ * <ul>
+ * <li> <extension>-Extension-Name:
+ * unique name of the extension
+ * <li> <extension>-Specification-Version:
+ * minimum specification version
+ * <li> <extension>-Implementation-Version:
+ * minimum implementation version
+ * <li> <extension>-Implementation-Vendor-Id:
+ * unique id of implementation vendor
+ * <li> <extension>-Implementation-URL:
+ * where the latest version of the extension library can be found
+ * </ul>
+ */
+ public static final Name EXTENSION_LIST = new Name("Extension-List");
+
+ /**
+ * Extension identification attribute -
+ * the name if the extension library contained in the jar.
+ */
+ public static final Name EXTENSION_NAME = new Name("Extension-Name");
+ /**
+ * Extension identification attribute -
+ * synonym for <code>EXTENSTION_NAME</code>.
+ */
+ public static final Name EXTENSION_INSTALLATION = EXTENSION_NAME;
+
+ // Package versioning and sealing attributes
+ /**
+ * Package versioning -
+ * name of extension library contained in this jar.
+ */
+ public static final Name IMPLEMENTATION_TITLE
+ = new Name("Implementation-Title");
+ /**
+ * Package versioning -
+ * version of the extension library contained in this jar.
+ */
+ public static final Name IMPLEMENTATION_VERSION
+ = new Name("Implementation-Version");
+ /**
+ * Package versioning -
+ * name of extension library creator contained in this jar.
+ */
+ public static final Name IMPLEMENTATION_VENDOR
+ = new Name("Implementation-Vendor");
+ /**
+ * Package versioning -
+ * unique id of extension library creator.
+ */
+ public static final Name IMPLEMENTATION_VENDOR_ID
+ = new Name("Implementation-Vendor-Id");
+ /**
+ * Package versioning -
+ * location where this implementation can be downloaded.
+ */
+ public static final Name IMPLEMENTATION_URL
+ = new Name("Implementation-URL");
+ /**
+ * Package versioning -
+ * title of the specification contained in this jar.
+ */
+ public static final Name SPECIFICATION_TITLE
+ = new Name("Specification-Title");
+ /**
+ * Package versioning -
+ * version of the specification contained in this jar.
+ */
+ public static final Name SPECIFICATION_VERSION
+ = new Name("Specification-Version");
+ /**
+ * Package versioning -
+ * organisation that maintains the specification contains in this
+ * jar.
+ */
+ public static final Name SPECIFICATION_VENDOR
+ = new Name("Specification-Vendor");
+ /**
+ * Package sealing -
+ * whether (all) package(s) is(/are) sealed. Value is either "true"
+ * or "false".
+ */
+ public static final Name SEALED = new Name("Sealed");
+
+ /**
+ * File contents attribute -
+ * Mime type and subtype for the jar entry.
+ */
+ public static final Name CONTENT_TYPE = new Name("Content-Type");
+
+ /**
+ * Bean objects attribute -
+ * whether the entry is a Java Bean. Value is either "true" or "false".
+ */
+ public static final Name JAVA_BEAN = new Name("Java-Bean");
+
+ /**
+ * Signing attribute -
+ * application specific signing attribute. Must be understood by
+ * the manifest parser when present to validate the jar (entry).
+ */
+ public static final Name MAGIC = new Name("Magic");
+
+ /** The (lowercase) String representation of this Name */
+ private final String name;
+ /** The original String given to the constructor */
+ private final String origName;
+
+ // Constructor
+
+ /**
+ * Creates a new Name from the given String.
+ * Throws an IllegalArgumentException if the given String is empty or
+ * contains any illegal Name characters.
+ *
+ * @param name the name of the new Name
+ * @exception IllegalArgumentException if name isn't a valid String
+ * representation of a Name
+ * @exception NullPointerException if name is null
+ */
+ public Name(String name) throws IllegalArgumentException,
+ NullPointerException
+ {
+ // name must not be null
+ // this will throw a NullPointerException if it is
+ char chars[] = name.toCharArray();
+
+ // there must be at least one character
+ if (chars.length == 0)
+ throw new
+ IllegalArgumentException
+ ("There must be at least one character in a name");
+
+ // first character must be alphanum
+ char c = chars[0];
+ if (!((c >= 'a' && c <= 'z') ||
+ (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9')))
+ throw new
+ IllegalArgumentException("First character must be alphanum");
+
+ // all other characters must be alphanums, '-' or '_'
+ for (int i = 1; i < chars.length; i++)
+ {
+ c = chars[i];
+ if (!((c >= 'a' && c <= 'z') ||
+ (c >= 'A' && c <= 'Z') ||
+ (c >= '0' && c <= '9') || (c == '-') || (c == '_')))
+ throw new
+ IllegalArgumentException
+ ("Characters must be alphanums, '-' or '_'");
}
- public boolean equals(Object o) {
- return ((o instanceof Name) &&
- name.equalsIgnoreCase(((Name)o).name));
+ // Still here? Then convert to lower case and be done.
+ // Store the original name for toString();
+ this.origName = name;
+ this.name = name.toLowerCase();
+ }
+
+ /**
+ * Returns the hash code of the (lowercase) String representation of
+ * this Name.
+ */
+ public int hashCode()
+ {
+ return name.hashCode();
+ }
+
+ /**
+ * Checks if another object is equal to this Name object.
+ * Another object is equal to this Name object if it is an instance of
+ * Name and the (lowercase) string representation of the name is equal.
+ */
+ public boolean equals(Object o)
+ {
+ // Quick and dirty check
+ if (name == o)
+ return true;
+
+ try
+ {
+ // Note that the constructor already converts the strings to
+ // lowercase.
+ String otherName = ((Name) o).name;
+ return name.equals(otherName);
}
-
- public int hashCode() {
- return name.toUpperCase().hashCode();
+ catch (ClassCastException cce)
+ {
+ return false;
}
-
- public String toString() {
- return name;
+ catch (NullPointerException npe)
+ {
+ return false;
}
}
-}
+ /**
+ * Returns the string representation of this Name as given to the
+ * constructor (not neccesarily the lower case representation).
+ */
+ public String toString()
+ {
+ return origName;
+ }
+ }
+
+ // Constructors
+
+ /**
+ * Creates an empty Attributes map.
+ */
+ public Attributes()
+ {
+ map = new Hashtable();
+ }
+
+ /**
+ * Creates an empty Attributes map with the given initial size.
+ * @param size the initial size of the underlying map
+ */
+ public Attributes(int size)
+ {
+ map = new Hashtable(size);
+ }
+
+ /**
+ * Creates an Attributes map with the initial values taken from another
+ * Attributes map.
+ * @param attr Attributes map to take the initial values from
+ */
+ public Attributes(Attributes attr)
+ {
+ map = new Hashtable(attr.map);
+ }
+
+ // Methods
+
+ /**
+ * Gets the value of an attribute name given as a String.
+ *
+ * @param name a String describing the Name to look for
+ * @return the value gotten from the map of null when not found
+ */
+ public String getValue(String name)
+ {
+ return (String) get(new Name(name));
+ }
+
+ /**
+ * Gets the value of the given attribute name.
+ *
+ * @param name the Name to look for
+ * @return the value gotten from the map of null when not found
+ */
+ public String getValue(Name name)
+ {
+ return (String) get(name);
+ }
+
+ /**
+ * Stores an attribute name (represented by a String) and value in this
+ * Attributes map.
+ * When the (case insensitive string) name already exists the value is
+ * replaced and the old value is returned.
+ *
+ * @param name a (case insensitive) String representation of the attribite
+ * name to add/replace
+ * @param value the (new) value of the attribute name
+ * @returns the old value of the attribute name or null if it didn't exist
+ * yet
+ */
+ public String putValue(String name, String value)
+ {
+ return putValue(new Name(name), value);
+ }
+
+ /**
+ * Stores an attribute name (represented by a String) and value in this
+ * Attributes map.
+ * When the name already exists the value is replaced and the old value
+ * is returned.
+ * <p>
+ * I don't know why there is no public method with this signature. I think
+ * there should be one.
+ *
+ * @param name the attribite name to add/replace
+ * @param value the (new) value of the attribute name
+ * @returns the old value of the attribute name or null if it didn't exist
+ * yet
+ */
+ String putValue(Name name, String value)
+ {
+ return (String) put(name, value);
+ }
+
+ // Methods from Cloneable interface
+
+ /**
+ * Return a clone of this attribute map.
+ */
+ public Object clone()
+ {
+ return new Attributes(this);
+ }
+
+ // Methods from Map interface
+
+ /**
+ * Removes all attributes.
+ */
+ public void clear()
+ {
+ map.clear();
+ }
+
+ /**
+ * Checks to see if there is an attribute with the specified name.
+ * XXX - what if the object is a String?
+ *
+ * @param attrName the name of the attribute to check
+ * @return true if there is an attribute with the specified name, false
+ * otherwise
+ */
+ public boolean containsKey(Object attrName)
+ {
+ return map.containsKey(attrName);
+ }
+
+ /**
+ * Checks to see if there is an attribute name with the specified value.
+ *
+ * @param attrValue the value of a attribute to check
+ * @return true if there is an attribute name with the specified value,
+ * false otherwise
+ */
+ public boolean containsValue(Object attrValue)
+ {
+ return map.containsValue(attrValue);
+ }
+
+ /**
+ * Gives a Set of attribute name and values pairs as MapEntries.
+ * @see java.util.Map.Entry
+ * @see java.util.Map#entrySet()
+ *
+ * @return a set of attribute name value pairs
+ */
+ public Set entrySet()
+ {
+ return map.entrySet();
+ }
+
+ /**
+ * Checks to see if two Attributes are equal. The supplied object must be
+ * a real instance of Attributes and contain the same attribute name/value
+ * pairs.
+ *
+ * @param o another Attribute object which should be checked for equality
+ * @return true if the object is an instance of Attributes and contains the
+ * same name/value pairs, false otherwise
+ */
+ public boolean equals(Object o)
+ {
+ // quick and dirty check
+ if (this == o)
+ return true;
+
+ try
+ {
+ return map.equals(((Attributes) o).map);
+ }
+ catch (ClassCastException cce)
+ {
+ return false;
+ }
+ catch (NullPointerException npe)
+ {
+ return false;
+ }
+ }
+
+ /**
+ * Gets the value of a specified attribute name.
+ * XXX - what if the object is a String?
+ *
+ * @param attrName the name of the attribute we want the value of
+ * @return the value of the specified attribute name or null when there is
+ * no such attribute name
+ */
+ public Object get(Object attrName)
+ {
+ return map.get(attrName);
+ }
+
+ /**
+ * Returns the hashcode of the attribute name/value map.
+ */
+ public int hashCode()
+ {
+ return map.hashCode();
+ }
+
+ /**
+ * Returns true if there are no attributes set, false otherwise.
+ */
+ public boolean isEmpty()
+ {
+ return map.isEmpty();
+ }
+
+ /**
+ * Gives a Set of all the values of defined attribute names.
+ */
+ public Set keySet()
+ {
+ return map.keySet();
+ }
+
+ /**
+ * Adds or replaces a attribute name/value pair.
+ * XXX - What if the name is a string? What if the name is neither a Name
+ * nor a String? What if the value is not a string?
+ *
+ * @param name the name of the attribute
+ * @param value the (new) value of the attribute
+ * @return the old value of the attribute or null when there was no old
+ * attribute with this name
+ */
+ public Object put(Object name, Object value)
+ {
+ return map.put(name, value);
+ }
+
+ /**
+ * Adds or replaces all attribute name/value pairs from another
+ * Attributes object to this one. The supplied Map must be an instance of
+ * Attributes.
+ *
+ * @param attr the Attributes object to merge with this one
+ * @exception ClassCastException if the supplied map is not an instance of
+ * Attributes
+ */
+ public void putAll(Map attr)
+ {
+ if (!(attr instanceof Attributes))
+ {
+ throw new
+ ClassCastException("Supplied Map is not an instance of Attributes");
+ }
+ map.putAll(attr);
+ }
+
+ /**
+ * Remove a attribute name/value pair.
+ * XXX - What if the name is a String?
+ *
+ * @param name the name of the attribute name/value pair to remove
+ * @return the old value of the attribute or null if the attribute didn't
+ * exist
+ */
+ public Object remove(Object name)
+ {
+ return map.remove(name);
+ }
+
+ /**
+ * Returns the number of defined attribute name/value pairs.
+ */
+ public int size()
+ {
+ return map.size();
+ }
+
+ /**
+ * Returns all the values of the defined attribute name/value pairs as a
+ * Collection.
+ */
+ public Collection values()
+ {
+ return map.values();
+ }
+}
Index: kaffe/libraries/javalib/java/util/jar/JarEntry.java
diff -u kaffe/libraries/javalib/java/util/jar/JarEntry.java:1.2 kaffe/libraries/javalib/java/util/jar/JarEntry.java:1.3
--- kaffe/libraries/javalib/java/util/jar/JarEntry.java:1.2 Sun May 18 16:44:56 2003
+++ kaffe/libraries/javalib/java/util/jar/JarEntry.java Mon Oct 27 15:44:20 2003
@@ -1,52 +1,165 @@
+/* JarEntry.java - Represents an entry in a jar file
+ Copyright (C) 2000 Free Software Foundation, Inc.
-/*
- * Java core library component.
- *
- * Copyright (c) 1999
- * Archie L. Cobbs. All rights reserved.
- * Copyright (c) 1999
- * Transvirtual Technologies, Inc. All rights reserved.
- *
- * See the file "license.terms" for information on usage and redistribution
- * of this file.
- *
- * Author: Archie L. Cobbs <archie at whistle.com>
- */
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
package java.util.jar;
import java.io.IOException;
-import java.util.zip.ZipEntry;
import java.security.cert.Certificate;
+import java.util.zip.ZipEntry;
-public class JarEntry extends ZipEntry {
- private final Attributes attr;
+/**
+ * Extension to a ZipEntry that contains manifest attributes and certificates.
+ * Both the Atrributes and the Certificates can be null when not set.
+ * Note that the <code>getCertificates()</code> method only returns a
+ * valid value after all of the data of the entry has been read.
+ * <p>
+ * There are no public methods to set the attributes or certificate of an
+ * Entru. Only JarEntries created by the classes in <code>java.util.jar</code>
+ * will have these properties set.
+ *
+ * @since 1.2
+ * @author Mark Wielaard (mark at klomp.org)
+ */
- public JarEntry(String name) {
- super(name);
- attr = null;
- }
-
- public JarEntry(ZipEntry ze) {
- super(ze);
- attr = null;
- }
-
- public JarEntry(JarEntry je) {
- super(je);
- attr = je.attr; // XXX (Attributes)je.attr.clone();
- }
-
- JarEntry(ZipEntry ze, Attributes attr) {
- super(ze);
- this.attr = attr; // XXX (Attributes)attr.clone();
- }
-
- public Attributes getAttributes() throws IOException {
- return attr;
- }
-
- public Certificate[] getCertificates() {
- return null;
- }
+public class JarEntry extends ZipEntry
+{
+ // (Package local) fields
+
+ Attributes attr;
+ Certificate certs[];
+
+ // Constructors
+
+ /**
+ * Creates a new JarEntry with the specified name and no attributes or
+ * or certificates. Calls <code>super(name)</code> so all other (zip)entry
+ * fields are null or -1.
+ *
+ * @param name the name of the new jar entry
+ * @exception NullPointerException when the supplied name is null
+ * @exception IllegalArgumentException when the supplied name is longer
+ * than 65535 bytes
+ */
+ public JarEntry(String name) throws NullPointerException,
+ IllegalArgumentException
+ {
+ super(name);
+ attr = null;
+ certs = null;
+ }
+
+ /**
+ * Creates a new JarEntry with the specified ZipEntry as template for
+ * all properties of the entry. Both attributes and certificates will be
+ * null.
+ *
+ * @param entry the ZipEntry whose fields should be copied
+ */
+ public JarEntry(ZipEntry entry)
+ {
+ super(entry);
+ attr = null;
+ certs = null;
+ }
+
+ /**
+ * Creates a new JarEntry with the specified JarEntry as template for
+ * all properties of the entry.
+ *
+ * @param entry the jarEntry whose fields should be copied
+ */
+ public JarEntry(JarEntry entry)
+ {
+ super(entry);
+ try
+ {
+ attr = entry.getAttributes();
+ }
+ catch (IOException _)
+ {
+ }
+ certs = entry.getCertificates();
+ }
+
+ // Methods
+
+ /**
+ * Returns a copy of the Attributes set for this entry.
+ * When no Attributes are set in the manifest null is returned.
+ *
+ * @return a copy of the Attributes set for this entry
+ * @exception IOException This will never be thrown. It is here for
+ * binary compatibility.
+ */
*** Patch too long, truncated ***
More information about the kaffe
mailing list