org.compass.core
Interface CompassOperations

All Known Subinterfaces:
CompassSession, InternalCompassSession
All Known Implementing Classes:
CompassTemplate, DefaultCompassSession

public interface CompassOperations

A interface describing all the available operations allowed by compass.

Author:
kimchy

Method Summary
 void create(Object obj)
          Creates a NEW object in Compass.
 void create(String alias, Object obj)
          Creates a NEW object in Compass that shares mapping alais with multiple objects.
 Property createProperty(String name, byte[] value, Property.Store store)
          Creates a binary property only stored (can be compressed).
 Property createProperty(String name, Reader value)
          Creates a property (indexed, and not stored) for the specified reader.
 Property createProperty(String name, Reader value, Property.TermVector termVector)
          Creates a property (indexed, and not stored) for the specified reader.
 Property createProperty(String name, String value, Property.Store store, Property.Index index)
          Creates a Property that is used with the actual Search Engine.
 Property createProperty(String name, String value, Property.Store store, Property.Index index, Property.TermVector termVector)
          Creates a Property that is used with the actual Search Engine.
 Resource createResource(String alias)
          Creates a resource, that is used with the actual Search Engine implementation.
 void delete(Class clazz, Object obj)
          Deletes an object from Compass that match the mapping specified for the defined class.
 void delete(CompassQuery query)
          Deletes all entries in the index that match the given query.
 void delete(Object obj)
          Deletes an object from Compass.
 void delete(Resource resource)
          Deletes a resource with the specified alias.
 void delete(String alias, Object obj)
          Deletes an object from Compass with multiple alias's.
 void evict(Object obj)
          Evicts the given object from the first level cache (transaction scoped cache).
 void evict(Resource resource)
          Evicts the given resource from the first level cache (transaction scoped cache).
 void evict(String alias, Object id)
          Evicts the given object from the first level cache (transaction scoped cache).
 void evictAll()
          Evicts all the objects and the resources from the first level cache.
 CompassHits find(String query)
          Finds a list of objects that match the specified query.
 Object get(Class clazz, Serializable id)
          Returns an object that match the mapping specified for the defined class, and matches the specified id.
 Object get(String alias, Serializable id)
          Returns an object that match the mapping specified for the defined alias, and matches the specified id.
 Resource getResource(Class clazz, Serializable id)
          Returns a Resource that match the mapping specified for the defined class type, and specified id.
 Resource getResource(String alias, Serializable id)
          Returns a Resource that match the mapping specified for the defined alias (possibley different object types), and matches the specified id.
 CompassSettings getSettings()
          Runtimes settings that apply on the session level.
 Object load(Class clazz, Serializable id)
          Loads and returns an object that match the mapping specified for the defined class, and matches the specified id.
 Object load(String alias, Serializable id)
          Loads and returns an object that match the mapping specified for the defined class, and matches the specified id.
 Resource loadResource(Class clazz, Serializable id)
          Loads and returns a Resource that match the mapping specified for the defined class, and matches the specified id.
 Resource loadResource(String alias, Serializable id)
          Loads and returns a Resource that match the mapping specified for the defined alias, and matches the specified id.
 void save(Object obj)
          Saves an object in Compass.
 void save(String alias, Object obj)
          Saves an object in Compass that shares mapping alais with multiple objects.
 

Method Detail

getSettings

CompassSettings getSettings()
Runtimes settings that apply on the session level.

Returns:
Runtime settings applies on the session level
See Also:
RuntimeCompassEnvironment, RuntimeLuceneEnvironment

createResource

Resource createResource(String alias)
                        throws CompassException
Creates a resource, that is used with the actual Search Engine implementation.

Returns:
a new resource
Throws:
CompassException

createProperty

Property createProperty(String name,
                        String value,
                        Property.Store store,
                        Property.Index index)
                        throws CompassException
Creates a Property that is used with the actual Search Engine. The available values for the store and index parameters are provided in the Property interface (Property.Store and Property.Index). It stores no term vector information (Property.TermVector.NO).

