no.sesat.search.result
Class BasicResultList<T extends ResultItem>

java.lang.Object
  extended by no.sesat.search.result.BasicResultItem
      extended by no.sesat.search.result.BasicResultList<T>
Type Parameters:
T - the type of ResultItem the ResultList contains.
All Implemented Interfaces:
Serializable, ResultItem, ResultList<T>
Direct Known Subclasses:
BasicNavigationItem, FacetedSearchResultImpl, OvertureSearchResult, PlatefoodSearchResult

public class BasicResultList<T extends ResultItem>
extends BasicResultItem
implements ResultList<T>

A simple implementation of a search result. Is not multi-thread safe. All fields (of all types) handled by superclass BasicSearchResultItem.

Version:
$Id: BasicResultList.java 7225 2009-04-09 00:32:20Z ssmiweve $
See Also:
Serialized Form

Constructor Summary
  BasicResultList()
          Plain constructor.
  BasicResultList(ResultItem copy)
          Copy constructor.
  BasicResultList(ResultList<ResultItem> copy)
          Copy constructor.
protected BasicResultList(String title, String url, int hitCount)
           
 
Method Summary
 BasicResultList<T> addField(String field, String value)
          Adds the field to the returned instance which is otherwise equal to this.
 BasicResultList<T> addObjectField(String field, Serializable value)
          Adds the field to the returned instance which is otherwise equal to this.
 void addQuerySuggestion(Suggestion query)
          
 void addRelevantQuery(WeightedSuggestion query)
           
 void addResult(T item)
          Adds the result to the end of the current list of results.
 void addResults(List<? extends T> items)
          Appends the results to the end of the current list of results.
 void addSpellingSuggestion(WeightedSuggestion suggestion)
           
 BasicResultList<T> addToMultivaluedField(String field, String value)
          Adds (to the multivalued) field to the returned instance which is otherwise equal to this.
 int getHitCount()
          Get the hitcount.
 Collection<Suggestion> getQuerySuggestions()
          
 List<WeightedSuggestion> getRelevantQueries()
          Get the relevantQueries.
 List<T> getResults()
          Returns a defensive copy of the results.
 int getResultsSize()
          JavaBean compatability for JSPs.
 List<WeightedSuggestion> getSpellingSuggestions()
          
 Map<String,List<WeightedSuggestion>> getSpellingSuggestionsMap()
          
 void removeResult(T item)
          Remove the result from the current result list.
 void removeResults()
          Remove all results from the current result list.
 void replaceResult(T original, T theNew)
          Replace the original with theNew.
 void setHitCount(int docCount)
          Set the hitcount.
 void sortResults(Comparator comparator)
          Sorts the results according to the order induced by the specified comparator.
 
Methods inherited from class no.sesat.search.result.BasicResultItem
equals, getField, getField, getFieldNames, getFields, getInteger, getMultivaluedField, getObjectField, getTitle, getUrl, hashCode, setTitle, setUrl
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface no.sesat.search.result.ResultItem
getField, getFieldNames, getMultivaluedField, getObjectField, getTitle, getUrl, setTitle, setUrl
 

Constructor Detail

BasicResultList

public BasicResultList()
Plain constructor.


BasicResultList

protected BasicResultList(String title,
                          String url,
                          int hitCount)

BasicResultList

public BasicResultList(ResultItem copy)
Copy constructor. Does not copy results, spellingSuggestions, querySuggestions, or relevantQueries.

Parameters:
copy -

BasicResultList

public BasicResultList(ResultList<ResultItem> copy)
Copy constructor. Does not copy results.

Parameters:
copy -
Method Detail

setHitCount

public void setHitCount(int docCount)
Description copied from interface: ResultList
Set the hitcount.

Specified by:
setHitCount in interface ResultList<T extends ResultItem>

getHitCount

public int getHitCount()
Description copied from interface: ResultList
Get the hitcount. May not match getResults().size().

Specified by:
getHitCount in interface ResultList<T extends ResultItem>
Returns:

addResult

public void addResult(T item)
Description copied from interface: ResultList
Adds the result to the end of the current list of results.

