You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by rm...@apache.org on 2010/10/03 17:41:57 UTC

svn commit: r1003978 - in /lucene/dev/trunk: lucene/contrib/benchmark/src/java/org/apache/lucene/benchmark/quality/trec/ lucene/contrib/highlighter/src/java/org/apache/lucene/search/highlight/ lucene/contrib/instantiated/src/java/org/apache/lucene/stor...

Author: rmuir
Date: Sun Oct  3 15:41:57 2010
New Revision: 1003978

URL: http://svn.apache.org/viewvc?rev=1003978&view=rev
Log:
LUCENE-2681: fix generics violations in contrib/modules

Modified:
    lucene/dev/trunk/lucene/contrib/benchmark/src/java/org/apache/lucene/benchmark/quality/trec/TrecJudge.java
    lucene/dev/trunk/lucene/contrib/highlighter/src/java/org/apache/lucene/search/highlight/WeightedSpanTermExtractor.java
    lucene/dev/trunk/lucene/contrib/instantiated/src/java/org/apache/lucene/store/instantiated/InstantiatedTerm.java
    lucene/dev/trunk/lucene/contrib/memory/src/java/org/apache/lucene/index/memory/MemoryIndex.java
    lucene/dev/trunk/modules/analysis/common/src/java/org/apache/lucene/analysis/compound/CompoundWordTokenFilterBase.java
    lucene/dev/trunk/modules/analysis/common/src/java/org/apache/lucene/analysis/compound/hyphenation/TernaryTree.java
    lucene/dev/trunk/modules/analysis/common/src/java/org/apache/lucene/analysis/fr/FrenchStemFilter.java
    lucene/dev/trunk/modules/analysis/common/src/java/org/apache/lucene/analysis/query/QueryAutoStopWordAnalyzer.java
    lucene/dev/trunk/modules/analysis/common/src/java/org/tartarus/snowball/TestApp.java

