< 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,114 ****
* 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);
if (text == null) {
text = "";
}
Keywords result = null;
--- 103,114 ----
* 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<String> validKeywords) throws Fault {
! Set<String> lowerCaseValidKeywords = toLowerCase(validKeywords);
if (text == null) {
text = "";
}
Keywords result = null;
*** 189,214 ****
* @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) {
if (words == null)
return null;
boolean allLowerCase = true;
! for (Iterator iter = words.iterator(); iter.hasNext() && allLowerCase; ) {
! String word = (String) (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());
s.add(word.toLowerCase());
}
return s;
}
--- 189,214 ----
* @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<String> toLowerCase(Set<String> words) {
if (words == null)
return null;
boolean allLowerCase = true;
! 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<String> iter = words.iterator(); iter.hasNext(); ) {
! String word = iter.next();
s.add(word.toLowerCase());
}
return s;
}
*** 232,242 ****
abstract class SetKeywords extends Keywords {
Set<String> keys;
String allKwds = ""; // string to be used by toString()
! SetKeywords(String[] kwds, Set validKeywords) throws Keywords.Fault {
if (kwds.length == 0) {
throw new Keywords.Fault(i18n, "kw.noKeywords");
}
keys = new HashSet<String>();
--- 232,242 ----
abstract class SetKeywords extends Keywords {
Set<String> keys;
String allKwds = ""; // string to be used by toString()
! 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,286 ****
return hash;
}
}
class AllKeywords extends SetKeywords {
! AllKeywords(String[] keys, Set validKeywords) throws Keywords.Fault {
super(keys, validKeywords);
}
/**
--- 276,286 ----
return hash;
}
}
class AllKeywords extends SetKeywords {
! AllKeywords(String[] keys, Set<String> validKeywords) throws Keywords.Fault {
super(keys, validKeywords);
}
/**
*** 299,309 ****
}
}
class AnyKeywords extends SetKeywords {
! AnyKeywords(String[] keys, Set validKeywords) throws Keywords.Fault {
super(keys, validKeywords);
}
/**
* @param s - the set
--- 299,309 ----
}
}
class AnyKeywords extends SetKeywords {
! AnyKeywords(String[] keys, Set<String> validKeywords) throws Keywords.Fault {
super(keys, validKeywords);
}
/**
* @param s - the set
*** 326,336 ****
}
//------------------------------------------------------------------------------
class ExprParser {
! ExprParser(String text, Set validKeywords) {
this.text = text;
this.validKeywords = validKeywords;
nextToken();
}
--- 326,336 ----
}
//------------------------------------------------------------------------------
class ExprParser {
! ExprParser(String text, Set<String> validKeywords) {
this.text = text;
this.validKeywords = validKeywords;
nextToken();
}
*** 435,445 ****
}
protected static boolean allowNumericKeywords =
Boolean.getBoolean("javatest.allowNumericKeywords");
private String text;
! private Set 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;
--- 435,445 ----
}
protected static boolean allowNumericKeywords =
Boolean.getBoolean("javatest.allowNumericKeywords");
private String text;
! 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 >