Parameters:
name -
value -
store -
index -
Returns:
a new property
Throws:
CompassException

createProperty

Property createProperty(String name,
                        String value,
                        Property.Store store,
                        Property.Index index,
                        Property.TermVector termVector)
                        throws CompassException
Creates a Property that is used with the actual Search Engine. The available values for the store and index parameters are provided in the Property interface (Property.Store, Property.Index, Property.TermVector).

Parameters:
name - The name of the property
value - The value of the property
store - The store setting for the property
index - The index setting for the property
Returns:
a new property
Throws:
CompassException

createProperty

Property createProperty(String name,
                        Reader value)
                        throws CompassException
Creates a property (indexed, and not stored) for the specified reader. It stores no term vector information (Property.TermVector.NO).

Parameters:
name - The name of the property
value - The value of the property
Returns:
a new property
Throws:
CompassException

createProperty

Property createProperty(String name,
                        Reader value,
                        Property.TermVector termVector)
                        throws CompassException
Creates a property (indexed, and not stored) for the specified reader.

Parameters:
name - The name of the property
value - The value of the property
termVector - The term vector setting for the property
Returns:
a new property
Throws:
CompassException

createProperty

Property createProperty(String name,
                        byte[] value,
                        Property.Store store)
                        throws CompassException
Creates a binary property only stored (can be compressed).

Parameters:
name - The name of the property
value - The value of the property
store - The store setting for the property
Returns:
a new property
Throws:
CompassException

delete

void delete(Resource resource)
            throws CompassException
Deletes a resource with the specified alias. Note that the resource must have the defined ids in the mapping files set and an alias set.

Parameters:
resource - The resource to be deleted.
Throws:
CompassException

getResource

Resource getResource(Class clazz,
                     Serializable id)
                     throws CompassException
Returns a Resource that match the mapping specified for the defined class type, and specified id. The id can be an object of the class (with the id attributes set), an array of id objects, or the actual id object. Returns null if the object is not found.

Parameters:
clazz - The class that represents the required mapping
id - The id that identifies the resource
Returns:
The resource, returns null if not found
Throws:
CompassException

getResource

Resource getResource(String alias,
                     Serializable id)
                     throws CompassException
Returns a Resource that match the mapping specified for the defined alias (possibley different object types), and matches the specified id. The id can be an object of the class (with the id attributes set), an array of id objects, or the actual id object. Returns null if the object is not found.

Parameters:
alias - The alias that represents the required mapping
id - The id that identifies the resource
Returns:
The resource
Throws:
CompassException

loadResource

Resource loadResource(Class clazz,
                      Serializable id)
                      throws CompassException
Loads and returns a Resource that match the mapping specified for the defined class, and matches the specified id. The id can be an object of the class (with the id attributes set), an array of id objects, or the actual id object. Throws an exception if the resource is not found.

Parameters:
clazz - The class that represents the required mapping
id - The id that identifies the resource
Returns:
The resource
Throws:
CompassException

loadResource

Resource loadResource(String alias,
                      Serializable id)
                      throws CompassException
Loads and returns a Resource that match the mapping specified for the defined alias, and matches the specified id. The id can be an object of the class (with the id attributes set), an array of id objects, or the actual id object. Throws an exception if the resource is not found.

Parameters:
alias - The alias that represents the required mapping
id - The id that identifies the resource
Returns:
The resource
Throws:
CompassException

delete

void delete(Object obj)
            throws CompassException
Deletes an object from Compass. The object must have been either loaded by Compass or it's ids must be set if already known.

Parameters:
obj - The object to delete
Throws:
CompassException

delete

void delete(String alias,
            Object obj)
            throws CompassException
Deletes an object from Compass with multiple alias's. The object can either be the id (or an array of ids), or the actual data object with it's property ids set.

Parameters:
alias - The alias that the objects maps under
obj - The object to delete
Throws:
CompassException

delete

void delete(Class clazz,
            Object obj)
            throws CompassException
Deletes an object from Compass that match the mapping specified for the defined class. The object can either be the id (or an array of ids), or the actual data object with it's property ids set.

