Author: mickw
Date: 2006-05-16 21:27:55 +0200 (Tue, 16 May 2006)
New Revision: 2926

Modified:
   
trunk/src/java/no/schibstedsok/front/searchportal/result/BasicSearchResult.java
   trunk/src/java/no/schibstedsok/front/searchportal/result/SearchResult.java
   
trunk/src/java/no/schibstedsok/front/searchportal/result/handler/SpellingSuggestionChooser.java
Log:
generics


Modified: 
trunk/src/java/no/schibstedsok/front/searchportal/result/BasicSearchResult.java
===================================================================
--- 
trunk/src/java/no/schibstedsok/front/searchportal/result/BasicSearchResult.java 
    2006-05-16 17:47:39 UTC (rev 2925)
+++ 
trunk/src/java/no/schibstedsok/front/searchportal/result/BasicSearchResult.java 
    2006-05-16 19:27:55 UTC (rev 2926)
@@ -18,13 +18,13 @@
  */
 public class BasicSearchResult implements SearchResult {
 
-    private static Log log = LogFactory.getLog(BasicSearchResult.class);
+    private static Log LOG = LogFactory.getLog(BasicSearchResult.class);
 
     private final SearchCommand searchCommand;
     protected int hitCount = -1;
     private final List<SearchResultItem> results = new 
ArrayList<SearchResultItem>();
-    private final Map<String, List> spellingSuggestions = new HashMap<String, 
List>();
-    private final List querySuggestions = new ArrayList();
+    private final Map<String,List<SpellingSuggestion>> spellingSuggestions = 
new HashMap<String,List<SpellingSuggestion>>();
+    private final List<QuerySuggestion> querySuggestions = new 
ArrayList<QuerySuggestion>();
 
     public BasicSearchResult(final SearchCommand command) {
         this.searchCommand = command;
@@ -48,24 +48,24 @@
 
     public void addSpellingSuggestion(SpellingSuggestion suggestion) {
         if (spellingSuggestions.containsKey(suggestion.getOriginal())) {
-            List exising = spellingSuggestions.get(suggestion.getOriginal());
+            final List<SpellingSuggestion> exising = 
spellingSuggestions.get(suggestion.getOriginal());
             exising.add(suggestion);
         } else {
-            List existingSuggestions = new ArrayList();
+            final List<SpellingSuggestion> existingSuggestions = new 
ArrayList<SpellingSuggestion>();
             existingSuggestions.add(suggestion);
             spellingSuggestions.put(suggestion.getOriginal(), 
existingSuggestions);
         }
 
-        if (log.isDebugEnabled()) {
-            log.debug("Spelling suggestions " + suggestion + " " + "added");
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("Spelling suggestions " + suggestion + " " + "added");
         }
     }
     
-    public Map<String, List> getSpellingSuggestions() {
+    public Map<String,List<SpellingSuggestion>> getSpellingSuggestions() {
         return spellingSuggestions;
     }
 
-    public List getQuerySuggestions() {
+    public List<QuerySuggestion> getQuerySuggestions() {
        return querySuggestions;
     }
 

Modified: 
trunk/src/java/no/schibstedsok/front/searchportal/result/SearchResult.java
===================================================================
--- trunk/src/java/no/schibstedsok/front/searchportal/result/SearchResult.java  
2006-05-16 17:47:39 UTC (rev 2925)
+++ trunk/src/java/no/schibstedsok/front/searchportal/result/SearchResult.java  
2006-05-16 19:27:55 UTC (rev 2926)
@@ -31,9 +31,9 @@
 
     void addSpellingSuggestion(SpellingSuggestion suggestion);
 
-    Map<String, List> getSpellingSuggestions();
+    Map<String,List<SpellingSuggestion>> getSpellingSuggestions();
 
-    List getQuerySuggestions();
+    List<QuerySuggestion> getQuerySuggestions();
 
     void addQuerySuggestion(QuerySuggestion query);
 }

Modified: 
trunk/src/java/no/schibstedsok/front/searchportal/result/handler/SpellingSuggestionChooser.java
===================================================================
--- 
trunk/src/java/no/schibstedsok/front/searchportal/result/handler/SpellingSuggestionChooser.java
     2006-05-16 17:47:39 UTC (rev 2925)
+++ 
trunk/src/java/no/schibstedsok/front/searchportal/result/handler/SpellingSuggestionChooser.java
     2006-05-16 19:27:55 UTC (rev 2926)
@@ -17,7 +17,7 @@
  * @author <a href="mailto:[EMAIL PROTECTED]">Magnus Eklund</a>
  * @version <tt>$Revision$</tt>
  */
-public class SpellingSuggestionChooser implements ResultHandler {
+public final class SpellingSuggestionChooser implements ResultHandler {
 
     private static transient Log log = 
LogFactory.getLog(SpellingSuggestionChooser.class);
 
@@ -113,9 +113,9 @@
         }
     }
 
-    private void removeAllIfOneIsNotMuchBetter(final List suggestionList) {
-        final SpellingSuggestion best = (SpellingSuggestion) 
suggestionList.get(0);
-        final SpellingSuggestion nextBest = (SpellingSuggestion) 
suggestionList.get(1);
+    private void removeAllIfOneIsNotMuchBetter(final List<SpellingSuggestion> 
suggestionList) {
+        final SpellingSuggestion best =  suggestionList.get(0);
+        final SpellingSuggestion nextBest =  suggestionList.get(1);
 
         if (best.getScore() < nextBest.getScore() + muchBetter) {
             suggestionList.clear();
@@ -133,15 +133,15 @@
         }
     }
 
-    private int numberOfCorrectedTerms(final Map<String, List> 
spellingSuggestions) {
+    private int numberOfCorrectedTerms(final 
Map<String,List<SpellingSuggestion>> spellingSuggestions) {
         return spellingSuggestions.keySet().size();
     }
 
-    private void removeSuggestionsWithTooHighDifference(final List 
suggestionList) {
+    private void removeSuggestionsWithTooHighDifference(final 
List<SpellingSuggestion> suggestionList) {
         int lastScore = -1;
 
-        for (final Iterator iterator = suggestionList.iterator(); 
iterator.hasNext();) {
-            final SpellingSuggestion suggestion = (SpellingSuggestion) 
iterator.next();
+        for (final Iterator<SpellingSuggestion> iterator = 
suggestionList.iterator(); iterator.hasNext();) {
+            final SpellingSuggestion suggestion =  iterator.next();
 
             if (suggestion.getScore() + maxDistance < lastScore) {
                 iterator.remove();
@@ -153,12 +153,12 @@
         }
     }
 
-    private void limitNumberOfSuggestions(final List suggestionList, final int 
limit) {
+    private void limitNumberOfSuggestions(final List<SpellingSuggestion> 
suggestionList, final int limit) {
         if (suggestionList.size() > limit) {
             final int numberToRemove = suggestionList.size() - limit;
 
             for (int i = 0; i < numberToRemove; i++) {
-                final SpellingSuggestion removed = (SpellingSuggestion) 
suggestionList.remove(suggestionList.size() - 1);
+                final SpellingSuggestion removed =  
suggestionList.remove(suggestionList.size() - 1);
                 if (log.isDebugEnabled()) {
                     log.debug("Suggestion " + removed + " to reach maximum 
number of suggestions");
                 }
@@ -166,9 +166,9 @@
         }
     }
 
-    private void removeSuggestionsWithTooLowScore(final List suggestionList) {
-        for (final Iterator suggestions = suggestionList.iterator(); 
suggestions.hasNext();) {
-            final SpellingSuggestion suggestion =  (SpellingSuggestion) 
suggestions.next();
+    private void removeSuggestionsWithTooLowScore(final 
List<SpellingSuggestion> suggestionList) {
+        for (final Iterator<SpellingSuggestion> suggestions = 
suggestionList.iterator(); suggestions.hasNext();) {
+            final SpellingSuggestion suggestion =   suggestions.next();
             if (suggestion.getScore() < minimumScore) {
                 suggestions.remove();
                 if (log.isDebugEnabled()) {

_______________________________________________
Kernel-commits mailing list
[email protected]
http://sesat.no/mailman/listinfo/kernel-commits

Reply via email to