This patch fixes more of our warnings on build.

ChangeLog:

2008-02-28  Andrew John Hughes  <[EMAIL PROTECTED]>

        * gnu/java/util/EmptyEnumeration.java:
        Add generic type parameter.
        * java/lang/ClassLoader.java:
        Use EmptyEnumeration with type parameter.
        * java/util/zip/ZipFile.java:
        Likewise.
        * javax/swing/text/html/StyleSheet.java,
        * javax/swing/text/html/ViewAttributeSet.java:
        Add generics.
        * javax/swing/tree/DefaultMutableTreeNode.java:
        Use EmptyEnumeration with type parameter.

-- 
Andrew :)

Support Free Java!
Contribute to GNU Classpath and the OpenJDK
http://www.gnu.org/software/classpath
http://openjdk.java.net
PGP Key: 94EFD9D8 (http://subkeys.pgp.net)
Fingerprint = F8EF F1EA 401E 2E60 15FA  7927 142C 2591 94EF D9D8
Index: gnu/java/util/EmptyEnumeration.java
===================================================================
RCS file: /sources/classpath/classpath/gnu/java/util/EmptyEnumeration.java,v
retrieving revision 1.4
diff -u -3 -p -u -r1.4 EmptyEnumeration.java
--- gnu/java/util/EmptyEnumeration.java	2 Jul 2005 20:32:15 -0000	1.4
+++ gnu/java/util/EmptyEnumeration.java	28 Feb 2008 23:47:01 -0000
@@ -51,25 +51,19 @@ import java.util.NoSuchElementException;
  *
  * @author Mark Wielaard ([EMAIL PROTECTED])
  */
-public final class EmptyEnumeration implements Enumeration, Serializable
+public final class EmptyEnumeration<T> implements Enumeration<T>, Serializable
 {
   /** The only instance of this class */
-  private static final EmptyEnumeration instance = new EmptyEnumeration();
+  private static final EmptyEnumeration<Object> instance = 
+    new EmptyEnumeration<Object>();
 
   /**
-   * Private constructor that creates a new empty Enumeration.
-   */
-  private EmptyEnumeration()
-  {
-  }
-
-  /**
-   * Returns the only instance of this class.
+   * Returns an instance of this class for Object.
    * It can be shared by multiple objects and threads.
    *
    * @return the common empty enumeration
    */
-  public static EmptyEnumeration getInstance()
+  public static EmptyEnumeration<Object> getInstance()
   {
     return instance;
   }
@@ -89,7 +83,7 @@ public final class EmptyEnumeration impl
    *
    * @throws NoSuchElementException this is empty
    */
-  public Object nextElement()
+  public T nextElement()
   {
     throw new NoSuchElementException();
   }
Index: java/lang/ClassLoader.java
===================================================================
RCS file: /sources/classpath/classpath/java/lang/ClassLoader.java,v
retrieving revision 1.62
diff -u -3 -p -u -r1.62 ClassLoader.java
--- java/lang/ClassLoader.java	10 Dec 2006 20:25:44 -0000	1.62
+++ java/lang/ClassLoader.java	28 Feb 2008 23:47:03 -0000
@@ -659,7 +659,7 @@ public abstract class ClassLoader
    */
   protected Enumeration<URL> findResources(String name) throws IOException
   {
-    return (Enumeration<URL>) EmptyEnumeration.getInstance();
+    return new EmptyEnumeration<URL>();
   }
 
   /**
Index: java/util/zip/ZipFile.java
===================================================================
RCS file: /sources/classpath/classpath/java/util/zip/ZipFile.java,v
retrieving revision 1.38
diff -u -3 -p -u -r1.38 ZipFile.java
--- java/util/zip/ZipFile.java	10 Dec 2006 20:25:46 -0000	1.38
+++ java/util/zip/ZipFile.java	28 Feb 2008 23:47:05 -0000
@@ -340,7 +340,7 @@ public class ZipFile implements ZipConst
       }
     catch (IOException ioe)
       {
-	return EmptyEnumeration.getInstance();
+	return new EmptyEnumeration<ZipEntry>();
       }
   }
 
Index: javax/swing/text/html/StyleSheet.java
===================================================================
RCS file: /sources/classpath/classpath/javax/swing/text/html/StyleSheet.java,v
retrieving revision 1.26
diff -u -3 -p -u -r1.26 StyleSheet.java
--- javax/swing/text/html/StyleSheet.java	10 Dec 2006 20:25:48 -0000	1.26
+++ javax/swing/text/html/StyleSheet.java	28 Feb 2008 23:47:05 -0000
@@ -182,7 +182,7 @@ public class StyleSheet extends StyleCon
    */
   private class CSSStyle
     extends SimpleAttributeSet
-    implements Style, Comparable
+    implements Style, Comparable<CSSStyle>
   {
 
     static final int PREC_UA = 0;
@@ -229,9 +229,8 @@ public class StyleSheet extends StyleCon
      * Sorts the rule according to the style's precedence and the
      * selectors specificity.
      */
-    public int compareTo(Object o)
+    public int compareTo(CSSStyle other)
     {
-      CSSStyle other = (CSSStyle) o;
       return other.precedence + other.selector.getSpecificity()
              - precedence - selector.getSpecificity();
     }
@@ -247,18 +246,18 @@ public class StyleSheet extends StyleCon
   /**
    * The linked style sheets stored.
    */
-  private ArrayList linked;
+  private ArrayList<StyleSheet> linked;
 
   /**
    * Maps element names (selectors) to AttributSet (the corresponding style
    * information).
    */
-  ArrayList css = new ArrayList();
+  ArrayList<CSSStyle> css = new ArrayList<CSSStyle>();
 
   /**
    * Maps selectors to their resolved styles.
    */
-  private HashMap resolvedStyles;
+  private HashMap<String,Style> resolvedStyles;
 
   /**
    * Constructs a StyleSheet.
@@ -267,7 +266,7 @@ public class StyleSheet extends StyleCon
   {
     super();
     baseFontSize = 4; // Default font size from CSS
-    resolvedStyles = new HashMap();
+    resolvedStyles = new HashMap<String,Style>();
   }
 
   /**
@@ -283,7 +282,7 @@ public class StyleSheet extends StyleCon
   {
     // Create list of the element and all of its parents, starting
     // with the bottommost element.
-    ArrayList path = new ArrayList();
+    ArrayList<Element> path = new ArrayList<Element>();
     Element el;
     AttributeSet atts;
     for (el = e; el != null; el = el.getParentElement())
@@ -295,7 +294,7 @@ public class StyleSheet extends StyleCon
     // We append the actual element after this loop.
     for (int i = count - 1; i > 0; i--)
       {
-        el = (Element) path.get(i);
+        el = path.get(i);
         atts = el.getAttributes();
         Object name = atts.getAttribute(StyleConstants.NameAttribute);
         selector.append(name.toString());
@@ -322,7 +321,7 @@ public class StyleSheet extends StyleCon
         selector.append(' ');
       }
     selector.append(t.toString());
-    el = (Element) path.get(0);
+    el = path.get(0);
     atts = el.getAttributes();
     // For leaf elements, we have to fetch the tag specific attributes.
     if (el.isLeaf())
@@ -372,7 +371,7 @@ public class StyleSheet extends StyleCon
    */
   private Style getResolvedStyle(String selector, List path, HTML.Tag tag)
   {
-    Style style = (Style) resolvedStyles.get(selector);
+    Style style = resolvedStyles.get(selector);
     if (style == null)
       style = resolveStyle(selector, path, tag);
     return style;
@@ -439,11 +438,9 @@ public class StyleSheet extends StyleCon
   {
     // FIXME: This style resolver is not correct. But it works good enough for
     // the default.css.
-    int count = tags.length;
-    ArrayList styles = new ArrayList();
-    for (Iterator i = css.iterator(); i.hasNext();)
+    ArrayList<CSSStyle> styles = new ArrayList<CSSStyle>();
+    for (CSSStyle style : css)
       {
-        CSSStyle style = (CSSStyle) i.next();
         if (style.selector.matches(tags, attributes))
           styles.add(style);
       }
@@ -453,10 +450,10 @@ public class StyleSheet extends StyleCon
       {
         for (int i = linked.size() - 1; i >= 0; i--)
           {
-            StyleSheet ss = (StyleSheet) linked.get(i);
+            StyleSheet ss = linked.get(i);
             for (int j = ss.css.size() - 1; j >= 0; j--)
               {
-                CSSStyle style = (CSSStyle) ss.css.get(j);
+                CSSStyle style = ss.css.get(j);
                 if (style.selector.matches(tags, attributes))
                   styles.add(style);
               }
@@ -615,7 +612,7 @@ public class StyleSheet extends StyleCon
     if (linked != null)
       {
         linkedSS = new StyleSheet[linked.size()];
-        linkedSS = (StyleSheet[]) linked.toArray(linkedSS);
+        linkedSS = linked.toArray(linkedSS);
       }
     else
       {
@@ -1446,8 +1443,8 @@ public class StyleSheet extends StyleCon
    */
   private Map attributeSetToMap(AttributeSet atts)
   {
-    HashMap map = new HashMap();
-    Enumeration keys = atts.getAttributeNames();
+    HashMap<String,String> map = new HashMap<String,String>();
+    Enumeration<?> keys = atts.getAttributeNames();
     while (keys.hasMoreElements())
       {
         Object key = keys.nextElement();
Index: javax/swing/text/html/ViewAttributeSet.java
===================================================================
RCS file: /sources/classpath/classpath/javax/swing/text/html/ViewAttributeSet.java,v
retrieving revision 1.1
diff -u -3 -p -u -r1.1 ViewAttributeSet.java
--- javax/swing/text/html/ViewAttributeSet.java	24 Aug 2006 16:58:11 -0000	1.1
+++ javax/swing/text/html/ViewAttributeSet.java	28 Feb 2008 23:47:11 -0000
@@ -83,7 +83,7 @@ class ViewAttributeSet
   {
     styleSheet = ss;
     view = v;
-    ArrayList atts = new ArrayList();
+    ArrayList<AttributeSet> atts = new ArrayList<AttributeSet>();
 
     Element el = v.getElement();
     AttributeSet elAtts = el.getAttributes();
@@ -93,7 +93,7 @@ class ViewAttributeSet
 
     if (el.isLeaf())
       {
-        Enumeration n = elAtts.getAttributeNames();
+        Enumeration<?> n = elAtts.getAttributeNames();
         while (n.hasMoreElements())
           {
             Object key = n.nextElement();
@@ -115,7 +115,7 @@ class ViewAttributeSet
       }
 
     AttributeSet[] atts1 = new AttributeSet[atts.size()];
-    atts1 = (AttributeSet[]) atts.toArray(atts1);
+    atts1 = atts.toArray(atts1);
     init(atts1);
   }
 
Index: javax/swing/tree/DefaultMutableTreeNode.java
===================================================================
RCS file: /sources/classpath/classpath/javax/swing/tree/DefaultMutableTreeNode.java,v
retrieving revision 1.20
diff -u -3 -p -u -r1.20 DefaultMutableTreeNode.java
--- javax/swing/tree/DefaultMutableTreeNode.java	17 Feb 2008 19:40:19 -0000	1.20
+++ javax/swing/tree/DefaultMutableTreeNode.java	28 Feb 2008 23:47:11 -0000
@@ -68,7 +68,7 @@ public class DefaultMutableTreeNode
    * children.
    */
   public static final Enumeration<TreeNode> EMPTY_ENUMERATION =
-    EmptyEnumeration.getInstance();
+    new EmptyEnumeration<TreeNode>();
 
   /**
    * The parent of this node (possibly <code>null</code>).

Attachment: signature.asc
Description: Digital signature

Reply via email to