Specified by:
addResult in interface ResultList<T extends ResultItem>

addResults

public void addResults(List<? extends T> items)
Description copied from interface: ResultList
Appends the results to the end of the current list of results.

Specified by:
addResults in interface ResultList<T extends ResultItem>

replaceResult

public void replaceResult(T original,
                          T theNew)
Description copied from interface: ResultList
Replace the original with theNew.

Specified by:
replaceResult in interface ResultList<T extends ResultItem>

removeResult

public void removeResult(T item)
Description copied from interface: ResultList
Remove the result from the current result list.

Specified by:
removeResult in interface ResultList<T extends ResultItem>

removeResults

public void removeResults()
Description copied from interface: ResultList
Remove all results from the current result list.

Specified by:
removeResults in interface ResultList<T extends ResultItem>

sortResults

public void sortResults(Comparator comparator)
Description copied from interface: ResultList
Sorts the results according to the order induced by the specified comparator.

Specified by:
sortResults in interface ResultList<T extends ResultItem>

addSpellingSuggestion

public void addSpellingSuggestion(WeightedSuggestion suggestion)
Specified by:
addSpellingSuggestion in interface ResultList<T extends ResultItem>

getSpellingSuggestions

public List<WeightedSuggestion> getSpellingSuggestions()

Specified by:
getSpellingSuggestions in interface ResultList<T extends ResultItem>
Returns:

getSpellingSuggestionsMap

public Map<String,List<WeightedSuggestion>> getSpellingSuggestionsMap()


getQuerySuggestions

public Collection<Suggestion> getQuerySuggestions()

Specified by:
getQuerySuggestions in interface ResultList<T extends ResultItem>
Returns:

addQuerySuggestion

public void addQuerySuggestion(Suggestion query)

Specified by:
addQuerySuggestion in interface ResultList<T extends ResultItem>

getResults

public List<T> getResults()
Returns a defensive copy of the results. To update a ResultItem in the list use replaceResult(original, theNew). Implementations of this method are free to return a live copy and document such, but the default defined behaviour is of an restricted API.

Specified by:
getResults in interface ResultList<T extends ResultItem>
Returns:

getResultsSize

public int getResultsSize()
JavaBean compatability for JSPs.


addField

public BasicResultList<T> addField(String field,
                                   String value)
Adds the field to the returned instance which is otherwise equal to this. There is no guarantee that this instance is altered. This allows implementations to be immutable if they choose to be. Use addObjectField to add a non-html string into the result.

Specified by:
addField in interface ResultItem
Specified by:
addField in interface ResultList<T extends ResultItem>
Overrides:
addField in class BasicResultItem
Parameters:
field -
value - html formatted string. html to display must be escaped.
Returns:

addObjectField

public BasicResultList<T> addObjectField(String field,
                                         Serializable value)
Description copied from interface: ResultItem
Adds the field to the returned instance which is otherwise equal to this. There is no guarantee that this instance is altered. This allows implementations to be immutable if they choose to be.

Specified by:
addObjectField in interface ResultItem
Specified by:
addObjectField in interface ResultList<T extends ResultItem>
Overrides:
addObjectField in class BasicResultItem
Parameters:
field -
value -
Returns:

addToMultivaluedField

public BasicResultList<T> addToMultivaluedField(String field,
                                                String value)
Description copied from interface: ResultItem
Adds (to the multivalued) field to the returned instance which is otherwise equal to this. There is no guarantee that this instance is altered. This allows implementations to be immutable if they choose to be.

Specified by:
addToMultivaluedField in interface ResultItem
Overrides:
addToMultivaluedField in class BasicResultItem
Returns:

addRelevantQuery

public void addRelevantQuery(WeightedSuggestion query)
Parameters:
query -

getRelevantQueries

public List<WeightedSuggestion> getRelevantQueries()
Get the relevantQueries.

Specified by:
getRelevantQueries in interface ResultList<T extends ResultItem>
Returns:
the relevantQueries.


Copyright © 2005-2009 Schibsted ASA. All Rights Reserved.