org.compass.core.converter.mapping
Class CollectionResourceWrapper

java.lang.Object
  extended by org.compass.core.converter.mapping.CollectionResourceWrapper
All Implemented Interfaces:
Serializable, Resource, AliasedObject

public class CollectionResourceWrapper
extends Object
implements Resource

Author:
kimchy
See Also:
Serialized Form

Nested Class Summary
 class CollectionResourceWrapper.PropertiesWrapper
           
 
Constructor Summary
CollectionResourceWrapper(Resource resource)
           
 
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.
 void copy(Resource resource)
          Copies the content of the give Resource into the current one
 String getAlias()
          Returns the mapping alias of the associated Resource
 float getBoost()
          Returns the boost for the property.
 String getId()
          Returns the id of the resource.
 Property[] getIdProperties()
          Returns the id properties of the resource
 Property getIdProperty()
          Returns the id property of the resource
 String[] getIds()
          Returns the id values of the resource.
 Object getObject(String name)
          Returns the object value of the property with the given name if any exists in the resource, or null.
 Object[] getObjects(String name)
          Returns an array of values of the proeprty with the given name.
 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 getUID()
          Returns the unique id of the resource.
 String getValue(String name)
          Returns the string value of the property with the given name if any exist in this resource, or null.
 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.
 void rollbackGetProperty(String name)
           
 Resource setBoost(float boost)
          Sets the boost level for the resource.
 Resource setProperty(Property property)
          Sest a property to the resource (removes then adds).
 Resource setProperty(String name, Object value)
          Sets a property to the resource (removes then adds) based on resource mapping definitions.
 Resource setProperty(String name, Reader value)
          Sets a property to the resource (removes then adds) based on resource mapping definitions.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CollectionResourceWrapper

public CollectionResourceWrapper(Resource resource)
Method Detail

getValue

public String getValue(String name)
Description copied from interface: Resource
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.

Specified by:
getValue in interface Resource
Parameters:
name - The name of the property
Returns:
The first value that match the name

getObject

public Object getObject(String name)
Description copied from interface: Resource
Returns the object value of the property with the given name if any exists in the resource, or null. If multiple properties exists with this name, this methods returns the first value added.

If a converter is associated with the property in one of Compass mapping definitions, it will be used to convert the string value to an object value. If there is no converter associated with the property, the string value will be returned.

Specified by:
getObject in interface Resource
Parameters:
name - The name of the property
Returns:
The first object value that match the name (converted if possible)

getValues

public String[] getValues(String name)
Description copied from interface: Resource
Returns an array of values of the property specified as the method parameter. This method can return null.

Specified by:
getValues in interface Resource
Parameters:
name - the name of the property
Returns:
a String[] of property values

getAlias

public String getAlias()
Description copied from interface: Resource
Returns the mapping alias of the associated Resource

Specified by:
getAlias in interface Resource
Specified by:
getAlias in interface AliasedObject
Returns:
The alias

getId

public String getId()
Description copied from interface: Resource
Returns the id of the resource. Used when there is only one id for the resource.

Specified by:
getId in interface Resource
Returns:
The id of the resource.

getUID

public String getUID()
Description copied from interface: Resource
Returns the unique id of the resource. Note, the ids must be set on this resource in order to get the uid, if not a CompassException will be thrown.

Specified by:
getUID in interface Resource

getIds

public String[] getIds()
Description copied from interface: Resource
Returns the id values of the resource.

Specified by:
getIds in interface Resource
Returns:
The id values of the resource

getIdProperty

public Property getIdProperty()
Description copied from interface: Resource
Returns the id property of the resource

Specified by:
getIdProperty in interface Resource
Returns:
The id properties of the resource

getIdProperties

public Property[] getIdProperties()
Description copied from interface: Resource
Returns the id properties of the resource

Specified by:
getIdProperties in interface Resource
Returns:
The id properties of the resource

addProperty

public Resource addProperty(String name,
                            Object value)
                     throws SearchEngineException
Description copied from interface: Resource
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.

Specified by:
addProperty in interface Resource
Parameters:
name - the name of the property
value - the value to be set (will be converted to a string).
Throws:
SearchEngineException

addProperty

public Resource addProperty(String name,
                            Reader value)
                     throws SearchEngineException
Description copied from interface: Resource
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.

Specified by:
addProperty in interface Resource
Parameters:
name - the name of the property
value - the value to be set (will be converted to a string).
Throws:
SearchEngineException

addProperty

public Resource addProperty(Property property)
Description copied from interface: Resource
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.

Specified by:
addProperty in interface Resource
Parameters:
property - The properyt to add

removeProperty

public Resource removeProperty(String name)
Description copied from interface: Resource
Remove the latest property added under the given name.

Specified by:
removeProperty in interface Resource
Parameters:
name - The last property name to remove

removeProperties

public Resource removeProperties(String name)
Description copied from interface: Resource
Removes all the properties under the given name.

Specified by:
removeProperties in interface Resource
Parameters:
name - The properties name to remove

setProperty

public Resource setProperty(String name,
                            Object value)
                     throws SearchEngineException
Description copied from interface: Resource
Sets a property to the resource (removes then adds) 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.

Specified by:
setProperty in interface Resource
Parameters:
name - the name of the property
value - the value to be set (will be converted to a string).
Throws:
SearchEngineException

setProperty

public Resource setProperty(String name,
                            Reader value)
                     throws SearchEngineException
Description copied from interface: Resource
Sets a property to the resource (removes then adds) 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.

Specified by:
setProperty in interface Resource
Parameters:
name - the name of the property
value - the value to be set (will be converted to a string).
Throws:
SearchEngineException

setProperty

public Resource setProperty(Property property)
Description copied from interface: Resource
Sest a property to the resource (removes then adds). 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.

Specified by:
setProperty in interface Resource
Parameters:
property - The properyt to add

getProperty

public Property getProperty(String name)
Description copied from interface: Resource
Returns the first property under the name.

Specified by:
getProperty in interface Resource
Parameters:
name - The name of the property
Returns:
The first proeprty that match the name

rollbackGetProperty

public void rollbackGetProperty(String name)

getProperties

public Property[] getProperties(String name)
Description copied from interface: Resource
Returns all the properties under the given name.

Specified by:
getProperties in interface Resource
Parameters:
name - The name of the properties
Returns:
An array of properties that match the name

getObjects

public Object[] getObjects(String name)
Description copied from interface: Resource
Returns an array of values of the proeprty with the given name. This method returns an empty array if no values are associated with the given name.

If a converter is associated with the property in one of Compass mapping definitions, it will be used to convert the string value to an object value. If there is no converter associated with the property, the string value will be returned.

Specified by:
getObjects in interface Resource

getProperties

public Property[] getProperties()
Description copied from interface: Resource
Returns all the properties for the resource.

Specified by:
getProperties in interface Resource
Returns:
All the properties

getBoost

public float getBoost()
Description copied from interface: Resource
Returns the boost for the property.

Specified by:
getBoost in interface Resource
Returns:
The boost value

setBoost

public Resource setBoost(float boost)
Description copied from interface: Resource
Sets the boost level for the resource.

Specified by:
setBoost in interface Resource
Parameters:
boost - The boost level for the resource

copy

public void copy(Resource resource)
Description copied from interface: Resource
Copies the content of the give Resource into the current one

Specified by:
copy in interface Resource
Parameters:
resource - The resource to copy from


Copyright (c) 2004-2008 The Compass Project.