Modified: lucene/dev/trunk/lucene/contrib/benchmark/src/java/org/apache/lucene/benchmark/quality/trec/TrecJudge.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/contrib/benchmark/src/java/org/apache/lucene/benchmark/quality/trec/TrecJudge.java?rev=1003978&r1=1003977&r2=1003978&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/contrib/benchmark/src/java/org/apache/lucene/benchmark/quality/trec/TrecJudge.java (original)
+++ lucene/dev/trunk/lucene/contrib/benchmark/src/java/org/apache/lucene/benchmark/quality/trec/TrecJudge.java Sun Oct  3 15:41:57 2010
@@ -113,7 +113,7 @@ public class TrecJudge implements Judge 
 
   // inherit javadocs
   public boolean validateData(QualityQuery[] qq, PrintWriter logger) {
-    HashMap<String,QRelJudgement> missingQueries = (HashMap<String, QRelJudgement>) judgements.clone();
+    HashMap<String,QRelJudgement> missingQueries = new HashMap<String, QRelJudgement>(judgements);
     ArrayList<String> missingJudgements = new ArrayList<String>();
     for (int i=0; i<qq.length; i++) {
       String id = qq[i].getQueryID();

Modified: lucene/dev/trunk/lucene/contrib/highlighter/src/java/org/apache/lucene/search/highlight/WeightedSpanTermExtractor.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/contrib/highlighter/src/java/org/apache/lucene/search/highlight/WeightedSpanTermExtractor.java?rev=1003978&r1=1003977&r2=1003978&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/contrib/highlighter/src/java/org/apache/lucene/search/highlight/WeightedSpanTermExtractor.java (original)
+++ lucene/dev/trunk/lucene/contrib/highlighter/src/java/org/apache/lucene/search/highlight/WeightedSpanTermExtractor.java Sun Oct  3 15:41:57 2010
@@ -176,6 +176,7 @@ public class WeightedSpanTermExtractor {
           }
         }
 
+        @SuppressWarnings("unchecked")
         final List<SpanQuery>[] disjunctLists = new List[maxPosition + 1];
         int distinctPositions = 0;
 
@@ -506,12 +507,9 @@ public class WeightedSpanTermExtractor {
   static private class PositionCheckingMap<K> extends HashMap<K,WeightedSpanTerm> {
 
     @Override
-    public void putAll(Map m) {
-      Iterator<Map.Entry<K, WeightedSpanTerm>> it = m.entrySet().iterator();
-      while (it.hasNext()) {
-        Map.Entry<K, WeightedSpanTerm> entry = it.next();
+    public void putAll(Map<? extends K,? extends WeightedSpanTerm> m) {
+      for (Map.Entry<? extends K,? extends WeightedSpanTerm> entry : m.entrySet())
         this.put(entry.getKey(), entry.getValue());
-      }
     }
 
     @Override

Modified: lucene/dev/trunk/lucene/contrib/instantiated/src/java/org/apache/lucene/store/instantiated/InstantiatedTerm.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/contrib/instantiated/src/java/org/apache/lucene/store/instantiated/InstantiatedTerm.java?rev=1003978&r1=1003977&r2=1003978&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/contrib/instantiated/src/java/org/apache/lucene/store/instantiated/InstantiatedTerm.java (original)
+++ lucene/dev/trunk/lucene/contrib/instantiated/src/java/org/apache/lucene/store/instantiated/InstantiatedTerm.java Sun Oct  3 15:41:57 2010
@@ -37,7 +37,7 @@ public class InstantiatedTerm
     }
   };
 
-  public static final Comparator termComparator = new Comparator() {
+  public static final Comparator<Object> termComparator = new Comparator<Object>() {
     public int compare(Object o, Object o1) {
       return ((InstantiatedTerm)o).getTerm().compareTo((Term)o1);
     }

Modified: lucene/dev/trunk/lucene/contrib/memory/src/java/org/apache/lucene/index/memory/MemoryIndex.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/contrib/memory/src/java/org/apache/lucene/index/memory/MemoryIndex.java?rev=1003978&r1=1003977&r2=1003978&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/contrib/memory/src/java/org/apache/lucene/index/memory/MemoryIndex.java (original)
+++ lucene/dev/trunk/lucene/contrib/memory/src/java/org/apache/lucene/index/memory/MemoryIndex.java Sun Oct  3 15:41:57 2010
@@ -202,7 +202,8 @@ public class MemoryIndex implements Seri
    * 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<Object> termComparator = new Comparator<Object>() {
+    @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 Seri
   /** returns a view of the given map's entries, sorted ascending by key */
   private static <K,V> Map.Entry<K,V>[] sort(HashMap<K,V> map) {
     int size = map.size();
+    @SuppressWarnings("unchecked")
     Map.Entry<K,V>[] entries = new Map.Entry[size];
     
     Iterator<Map.Entry<K,V>> iter = map.entrySet().iterator();

Modified: lucene/dev/trunk/modules/analysis/common/src/java/org/apache/lucene/analysis/compound/CompoundWordTokenFilterBase.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/modules/analysis/common/src/java/org/apache/lucene/analysis/compound/CompoundWordTokenFilterBase.java?rev=1003978&r1=1003977&r2=1003978&view=diff
==============================================================================
--- lucene/dev/trunk/modules/analysis/common/src/java/org/apache/lucene/analysis/compound/CompoundWordTokenFilterBase.java (original)
+++ lucene/dev/trunk/modules/analysis/common/src/java/org/apache/lucene/analysis/compound/CompoundWordTokenFilterBase.java Sun Oct  3 15:41:57 2010
@@ -133,7 +133,7 @@ public abstract class CompoundWordTokenF
     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 CompoundWordTokenF
     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<Token>();
@@ -221,8 +221,9 @@ public abstract class CompoundWordTokenF
     }
   }
   
-  protected static final void addAllLowerCase(Set<Object> target, Collection<String> 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());
     }
   }

Modified: lucene/dev/trunk/modules/analysis/common/src/java/org/apache/lucene/analysis/compound/hyphenation/TernaryTree.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/modules/analysis/common/src/java/org/apache/lucene/analysis/compound/hyphenation/TernaryTree.java?rev=1003978&r1=1003977&r2=1003978&view=diff
==============================================================================
--- lucene/dev/trunk/modules/analysis/common/src/java/org/apache/lucene/analysis/compound/hyphenation/TernaryTree.java (original)
+++ lucene/dev/trunk/modules/analysis/common/src/java/org/apache/lucene/analysis/compound/hyphenation/TernaryTree.java Sun Oct  3 15:41:57 2010
@@ -453,11 +453,11 @@ public class TernaryTree implements Clon
     }
   }
 
