< prev index next >

src/com/sun/javatest/Keywords.java

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

@@ -103,12 +103,12 @@
      *    or null.
      *    If not null, all the keywords in <i>text</i> must be in this set.
      * @return A Keywords object for the specified type and text.
      * @throws Keywords.Fault if there are errors in the arguments.
      */
-    public static Keywords create(String type, String text, Set validKeywords) throws Fault {
-        Set lowerCaseValidKeywords = toLowerCase(validKeywords);
+    public static Keywords create(String type, String text, Set<String> validKeywords) throws Fault {
+        Set<String> lowerCaseValidKeywords = toLowerCase(validKeywords);
         if (text == null) {
             text = "";
         }
 
         Keywords result = null;

@@ -189,26 +189,26 @@
      * @return true if the the specified set of words are compatible
      * with this keywords object.
      */
     public abstract boolean accepts(Set<String> s);
 
-    private static Set toLowerCase(Set words) {
+    private static Set<String> toLowerCase(Set<String> words) {
         if (words == null)
             return null;
 
         boolean allLowerCase = true;
-        for (Iterator iter = words.iterator(); iter.hasNext() && allLowerCase; ) {
-            String word = (String) (iter.next());
+        for (Iterator<String> iter = words.iterator(); iter.hasNext() && allLowerCase; ) {
+            String word = iter.next();
             allLowerCase &= word.equals(word.toLowerCase());
         }
 
         if (allLowerCase)
             return words;
 
         Set<String> s = new HashSet<>();
-        for (Iterator iter = words.iterator(); iter.hasNext(); ) {
-            String word = (String) (iter.next());
+        for (Iterator<String> iter = words.iterator(); iter.hasNext(); ) {
+            String word = iter.next();
             s.add(word.toLowerCase());
         }
 
         return s;
     }

@@ -232,11 +232,11 @@
 
 abstract class SetKeywords extends Keywords {
     Set<String> keys;
     String allKwds = ""; // string to be used by toString()
 
-    SetKeywords(String[] kwds, Set validKeywords) throws Keywords.Fault {
+    SetKeywords(String[] kwds, Set<String> validKeywords) throws Keywords.Fault {
         if (kwds.length == 0) {
             throw new Keywords.Fault(i18n, "kw.noKeywords");
         }
 
         keys = new HashSet<String>();

@@ -276,11 +276,11 @@
         return hash;
     }
 
 }
 class AllKeywords extends SetKeywords {
-    AllKeywords(String[] keys, Set validKeywords) throws Keywords.Fault {
+    AllKeywords(String[] keys, Set<String> validKeywords) throws Keywords.Fault {
         super(keys, validKeywords);
     }
 
 
     /**

@@ -299,11 +299,11 @@
     }
 }
 
 
 class AnyKeywords extends SetKeywords {
-    AnyKeywords(String[] keys, Set validKeywords) throws Keywords.Fault {
+    AnyKeywords(String[] keys, Set<String> validKeywords) throws Keywords.Fault {
         super(keys, validKeywords);
     }
 
     /**
      * @param s - the set

@@ -326,11 +326,11 @@
 }
 
 //------------------------------------------------------------------------------
 
 class ExprParser {
-    ExprParser(String text, Set validKeywords) {
+    ExprParser(String text, Set<String> validKeywords) {
         this.text = text;
         this.validKeywords = validKeywords;
         nextToken();
     }
 

@@ -435,11 +435,11 @@
     }
 
     protected static boolean allowNumericKeywords =
         Boolean.getBoolean("javatest.allowNumericKeywords");
     private String text;
-    private Set validKeywords;
+    private Set<String> validKeywords;
     private int index;
     private int token;
     private String idValue;
     private static final int
         ID = 0, AND = 1, OR = 2, NOT = 3, LPAREN = 4, RPAREN = 5, END = 6, ERROR = 7;
< prev index next >