net.wotonomy.datastore
Interface DataIndex

All Superinterfaces:
java.io.Serializable
All Known Implementing Classes:
DefaultDataIndex

public interface DataIndex
extends java.io.Serializable

A DataIndex maintains a list of objects associated with values. The objects can then be retrieved based on the values. This class should not be much more complex than a simple map or list because the DataSoup is responsible for populating it.


Method Summary
 java.lang.Object addObject(java.lang.Object anObject, java.lang.Object newValue)
          Adds an object to be associated with the specified value.
 void clear()
          Removes all objects from the index.
 java.lang.String getName()
          Gets the name of this index.
 java.lang.String getProperty()
          The property managed by this index.
 java.util.List query(java.lang.Object beginValue, java.lang.Object endValue)
          Returns all objects in the index whose associated values fall between the two specified values, inclusive.
 java.lang.Object removeObject(java.lang.Object anObject, java.lang.Object oldValue)
          Removes an object from the index.
 java.lang.Object updateObject(java.lang.Object anObject, java.lang.Object oldValue, java.lang.Object newValue)
          Updates an object previously associated with the specified value to be associated with the specified new value.
 

Method Detail

getName

java.lang.String getName()
Gets the name of this index. The DataSoup uses this to uniquely refer to this index.

Returns:
The name of this index.

getProperty

java.lang.String getProperty()
The property managed by this index. This is the property used when the DataSoup builds and rebuilds this index.

Returns:
The property managed by this index.

addObject

java.lang.Object addObject(java.lang.Object anObject,
                           java.lang.Object newValue)
Adds an object to be associated with the specified value.

Parameters:
anObject - A data object, usually but not always a DataKey.
newValue - The property value to be associated with the data object.
Returns:
The data object that was inserted, or null if an error occurred.

updateObject

java.lang.Object updateObject(java.lang.Object anObject,
                              java.lang.Object oldValue,
                              java.lang.Object newValue)
Updates an object previously associated with the specified value to be associated with the specified new value.

Parameters:
anObject - A data object, usually but not always a DataKey.
oldValue - The value currently associated with the data object.
newValue - The value to be associated with the data object.
Returns:
The data object that was updated, or null if an error occurred.

removeObject

java.lang.Object removeObject(java.lang.Object anObject,
                              java.lang.Object oldValue)
Removes an object from the index.

Parameters:
anObject - A data object, usually but not always a DataKey.
oldValue - The value currently associated with the data object.
Returns:
The data object that was removed, or null if not found or error.

clear

void clear()
Removes all objects from the index. Usually called before rebuilding the index.


query

java.util.List query(java.lang.Object beginValue,
                     java.lang.Object endValue)
Returns all objects in the index whose associated values fall between the two specified values, inclusive.

Parameters:
beginValue - The beginning value, or null for all values up to an including the end key.
endValue - The ending value, or null for all values since and including the begin key.
Returns:
A List of the matching objects, ordered in increasing value, or null for invalid query parameters or other error.


Copyright © 2006 null. All Rights Reserved.