-  public Enumeration keys() {
+  public Enumeration<String> keys() {
     return new Iterator();
   }
 
-  public class Iterator implements Enumeration {
+  public class Iterator implements Enumeration<String> {
 
     /**
      * current node index
@@ -494,7 +494,7 @@ public class TernaryTree implements Clon
     /**
      * Node stack
      */
-    Stack ns;
+    Stack<Item> ns;
 
     /**
      * key stack implemented with a StringBuilder
@@ -503,7 +503,7 @@ public class TernaryTree implements Clon
 
     public Iterator() {
       cur = -1;
-      ns = new Stack();
+      ns = new Stack<Item>();
       ks = new StringBuilder();
       rewind();
     }
@@ -515,7 +515,7 @@ public class TernaryTree implements Clon
       run();
     }
 
-    public Object nextElement() {
+    public String nextElement() {
       String res = new String(curkey);
       cur = up();
       run();
@@ -557,11 +557,11 @@ public class TernaryTree implements Clon
           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 Clon
 
           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
             }

Modified: lucene/dev/trunk/modules/analysis/common/src/java/org/apache/lucene/analysis/fr/FrenchStemFilter.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/modules/analysis/common/src/java/org/apache/lucene/analysis/fr/FrenchStemFilter.java?rev=1003978&r1=1003977&r2=1003978&view=diff
==============================================================================
--- lucene/dev/trunk/modules/analysis/common/src/java/org/apache/lucene/analysis/fr/FrenchStemFilter.java (original)
+++ lucene/dev/trunk/modules/analysis/common/src/java/org/apache/lucene/analysis/fr/FrenchStemFilter.java Sun Oct  3 15:41:57 2010
@@ -107,7 +107,7 @@ public final class FrenchStemFilter exte
 	 */
 	@Deprecated // TODO remove in 3.2
 	public void setExclusionTable( Map<?,?> exclusiontable ) {
-		exclusions = new HashSet(exclusiontable.keySet());
+		exclusions = exclusiontable.keySet();
 	}
 }
 

Modified: lucene/dev/trunk/modules/analysis/common/src/java/org/apache/lucene/analysis/query/QueryAutoStopWordAnalyzer.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/modules/analysis/common/src/java/org/apache/lucene/analysis/query/QueryAutoStopWordAnalyzer.java?rev=1003978&r1=1003977&r2=1003978&view=diff
==============================================================================
--- lucene/dev/trunk/modules/analysis/common/src/java/org/apache/lucene/analysis/query/QueryAutoStopWordAnalyzer.java (original)
+++ lucene/dev/trunk/modules/analysis/common/src/java/org/apache/lucene/analysis/query/QueryAutoStopWordAnalyzer.java Sun Oct  3 15:41:57 2010
@@ -158,6 +158,7 @@ public final class QueryAutoStopWordAnal
     /* if the stopwords for a field are changed,
      * then saved streams for that field are erased.
      */
+    @SuppressWarnings("unchecked")
     Map<String,SavedStreams> streamMap = (Map<String,SavedStreams>) getPreviousTokenStream();
     if (streamMap != null)
       streamMap.remove(fieldName);
@@ -195,6 +196,7 @@ public final class QueryAutoStopWordAnal
   public TokenStream reusableTokenStream(String fieldName, Reader reader)
       throws IOException {
     /* map of SavedStreams for each field */
+    @SuppressWarnings("unchecked")
     Map<String,SavedStreams> streamMap = (Map<String,SavedStreams>) getPreviousTokenStream();
     if (streamMap == null) {
       streamMap = new HashMap<String, SavedStreams>();

Modified: lucene/dev/trunk/modules/analysis/common/src/java/org/tartarus/snowball/TestApp.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/modules/analysis/common/src/java/org/tartarus/snowball/TestApp.java?rev=1003978&r1=1003977&r2=1003978&view=diff
==============================================================================
--- lucene/dev/trunk/modules/analysis/common/src/java/org/tartarus/snowball/TestApp.java (original)
+++ lucene/dev/trunk/modules/analysis/common/src/java/org/tartarus/snowball/TestApp.java Sun Oct  3 15:41:57 2010
@@ -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<? extends SnowballProgram> 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;