Parameters:
clazz - The class that represtents the required mapping
obj - The object to delete
Throws:
CompassException

get

Object get(Class clazz,
           Serializable id)
           throws CompassException
Returns an object that match the mapping specified for the defined class, and matches the specified id. The id can be an object of the class (with the id attributes set), an array of id objects, or the actual id object. Returns null if the object is not found.

Parameters:
clazz - The class that represents the required mapping
id - The id that identifies the resource
Returns:
The object, returns null if not found
Throws:
CompassException

get

Object get(String alias,
           Serializable id)
           throws CompassException
Returns an object that match the mapping specified for the defined alias, and matches the specified id. The id can be an object of the class (with the id attributes set), an array of id objects, or the actual id object. Returns null if the object is not found.

Parameters:
alias - The alias that represents the required mapping
id - The id that identifies the resource
Returns:
The object, returns null if not found
Throws:
CompassException

load

Object load(Class clazz,
            Serializable id)
            throws CompassException
Loads and returns an object that match the mapping specified for the defined class, and matches the specified id. The id can be an object of the class (with the id attributes set), an array of id objects, or the actual id object. Throws an exception if the resource is not found.

Parameters:
clazz - The class that represents the required mapping
id - The id that identifies the resource
Returns:
The object
Throws:
CompassException

load

Object load(String alias,
            Serializable id)
            throws CompassException
Loads and returns an object that match the mapping specified for the defined class, and matches the specified id. The id can be an object of the class (with the id attributes set), an array of id objects, or the actual id object. Throws an exception if the resource is not found.

Parameters:
alias - The alias that represents the required mapping
id - The id that identifies the resource
Returns:
The object
Throws:
CompassException

delete

void delete(CompassQuery query)
            throws CompassException
Deletes all entries in the index that match the given query.

Parameters:
query - The query to delete by
Throws:
CompassException

find

CompassHits find(String query)
                 throws CompassException
Finds a list of objects that match the specified query. The query syntax is a search engine format query. For detailed description of the query syntax please visit the site.

Several examples are:

Note that the list may contains several object types (classes) with no relation between them (except for the semantic relation).

Parameters:
query - The query string to search by
Returns:
A hits of objects that matches the query string
Throws:
CompassException

create

void create(Object obj)
            throws CompassException
Creates a NEW object in Compass. All the meta data defined in the Compass mapping files will be indexed and saved for later searching. Note that if the same object (same alias and same id's already exists in the index, it won't be deleted).

Parameters:
obj - The object to save.
Throws:
CompassException

create

void create(String alias,
            Object obj)
            throws CompassException
Creates a NEW object in Compass that shares mapping alais with multiple objects. All the meta data defined in Compass mapping files will be indexed and saved for later searching.

Parameters:
alias - The alias that match the object mappings
obj - The object to save
Throws:
CompassException

save

void save(Object obj)
          throws CompassException
Saves an object in Compass. All the meta data defined in the Compass mapping files will be indexed and saved for later searching.

Parameters:
obj - The object to save.
Throws:
CompassException

save

void save(String alias,
          Object obj)
          throws CompassException
Saves an object in Compass that shares mapping alais with multiple objects. All the meta data defined in Compass mapping files will be indexed and saved for later searching.

Parameters:
alias - The alias that match the object mappings
obj - The object to save
Throws:
CompassException

evict

void evict(Object obj)
Evicts the given object from the first level cache (transaction scoped cache).

Parameters:
obj - The objects to evict.

evict

void evict(String alias,
           Object id)
Evicts the given object from the first level cache (transaction scoped cache). The object can either be the id (or an array of ids), or the actual data object with it's property ids set.

Parameters:
alias - The alias of the object/entry to evict.
id - The id of the object/entry to evict.

evict

void evict(Resource resource)
Evicts the given resource from the first level cache (transaction scoped cache).

Parameters:
resource - The resource to evict.

evictAll

void evictAll()
Evicts all the objects and the resources from the first level cache.



Copyright (c) 2004-2006 The Compass Project.