SPT Object Database API

com.sptci.prevayler
Class IndexStorage

java.lang.Object
  extended by com.sptci.prevayler.IndexStorage
All Implemented Interfaces:
Serializable

public class IndexStorage
extends Object
implements Serializable

A class used as the storage mechanism for storing the indices for prevalent objects in the prevalent system.

© Copyright 2008 Sans Pareil Technologies, Inc.

Version:
$Id: IndexStorage.java 18 2008-07-20 03:35:47Z sptrakesh $
Author:
Rakesh Vidyadharan 2008-05-22
See Also:
Serialized Form

Nested Class Summary
private  class IndexStorage.FieldStorage
          The storage used to maintain the indices for a field or combination of fields.
 
Field Summary
private static String NULL_VALUE
          The constant used to index null keys.
private static long serialVersionUID
           
private  Map<String,IndexStorage.FieldStorage> storage
          A map used to maintain indices for a prevalent object.
 
Constructor Summary
IndexStorage()
           
 
Method Summary
 void add(String[] fields, Collection index, PrevalentObject object)
          Add a new index for the specified fields to the store.
 void add(String field, Object index, PrevalentObject object)
          Add a new index for the specified field to the store.
 Collection<IndexedObject> get(String field, Object index)
          Return the collection of prevalent objects that match the specified index value.
protected  String getFieldName(String[] fields)
          Return the name used to represent the specified array of field names.
 boolean isFieldIndexed(String field)
          Determine whether the specified field is indexed.
 boolean isIndexed(String[] fields, Object values)
          Determines when the specified index exists in the store.
 boolean isIndexed(String field, Object value)
          Determines when the specified index exists in the store.
 void remove(PrevalentObject object)
          Remove the indices for the specified prevalent object from the store.
 void remove(String field, Object key, PrevalentObject value)
          Remove the index entry for the specified reference object that is refernced by the specified parent prevalent object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

NULL_VALUE

private static final String NULL_VALUE
The constant used to index null keys. This is useful to be able to find instances where an indexed field is null.

See Also:
Constant Field Values

storage

private final Map<String,IndexStorage.FieldStorage> storage
A map used to maintain indices for a prevalent object. The key to the map is the name(s) of the field(s) that are indexed, and the values are IndexStorage.FieldStorage instances.

Constructor Detail

IndexStorage

public IndexStorage()
Method Detail

add

public void add(String field,
                Object index,
                PrevalentObject object)
Add a new index for the specified field to the store.

Parameters:
field - The name of the field that is indexed.
index - The index for the field specified.
object - The prevalent object to associate with the index.
See Also:
IndexStorage.FieldStorage.add(java.lang.Object, com.sptci.prevayler.PrevalentObject)

add

public void add(String[] fields,
                Collection index,
                PrevalentObject object)
Add a new index for the specified fields to the store.

Parameters:
fields - The array of field names that are being indexed.
index - The index for the fields specified.
object - The prevalent object to associate with the index.
See Also:
IndexStorage.FieldStorage.add(java.lang.Object, com.sptci.prevayler.PrevalentObject)

remove

public void remove(PrevalentObject object)
Remove the indices for the specified prevalent object from the store.

Parameters:
object - The prevalent object to remove from the store.
See Also:
IndexStorage.FieldStorage.remove(java.lang.Object, com.sptci.prevayler.PrevalentObject)

remove

public void remove(String field,
                   Object key,
                   PrevalentObject value)
Remove the index entry for the specified reference object that is refernced by the specified parent prevalent object.

Parameters:
field - The name of the field that was indexed.
key - The referenced object that was indexed.
value - The parent prevalent object that holds a reference to the indexed child prevalent object.

get

public Collection<IndexedObject> get(String field,
                                     Object index)
Return the collection of prevalent objects that match the specified index value.

Parameters:
field - The name of the field that was indexed in the prevalent object.
index - The value of the indexed field to use to retrieve the objects.
Returns:
The collection of matching indexed objects that represent the prevalent objects.

isIndexed

public boolean isIndexed(String[] fields,
                         Object values)
Determines when the specified index exists in the store.

Parameters:
fields - The array of field names that are indexed.
values - The collection of values for the fields that are to be checked for existence in the store.
Returns:
Returns true if the values are indexed in the store.
See Also:
IndexStorage.FieldStorage.isIndexed(java.lang.Object)

isIndexed

public boolean isIndexed(String field,
                         Object value)
Determines when the specified index exists in the store.

Parameters:
field - The field name that is indexed.
value - The value that is to be checked for existence.
Returns:
Returns true if the value is indexed in the store.
See Also:
IndexStorage.FieldStorage.isIndexed(java.lang.Object)

isFieldIndexed

public boolean isFieldIndexed(String field)
Determine whether the specified field is indexed. This may be used to quickly determine whether a specified field in an already processed object has been annotated as indexed or not.

Parameters:
field - The name of the field that is to be checked.
Returns:
Returns true if the field is indexed.

getFieldName

protected String getFieldName(String[] fields)
Return the name used to represent the specified array of field names.

Parameters:
fields - The array of field names being indexed.
Returns:
The normalised name that represents the field names.

SPT Object Database API