no.sesat.search.result
Class BasicResultItem

java.lang.Object
  extended by no.sesat.search.result.BasicResultItem
All Implemented Interfaces:
Serializable, ResultItem
Direct Known Subclasses:
BasicResultList, BlogSearchResultItem

public class BasicResultItem
extends Object
implements ResultItem

A simple implementation of a search result item. Is not multi-thread safe. Mutates on setter methods. Delegates all fields (of all types) to the one map. Any field "recordid" is considered as a key to equality between result items.

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

Constructor Summary
  BasicResultItem()
           
  BasicResultItem(ResultItem copy)
           
protected BasicResultItem(String title, String url)
           
 
Method Summary
 BasicResultItem addField(String field, String value)
          Adds the field to the returned instance which is otherwise equal to this.
 BasicResultItem addObjectField(String field, Serializable value)
          Adds the field to the returned instance which is otherwise equal to this.
 BasicResultItem addToMultivaluedField(String field, String value)
          Adds (to the multivalued) field to the returned instance which is otherwise equal to this.
 boolean equals(Object obj)
           
 String getField(String field)
           
 String getField(String field, int maxLength)
           
 Collection<String> getFieldNames()
          Returns a defensive copy of the field names existing in this resultItem.
 Map<String,Serializable> getFields()
          JavaBean standards access (read-only) to the fields map.
 Integer getInteger(String field)
           
 Collection<String> getMultivaluedField(String field)
          Returns a live copy of the field's collection.
 Serializable getObjectField(String field)
           
 String getTitle()
          The title this result item represents.
 String getUrl()
          The URL this result item represents.
 int hashCode()
           
 ResultItem setTitle(String title)
          Sets the title to the returned instance which is otherwise equal to this.
 ResultItem setUrl(String url)
          Sets the URL to the returned instance which is otherwise equal to this.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BasicResultItem

public BasicResultItem()

BasicResultItem

protected BasicResultItem(String title,
                          String url)
Parameters:
title -
url -

BasicResultItem

public BasicResultItem(ResultItem copy)
Parameters:
copy -
Method Detail

addField

public BasicResultItem addField(String field,
                                String 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. Use addObjectField to add a non-html string into the result.

Specified by:
addField in interface ResultItem
Parameters:
field -
value -
Returns:

getField

public String getField(String field)
Specified by:
getField in interface ResultItem
Parameters:
field -
Returns:

getFields

public Map<String,Serializable> getFields()
JavaBean standards access (read-only) to the fields map. Useful for JSPs.

Returns:
the fields map, via Collections.unmodifiableMap(..)

getObjectField

public Serializable getObjectField(String field)
Specified by:
getObjectField in interface ResultItem
Parameters:
field -
Returns:

addObjectField

public BasicResultItem 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
Parameters:
field -
value -
Returns:

getInteger

public Integer getInteger(String field)
Parameters:
field -
Returns:

getField

public String getField(String field,
                       int maxLength)
Parameters:
field -
maxLength -
Returns:

getFieldNames

public Collection<String> getFieldNames()
Returns a defensive copy of the field names existing in this resultItem.

Specified by:
getFieldNames in interface ResultItem
Returns:

getMultivaluedField

public Collection<String> getMultivaluedField(String field)
Returns a live copy of the field's collection.

Specified by:
getMultivaluedField in interface ResultItem
Parameters:
field -
Returns:

addToMultivaluedField

public BasicResultItem 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
Parameters:
field -
value -
Returns:

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

getUrl

public String getUrl()
Description copied from interface: ResultItem
The URL this result item represents.

Specified by:
getUrl in interface ResultItem
Returns:

setUrl

public ResultItem setUrl(String url)
Description copied from interface: ResultItem
Sets the URL 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:
setUrl in interface ResultItem
Returns:

getTitle

public String getTitle()
Description copied from interface: ResultItem
The title this result item represents.

Specified by:
getTitle in interface ResultItem
Returns:

setTitle

public ResultItem setTitle(String title)
Description copied from interface: ResultItem
Sets the title 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:
setTitle in interface ResultItem
Returns:


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