[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[cp-patches] [generics] Patch: FYI: java.util.jar -vs- generics
From: |
Tom Tromey |
Subject: |
[cp-patches] [generics] Patch: FYI: java.util.jar -vs- generics |
Date: |
05 Oct 2005 20:56:34 -0600 |
I'm checking this in on the generics branch.
This fixes the generics-related problems in java.util.jar as pointed
out by japi.
Tom
2005-10-05 Tom Tromey <address@hidden>
* java/util/jar/Attributes.java: Implements Map<Object,Object>.
(map): Changed type.
(entrySet): Changed return type.
(keySet): Likewise.
(putAll): Changed argument type.
(values): Changed return type.
* java/util/jar/Manifest.java (getEntries): Genericized.
(Manifest): Updated.
(entries): Changed type.
(read_individual_sections): Updated.
(read_section_name): Likewise.
(write_main_attributes): Likewise.
(write_attribute_entry): Likewise.
(write_individual_sections): Likewise.
(write_entry_attributes): Likewise.
* java/util/jar/JarFile.java (entries): Genericized.
(JarEnumeration): Implements Enumeration<JarEntry>.
(JarEnumeration.nextElement): Changed return type.
(JarEnumeration.entries): Changed type.
Index: java/util/jar/Attributes.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/util/jar/Attributes.java,v
retrieving revision 1.9.2.3
diff -u -r1.9.2.3 Attributes.java
--- java/util/jar/Attributes.java 2 Aug 2005 20:12:31 -0000 1.9.2.3
+++ java/util/jar/Attributes.java 6 Oct 2005 02:57:51 -0000
@@ -65,7 +65,7 @@
* @see java.util.jar.Attributes.Name
* @author Mark Wielaard (address@hidden)
*/
-public class Attributes implements Cloneable, Map
+public class Attributes implements Cloneable, Map<Object, Object>
{
// Fields
@@ -75,7 +75,7 @@
* implementation it is actually a Hashtable, but that can be different in
* other implementations.
*/
- protected Map map;
+ protected Map<Object, Object> map;
// Inner class
@@ -493,7 +493,7 @@
*
* @return a set of attribute name value pairs
*/
- public Set entrySet()
+ public Set<Map.Entry<Object, Object>> entrySet()
{
return map.entrySet();
}
@@ -559,7 +559,7 @@
/**
* Gives a Set of all the values of defined attribute names.
*/
- public Set keySet()
+ public Set<Object> keySet()
{
return map.keySet();
}
@@ -588,7 +588,7 @@
* @exception ClassCastException if the supplied map is not an instance of
* Attributes
*/
- public void putAll(Map attr)
+ public void putAll(Map<?, ?> attr)
{
if (!(attr instanceof Attributes))
{
@@ -623,7 +623,7 @@
* Returns all the values of the defined attribute name/value pairs as a
* Collection.
*/
- public Collection values()
+ public Collection<Object> values()
{
return map.values();
}
Index: java/util/jar/JarFile.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/util/jar/JarFile.java,v
retrieving revision 1.10.2.5
diff -u -r1.10.2.5 JarFile.java
--- java/util/jar/JarFile.java 10 Sep 2005 15:31:47 -0000 1.10.2.5
+++ java/util/jar/JarFile.java 6 Oct 2005 02:57:52 -0000
@@ -304,7 +304,7 @@
*
* @exception IllegalStateException when the JarFile is already closed
*/
- public Enumeration entries() throws IllegalStateException
+ public Enumeration<JarEntry> entries() throws IllegalStateException
{
return new JarEnumeration(super.entries(), this);
}
@@ -313,13 +313,13 @@
* Wraps a given Zip Entries Enumeration. For every zip entry a
* JarEntry is created and the corresponding Attributes are looked up.
*/
- private static class JarEnumeration implements Enumeration
+ private static class JarEnumeration implements Enumeration<JarEntry>
{
- private final Enumeration entries;
+ private final Enumeration<? extends ZipEntry> entries;
private final JarFile jarfile;
- JarEnumeration(Enumeration e, JarFile f)
+ JarEnumeration(Enumeration<? extends ZipEntry> e, JarFile f)
{
entries = e;
jarfile = f;
@@ -330,7 +330,7 @@
return entries.hasMoreElements();
}
- public Object nextElement()
+ public JarEntry nextElement()
{
ZipEntry zip = (ZipEntry) entries.nextElement();
JarEntry jar = new JarEntry(zip);
Index: java/util/jar/Manifest.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/util/jar/Manifest.java,v
retrieving revision 1.8.2.2
diff -u -r1.8.2.2 Manifest.java
--- java/util/jar/Manifest.java 20 Sep 2005 18:46:30 -0000 1.8.2.2
+++ java/util/jar/Manifest.java 6 Oct 2005 02:57:52 -0000
@@ -64,7 +64,7 @@
private final Attributes mainAttr;
/** A map of atrributes for all entries described in this Manifest. */
- private final Map entries;
+ private final Map<String, Attributes> entries;
// Constructors
@@ -74,7 +74,7 @@
public Manifest()
{
mainAttr = new Attributes();
- entries = new Hashtable();
+ entries = new Hashtable<String, Attributes>();
}
/**
@@ -108,7 +108,7 @@
public Manifest(Manifest man)
{
mainAttr = new Attributes(man.getMainAttributes());
- entries = new Hashtable(man.getEntries());
+ entries = new Hashtable<String, Attributes>(man.getEntries());
}
// Methods
@@ -126,7 +126,7 @@
* in this manifest. Adding, changing or removing from this entries map
* changes the entries of this manifest.
*/
- public Map getEntries()
+ public Map<String, Attributes> getEntries()
{
return entries;
}
@@ -279,7 +279,7 @@
}
}
- private static void read_individual_sections(Map entries,
+ private static void read_individual_sections(Map<String, Attributes> entries,
BufferedReader br) throws
IOException
{
@@ -293,7 +293,7 @@
}
private static Attributes read_section_name(String s, BufferedReader br,
- Map entries) throws JarException
+ Map<String, Attributes> entries)
throws JarException
{
try
{
@@ -378,10 +378,10 @@
private static void write_main_attributes(Attributes attr, PrintWriter pw)
throws JarException
{
- Iterator it = attr.entrySet().iterator();
+ Iterator<Map.Entry<Object, Object>> it = attr.entrySet().iterator();
while (it.hasNext())
{
- Map.Entry entry = (Map.Entry) it.next();
+ Map.Entry<Object, Object> entry = it.next();
// Don't print the manifest version again
if (!Attributes.Name.MANIFEST_VERSION.equals(entry.getKey()))
{
@@ -390,7 +390,8 @@
}
}
- private static void write_attribute_entry(Map.Entry entry, PrintWriter pw)
+ private static void write_attribute_entry(Map.Entry<Object, Object> entry,
+ PrintWriter pw)
throws JarException
{
String name = entry.getKey().toString();
@@ -409,14 +410,15 @@
write_header(name, value, pw);
}
- private static void write_individual_sections(Map entries, PrintWriter pw)
+ private static void write_individual_sections(Map<String, Attributes>
entries,
+ PrintWriter pw)
throws JarException
{
- Iterator it = entries.entrySet().iterator();
+ Iterator<Map.Entry<String, Attributes>> it = entries.entrySet().iterator();
while (it.hasNext())
{
- Map.Entry entry = (Map.Entry) it.next();
+ Map.Entry<String, Attributes> entry = it.next();
write_header("Name", entry.getKey().toString(), pw);
write_entry_attributes((Attributes) entry.getValue(), pw);
pw.println();
@@ -426,10 +428,10 @@
private static void write_entry_attributes(Attributes attr, PrintWriter pw)
throws JarException
{
- Iterator it = attr.entrySet().iterator();
+ Iterator<Map.Entry<Object, Object>> it = attr.entrySet().iterator();
while (it.hasNext())
{
- Map.Entry entry = (Map.Entry) it.next();
+ Map.Entry<Object, Object> entry = it.next();
write_attribute_entry(entry, pw);
}
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [cp-patches] [generics] Patch: FYI: java.util.jar -vs- generics,
Tom Tromey <=