org.compass.core
Interface Resource

All Superinterfaces:
Serializable
All Known Implementing Classes:
CollectionResourceWrapper, LuceneResource

public interface Resource
extends Serializable

A Resource holds a list of meta data properties. The Resource is the basic data that is saved in Compass. Compass provides object to Resource mapping as well in the CompassSession object.

Author:
kimchy

Method Summary
 Resource addProperty(Property property)
          Add a property to the resource.
 Resource addProperty(String name, Object value)
          Adds a property to the resource based on resource mapping definitions.
 Resource addProperty(String name, Reader value)
          Adds a property to the resource based on resource mapping definitions.
 String get(String name)
          Returns the string value of the property with the given name if any exist in this resource, or null.
 String getAlias()
          Returns the mapping alias of the associated Resource
 float getBoost()
          Returns the boost for the property.
 Property[] getProperties()
          Returns all the properties for the resource.
 Property[] getProperties(String name)
          Returns all the properties under the given name.
 Property getProperty(String name)
          Returns the first property under the name.
 String[] getValues(String name)
          Returns an array of values of the property specified as the method parameter.
 Resource removeProperties(String name)
          Removes all the properties under the given name.
 Resource removeProperty(String name)
          Remove the latest property added under the given name.
 Resource setAlias(String alias)
          Sets the alias of the Resource.
 Resource setBoost(float boost)
          Sets the boost level for the property.
 

Method Detail

getAlias

String getAlias()
Returns the mapping alias of the associated Resource

Returns:
The alias

setAlias

Resource setAlias(String alias)
Sets the alias of the Resource. Advance method, since it is handled by Compass marshlling based on mapping file if using OSEM.

Parameters:
alias -

get

String get(String name)
Returns the string value of the property with the given name if any exist in this resource, or null. If multiple properties exist with this name, this method returns the first value added.

Parameters:
name -
Returns:
The first value that match the name

getValues

String[] getValues(String name)
Returns an array of values of the property specified as the method parameter. This method can return null.

Parameters:
name - the name of the property
Returns:
a String[] of property values

addProperty

Resource addProperty(String name,
                     Object value)
                     throws SearchEngineException
Adds a property to the resource based on resource mapping definitions. If the property already exists in the resource (the name exists), it will be added on top of it (won't replace it). ONLY use this method with resource mapping.

Parameters:
name - the name of the property
value - the value to be set (will be converted to a string).
Throws:
SearchEngineException

addProperty

Resource addProperty(String name,
                     Reader value)
                     throws SearchEngineException
Adds a property to the resource based on resource mapping definitions. If the property already exists in the resource (the name exists), it will be added on top of it (won't replace it). ONLY use this method with resource mapping.

Parameters:
name - the name of the property
value - the value to be set (will be converted to a string).
Throws:
SearchEngineException

addProperty

Resource addProperty(Property property)
Add a property to the resource. If the property already exists in the resource (the name exists), it will be added on top of it (won't replace it). Note: Compass adds all properties specified in mapping file, adding extra properties to a Resource will make the index out of sync with mapping.

Parameters:
property -

removeProperty

Resource removeProperty(String name)
Remove the latest property added under the given name.

Parameters:
name -

removeProperties

Resource removeProperties(String name)
Removes all the properties under the given name.

Parameters:
name -

getProperty

Property getProperty(String name)
Returns the first property under the name.

Parameters:
name -
Returns:
The first proeprty that match the name

getProperties

Property[] getProperties(String name)
Returns all the properties under the given name.

Parameters:
name -
Returns:
An array of properties that match the name

getProperties

Property[] getProperties()
Returns all the properties for the resource.

Returns:
All the properties

getBoost

float getBoost()
Returns the boost for the property.

Returns:
The boost value

setBoost

Resource setBoost(float boost)
Sets the boost level for the property.

Parameters:
boost -


Copyright (c) 2004-2006 The Compass Project.