diff --git a/lucene/contrib/benchmark/src/java/org/apache/lucene/benchmark/quality/trec/TrecJudge.java b/lucene/contrib/benchmark/src/java/org/apache/lucene/benchmark/quality/trec/TrecJudge.java index cff2cb3bde3..3ca38776365 100644 --- a/lucene/contrib/benchmark/src/java/org/apache/lucene/benchmark/quality/trec/TrecJudge.java +++ b/lucene/contrib/benchmark/src/java/org/apache/lucene/benchmark/quality/trec/TrecJudge.java @@ -113,7 +113,7 @@ public class TrecJudge implements Judge { // inherit javadocs public boolean validateData(QualityQuery[] qq, PrintWriter logger) { - HashMap missingQueries = (HashMap) judgements.clone(); + HashMap missingQueries = new HashMap(judgements); ArrayList missingJudgements = new ArrayList(); for (int i=0; i[] disjunctLists = new List[maxPosition + 1]; int distinctPositions = 0; @@ -506,12 +507,9 @@ public class WeightedSpanTermExtractor { static private class PositionCheckingMap extends HashMap { @Override - public void putAll(Map m) { - Iterator> it = m.entrySet().iterator(); - while (it.hasNext()) { - Map.Entry entry = it.next(); + public void putAll(Map m) { + for (Map.Entry entry : m.entrySet()) this.put(entry.getKey(), entry.getValue()); - } } @Override diff --git a/lucene/contrib/instantiated/src/java/org/apache/lucene/store/instantiated/InstantiatedTerm.java b/lucene/contrib/instantiated/src/java/org/apache/lucene/store/instantiated/InstantiatedTerm.java index e50ff74ff9f..b893e04cd86 100644 --- a/lucene/contrib/instantiated/src/java/org/apache/lucene/store/instantiated/InstantiatedTerm.java +++ b/lucene/contrib/instantiated/src/java/org/apache/lucene/store/instantiated/InstantiatedTerm.java @@ -37,7 +37,7 @@ public class InstantiatedTerm } }; - public static final Comparator termComparator = new Comparator() { + public static final Comparator termComparator = new Comparator() { public int compare(Object o, Object o1) { return ((InstantiatedTerm)o).getTerm().compareTo((Term)o1); } diff --git a/lucene/contrib/memory/src/java/org/apache/lucene/index/memory/MemoryIndex.java b/lucene/contrib/memory/src/java/org/apache/lucene/index/memory/MemoryIndex.java index c1d73d00f24..37e95004652 100644 --- a/lucene/contrib/memory/src/java/org/apache/lucene/index/memory/MemoryIndex.java +++ b/lucene/contrib/memory/src/java/org/apache/lucene/index/memory/MemoryIndex.java @@ -202,7 +202,8 @@ public class MemoryIndex implements Serializable { * Sorts term entries into ascending order; also works for * Arrays.binarySearch() and Arrays.sort() */ - private static final Comparator termComparator = new Comparator() { + private static final Comparator termComparator = new Comparator() { + @SuppressWarnings("unchecked") public int compare(Object o1, Object o2) { if (o1 instanceof Map.Entry) o1 = ((Map.Entry) o1).getKey(); if (o2 instanceof Map.Entry) o2 = ((Map.Entry) o2).getKey(); @@ -513,6 +514,7 @@ public class MemoryIndex implements Serializable { /** returns a view of the given map's entries, sorted ascending by key */ private static Map.Entry[] sort(HashMap map) { int size = map.size(); + @SuppressWarnings("unchecked") Map.Entry[] entries = new Map.Entry[size]; Iterator> iter = map.entrySet().iterator(); diff --git a/modules/analysis/common/src/java/org/apache/lucene/analysis/compound/CompoundWordTokenFilterBase.java b/modules/analysis/common/src/java/org/apache/lucene/analysis/compound/CompoundWordTokenFilterBase.java index 0d82cbff197..06f3ac73c3f 100644 --- a/modules/analysis/common/src/java/org/apache/lucene/analysis/compound/CompoundWordTokenFilterBase.java +++ b/modules/analysis/common/src/java/org/apache/lucene/analysis/compound/CompoundWordTokenFilterBase.java @@ -133,7 +133,7 @@ public abstract class CompoundWordTokenFilterBase extends TokenFilter { this(matchVersion, input,makeDictionary(dictionary),DEFAULT_MIN_WORD_SIZE,DEFAULT_MIN_SUBWORD_SIZE,DEFAULT_MAX_SUBWORD_SIZE, onlyLongestMatch); } - protected CompoundWordTokenFilterBase(Version matchVersion, TokenStream input, Set dictionary, boolean onlyLongestMatch) { + protected CompoundWordTokenFilterBase(Version matchVersion, TokenStream input, Set dictionary, boolean onlyLongestMatch) { this(matchVersion, input,dictionary,DEFAULT_MIN_WORD_SIZE,DEFAULT_MIN_SUBWORD_SIZE,DEFAULT_MAX_SUBWORD_SIZE, onlyLongestMatch); } @@ -141,11 +141,11 @@ public abstract class CompoundWordTokenFilterBase extends TokenFilter { this(matchVersion, input,makeDictionary(dictionary),DEFAULT_MIN_WORD_SIZE,DEFAULT_MIN_SUBWORD_SIZE,DEFAULT_MAX_SUBWORD_SIZE, false); } - protected CompoundWordTokenFilterBase(Version matchVersion, TokenStream input, Set dictionary) { + protected CompoundWordTokenFilterBase(Version matchVersion, TokenStream input, Set dictionary) { this(matchVersion, input,dictionary,DEFAULT_MIN_WORD_SIZE,DEFAULT_MIN_SUBWORD_SIZE,DEFAULT_MAX_SUBWORD_SIZE, false); } - protected CompoundWordTokenFilterBase(Version matchVersion, TokenStream input, Set dictionary, int minWordSize, int minSubwordSize, int maxSubwordSize, boolean onlyLongestMatch) { + protected CompoundWordTokenFilterBase(Version matchVersion, TokenStream input, Set dictionary, int minWordSize, int minSubwordSize, int maxSubwordSize, boolean onlyLongestMatch) { super(input); this.tokens=new LinkedList(); @@ -221,8 +221,9 @@ public abstract class CompoundWordTokenFilterBase extends TokenFilter { } } - protected static final void addAllLowerCase(Set target, Collection col) { - for (String string : col) { + protected static final void addAllLowerCase(CharArraySet target, Collection col) { + for (Object obj : col) { + String string = (String) obj; target.add(string.toLowerCase()); } } diff --git a/modules/analysis/common/src/java/org/apache/lucene/analysis/compound/hyphenation/TernaryTree.java b/modules/analysis/common/src/java/org/apache/lucene/analysis/compound/hyphenation/TernaryTree.java index b254362ee28..ca0d56e68dc 100644 --- a/modules/analysis/common/src/java/org/apache/lucene/analysis/compound/hyphenation/TernaryTree.java +++ b/modules/analysis/common/src/java/org/apache/lucene/analysis/compound/hyphenation/TernaryTree.java @@ -453,11 +453,11 @@ public class TernaryTree implements Cloneable, Serializable { } } - public Enumeration keys() { + public Enumeration keys() { return new Iterator(); } - public class Iterator implements Enumeration { + public class Iterator implements Enumeration { /** * current node index @@ -494,7 +494,7 @@ public class TernaryTree implements Cloneable, Serializable { /** * Node stack */ - Stack ns; + Stack ns; /** * key stack implemented with a StringBuilder @@ -503,7 +503,7 @@ public class TernaryTree implements Cloneable, Serializable { public Iterator() { cur = -1; - ns = new Stack(); + ns = new Stack(); ks = new StringBuilder(); rewind(); } @@ -515,7 +515,7 @@ public class TernaryTree implements Cloneable, Serializable { run(); } - public Object nextElement() { + public String nextElement() { String res = new String(curkey); cur = up(); run(); @@ -557,11 +557,11 @@ public class TernaryTree implements Cloneable, Serializable { case 1: if (sc[i.parent] != 0) { res = eq[i.parent]; - ns.push(i.clone()); + ns.push((Item) i.clone()); ks.append(sc[i.parent]); } else { i.child++; - ns.push(i.clone()); + ns.push((Item) i.clone()); res = hi[i.parent]; } climb = false; @@ -569,7 +569,7 @@ public class TernaryTree implements Cloneable, Serializable { case 2: res = hi[i.parent]; - ns.push(i.clone()); + ns.push((Item) i.clone()); if (ks.length() > 0) { ks.setLength(ks.length() - 1); // pop } diff --git a/modules/analysis/common/src/java/org/apache/lucene/analysis/fr/FrenchStemFilter.java b/modules/analysis/common/src/java/org/apache/lucene/analysis/fr/FrenchStemFilter.java index 6e5d1ebd648..d048cc1e31a 100644 --- a/modules/analysis/common/src/java/org/apache/lucene/analysis/fr/FrenchStemFilter.java +++ b/modules/analysis/common/src/java/org/apache/lucene/analysis/fr/FrenchStemFilter.java @@ -107,7 +107,7 @@ public final class FrenchStemFilter extends TokenFilter { */ @Deprecated // TODO remove in 3.2 public void setExclusionTable( Map exclusiontable ) { - exclusions = new HashSet(exclusiontable.keySet()); + exclusions = exclusiontable.keySet(); } } diff --git a/modules/analysis/common/src/java/org/apache/lucene/analysis/query/QueryAutoStopWordAnalyzer.java b/modules/analysis/common/src/java/org/apache/lucene/analysis/query/QueryAutoStopWordAnalyzer.java index bc4e62794d2..33dc018917f 100644 --- a/modules/analysis/common/src/java/org/apache/lucene/analysis/query/QueryAutoStopWordAnalyzer.java +++ b/modules/analysis/common/src/java/org/apache/lucene/analysis/query/QueryAutoStopWordAnalyzer.java @@ -158,6 +158,7 @@ public final class QueryAutoStopWordAnalyzer extends Analyzer { /* if the stopwords for a field are changed, * then saved streams for that field are erased. */ + @SuppressWarnings("unchecked") Map streamMap = (Map) getPreviousTokenStream(); if (streamMap != null) streamMap.remove(fieldName); @@ -195,6 +196,7 @@ public final class QueryAutoStopWordAnalyzer extends Analyzer { public TokenStream reusableTokenStream(String fieldName, Reader reader) throws IOException { /* map of SavedStreams for each field */ + @SuppressWarnings("unchecked") Map streamMap = (Map) getPreviousTokenStream(); if (streamMap == null) { streamMap = new HashMap(); diff --git a/modules/analysis/common/src/java/org/tartarus/snowball/TestApp.java b/modules/analysis/common/src/java/org/tartarus/snowball/TestApp.java index 855dfad17b0..3da6f8ccf2f 100644 --- a/modules/analysis/common/src/java/org/tartarus/snowball/TestApp.java +++ b/modules/analysis/common/src/java/org/tartarus/snowball/TestApp.java @@ -54,9 +54,9 @@ public class TestApp { return; } - Class stemClass = Class.forName("org.tartarus.snowball.ext." + - args[0] + "Stemmer"); - SnowballProgram stemmer = (SnowballProgram) stemClass.newInstance(); + Class stemClass = Class.forName("org.tartarus.snowball.ext." + + args[0] + "Stemmer").asSubclass(SnowballProgram.class); + SnowballProgram stemmer = stemClass.newInstance(); Method stemMethod = stemClass.getMethod("stem", new Class[0]); Reader reader;