< prev index next >

src/com/sun/interview/PropertiesQuestion.java

Print this page
rev 145 : 7902237: Fixing raw use of parameterized class
Reviewed-by: jjg

@@ -154,11 +154,11 @@
      * Get the set of keys currently used this question.  Includes all hidden and
      * read-only values as well.
      * @return The set of keys (internal non-i18n value)
      * @see #setKeys
      */
-    public Enumeration getKeys() {
+    public Enumeration<?> getKeys() {
         if (value != null)
             return value.keys();
         else
             return null;
     }

@@ -214,15 +214,12 @@
     public String getStringValue() {
         StringBuffer result = new StringBuffer();
         if (value != null) {
             String sep = System.getProperty("line.separator");
 
-            Enumeration names = value.propertyNames();
-            ArrayList list = Collections.list(names);
-            Collections.sort(list);
-            for (Object o : list) {
-                String key = (String)o;
+            SortedSet<String> names = new TreeSet<>(value.stringPropertyNames());
+            for (String key : names) {
                 result.append(key);
                 result.append("=");
                 result.append(value.getProperty(key));
                 result.append(sep);
             }

@@ -318,11 +315,11 @@
         }
 
         // repopulate a J2SE properties object
         Properties p = new Properties();
 
-        Enumeration e = p2.propertyNames();
+        Enumeration<?> e = p2.propertyNames();
         while(e.hasMoreElements()) {
             Object next = e.nextElement();
             p.put( next, p2.get(next) );
         }   // while
 

@@ -409,11 +406,11 @@
      * by this base implementation.
      * @return Invalid key in index zero, <em>localized</em> explanation
      *         in index one.  Null means there are no invalid keys.
      */
     public String[][] getInvalidKeys() {
-        Enumeration names = value.propertyNames();
+        Enumeration<?> names = value.propertyNames();
         List<String> badKeys = new ArrayList<>();
         List<String> reasons = new ArrayList<>();
 
         while (names.hasMoreElements()) {
             String curr = (String)(names.nextElement());

@@ -688,11 +685,11 @@
     public String[][] getUngrouped() {
         if (value == null || value.size() == 0)
             return null;
 
         if (keyGroups != null) {
-            Set keys = keyGroups.keySet();
+            Set<String> keys = keyGroups.keySet();
             if (keys != null) {
                 String[] gps = getGroups();
                 Properties copy = (Properties)(value.clone());
 
                 // remove all grouped entries from the copied

@@ -703,16 +700,14 @@
                     for (int j = 0; j < vals.length; j++)
                         copy.remove(vals[j][0]);
                 }
 
                 if (copy.size() > 0) {
-                    Enumeration en = copy.propertyNames();
+                    Set<String> en = copy.stringPropertyNames();
                     String[][] ret = new String[copy.size()][2];
                     int i = 0;
-
-                    while (en.hasMoreElements()) {
-                        String key = (String)(en.nextElement());
+                    for (String key : en) {
                         ret[i][0] = key;
                         ret[i][1] = copy.getProperty(key);
                         i++;
                     }   // while
 

@@ -722,11 +717,11 @@
                     return null;
             }
         }
         // no groups, return the entire value set
         String[][] ret = new String[value.size()][2];
-        Enumeration en = value.propertyNames();
+        Enumeration<?> en = value.propertyNames();
         int i = 0;
 
         while (en.hasMoreElements()) {
             String key = (String)(en.nextElement());
             ret[i][0] = key;
< prev index next >