org.compass.core.lucene
Class LuceneMultiResource

java.lang.Object
  extended by org.compass.core.lucene.LuceneMultiResource
All Implemented Interfaces:
Serializable, Map, Resource, AliasedObject, InternalResource, MultiResource

public class LuceneMultiResource
extends Object
implements MultiResource, Map

Author:
kimchy
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
Constructor Summary
LuceneMultiResource(String alias, LuceneSearchEngine searchEngine)
           
 
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 addResource()
          Adds another Resource, and moves the current resource to the newly created one.
 void clear()
          Clears all the saves resources.
 boolean containsKey(Object key)
           
 boolean containsValue(Object value)
           
 void copy(Resource resource)
          Copies the content of the give Resource into the current one
 Resource currentResource()
          Returns the curren Resource.
 Set entrySet()
           
 Object get(Object key)
           
 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.
 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 vlaue of the property with the given name if any exists in the resource, or null.
 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.
 boolean isEmpty()
           
 Set keySet()
           
 Object put(Object key, Object value)
           
 void putAll(Map t)
           
 Object remove(Object key)
           
 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 resource(int i)
          Returns the Resource at the given postion.
 ResourceKey resourceKey()
           
 Resource setBoost(float boost)
          Sets the boost level for the resource.
 int size()
          Returns the number of Resources.
 String toString()
           
 Collection values()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Constructor Detail

LuceneMultiResource

public LuceneMultiResource(String alias,
                           LuceneSearchEngine searchEngine)
Method Detail

size

public int size()
Description copied from interface: MultiResource
Returns the number of Resources.

Specified by:
size in interface Map
Specified by:
size in interface MultiResource

currentResource

public Resource currentResource()
Description copied from interface: MultiResource
Returns the curren Resource.

Specified by:
currentResource in interface MultiResource

resourceKey

public ResourceKey resourceKey()
Specified by:
resourceKey in interface InternalResource

addResource

public void addResource()
Description copied from interface: MultiResource
Adds another Resource, and moves the current resource to the newly created one.

Specified by:
addResource in interface MultiResource

resource

public Resource resource(int i)
Description copied from interface: MultiResource
Returns the Resource at the given postion.

Specified by:
resource in interface MultiResource

clear

public void clear()
Description copied from interface: MultiResource
Clears all the saves resources.

Specified by:
clear in interface Map
Specified by:
clear in interface MultiResource

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.

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

get

public String get(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:
get 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 vlaue 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

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

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

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

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

toString

public String toString()
Overrides:
toString in class Object

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface Map

containsKey

public boolean containsKey(Object key)
Specified by:
containsKey in interface Map

containsValue

public boolean containsValue(Object value)
Specified by:
containsValue in interface Map

values

public Collection values()
Specified by:
values in interface Map

putAll

public void putAll(Map t)
Specified by:
putAll in interface Map

entrySet

public Set entrySet()
Specified by:
entrySet in interface Map

keySet

public Set keySet()
Specified by:
keySet in interface Map

get

public Object get(Object key)
Specified by:
get in interface Map

remove

public Object remove(Object key)
Specified by:
remove in interface Map

put

public Object put(Object key,
                  Object value)
Specified by:
put in interface Map


Copyright (c) 2004-2006 The Compass Project.