This patch fixes a few warnings due to the use of generics
in javax.management.openmbean.

ChangeLog:

2008-06-15  Andrew John Hughes  <[EMAIL PROTECTED]>

        * javax/management/openmbean/TabularDataSupport.java,
        * javax/management/openmbean/TabularType.java:
        Fix warnings due to use of generics.

-- 
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: javax/management/openmbean/TabularDataSupport.java
===================================================================
RCS file: 
/sources/classpath/classpath/javax/management/openmbean/TabularDataSupport.java,v
retrieving revision 1.2
diff -u -u -r1.2 TabularDataSupport.java
--- javax/management/openmbean/TabularDataSupport.java  5 Mar 2007 23:19:44 
-0000       1.2
+++ javax/management/openmbean/TabularDataSupport.java  16 Jun 2008 00:40:17 
-0000
@@ -68,7 +68,7 @@
    *
    * @serial the map of rows to column values.
    */
-  private Map<Object,Object> dataMap;
+  private HashMap<Object,Object> dataMap;
 
   /**
    * The tabular type which represents this tabular data instance.
@@ -141,14 +141,10 @@
       throw new InvalidOpenTypeException("The type of the given value " +
                                         "does not match the row type " +
                                         "of this instance.");
-    List indexNames = tabularType.getIndexNames();
-    List matchingIndicies = new ArrayList(indexNames.size());
-    Iterator it = indexNames.iterator();
-    while (it.hasNext())
-      {
-       String name = (String) it.next();
-       matchingIndicies.add(val.get(name));
-      }
+    List<String> indexNames = tabularType.getIndexNames();
+    List<String> matchingIndicies = new ArrayList<String>(indexNames.size());
+    for (String name : indexNames)
+      matchingIndicies.add(val.get(name).toString());
     return matchingIndicies.toArray();
   }
 
@@ -173,7 +169,7 @@
     try
       {
        clone = (TabularDataSupport) super.clone();
-       clone.setMap((HashMap) ((HashMap) dataMap).clone());
+       clone.setMap((HashMap<Object,Object>) dataMap.clone());
       }
     catch (CloneNotSupportedException e)
       {
@@ -390,11 +386,11 @@
    */
   private boolean isKeyValid(Object[] key)
   {
-    Iterator it = tabularType.getIndexNames().iterator();
+    Iterator<String> it = tabularType.getIndexNames().iterator();
     CompositeType rowType = tabularType.getRowType();
     for (int a = 0; it.hasNext(); ++a)
       {
-       OpenType type = rowType.getType((String) it.next());
+       OpenType<?> type = rowType.getType(it.next());
        if (!(type.isValue(key[a])))
          return false;
       }
@@ -496,7 +492,7 @@
   {
     if (vals == null || vals.length == 0)
       return;
-    Map mapToAdd = new HashMap(vals.length);
+    Map<Object,Object> mapToAdd = new HashMap<Object,Object>(vals.length);
     for (int a = 0; a < vals.length; ++a)
       {
        Object[] key = calculateIndex(vals[a]);
@@ -539,9 +535,9 @@
   {
     if (m == null || m.size() == 0)
       return;
-    Collection vals = m.values();
+    Collection<?> vals = m.values();
     CompositeData[] data = new CompositeData[vals.size()];
-    Iterator it = vals.iterator();
+    Iterator<?> it = vals.iterator();
     for (int a = 0; it.hasNext(); ++a)
       {
        data[a] = (CompositeData) it.next();
@@ -591,12 +587,12 @@
   }
 
   /**
-   * Package-private method to set the internal [EMAIL PROTECTED] 
java.util.Map}
+   * Private method to set the internal [EMAIL PROTECTED] java.util.Map}
    * instance (used in cloning).
    *
    * @param map the new map used.
    */
-  void setMap(Map map)
+  private void setMap(HashMap<Object,Object> map)
   {
     dataMap = map;
   }
Index: javax/management/openmbean/TabularType.java
===================================================================
RCS file: 
/sources/classpath/classpath/javax/management/openmbean/TabularType.java,v
retrieving revision 1.3
diff -u -u -r1.3 TabularType.java
--- javax/management/openmbean/TabularType.java 5 Mar 2007 23:19:44 -0000       
1.3
+++ javax/management/openmbean/TabularType.java 16 Jun 2008 00:40:17 -0000
@@ -206,9 +206,8 @@
     if (hashCode == null)
       {
        int elementTotal = 0;
-       Iterator it = indexNames.iterator();
-       while (it.hasNext())
-         elementTotal += it.next().hashCode();
+       for (String s : indexNames)
+         elementTotal += s.hashCode();
        hashCode = Integer.valueOf(elementTotal 
                                   + getTypeName().hashCode()
                                   + rowType.hashCode());

Reply via email to