net.wotonomy.datastore
Class DefaultDataIndex

java.lang.Object
  extended by net.wotonomy.datastore.DefaultDataIndex
All Implemented Interfaces:
java.io.Serializable, DataIndex

public class DefaultDataIndex
extends java.lang.Object
implements DataIndex

This implementation of DataIndex wraps a TreeMap and adds the ability to contain objects with duplicate keys.

See Also:
Serialized Form

Field Summary
protected  java.lang.String name
           
protected  java.lang.String property
           
 
Constructor Summary
DefaultDataIndex()
           
DefaultDataIndex(java.lang.String aName, java.lang.String aProperty)
           
 
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.util.Comparator getComparator()
           
 java.lang.String getName()
          Gets the name of this index.
 java.lang.String getProperty()
          The property managed by this index.
 java.util.TreeMap getTreeMap()
           
protected  void populateListFromIterator(java.util.List aList, java.util.Iterator it)
           
 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.
 void setComparator(java.util.Comparator aComparator)
           
 void setName(java.lang.String aName)
           
 void setProperty(java.lang.String aProperty)
           
 void setTreeMap(java.util.TreeMap aMap)
           
 java.lang.String toString()
           
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

name

protected java.lang.String name

property

protected java.lang.String property
Constructor Detail

DefaultDataIndex

public DefaultDataIndex()

DefaultDataIndex

public DefaultDataIndex(java.lang.String aName,
                        java.lang.String aProperty)
Method Detail

getComparator

public java.util.Comparator getComparator()

setComparator

public void setComparator(java.util.Comparator aComparator)

getName

public java.lang.String getName()
Description copied from interface: DataIndex
Gets the name of this index. The DataSoup uses this to uniquely refer to this index.

Specified by:
getName in interface DataIndex
Returns:
The name of this index.

setName

public void setName(java.lang.String aName)

getProperty

public java.lang.String getProperty()
Description copied from interface: DataIndex
The property managed by this index. This is the property used when the DataSoup builds and rebuilds this index.

Specified by:
getProperty in interface DataIndex
Returns:
The property managed by this index.

setProperty

public void setProperty(java.lang.String aProperty)

getTreeMap

public java.util.TreeMap getTreeMap()

setTreeMap

public void setTreeMap(java.util.TreeMap aMap)

query

public java.util.List query(java.lang.Object beginValue,
                            java.lang.Object endValue)
Description copied from interface: DataIndex
Returns all objects in the index whose associated values fall between the two specified values, inclusive.

Specified by:
query in interface DataIndex
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.

populateListFromIterator

protected void populateListFromIterator(java.util.List aList,
                                        java.util.Iterator it)

addObject

public java.lang.Object addObject(java.lang.Object anObject,
                                  java.lang.Object newValue)
Description copied from interface: DataIndex
Adds an object to be associated with the specified value.

Specified by:
addObject in interface DataIndex
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

public java.lang.Object updateObject(java.lang.Object anObject,
                                     java.lang.Object oldValue,
                                     java.lang.Object newValue)
Description copied from interface: DataIndex
Updates an object previously associated with the specified value to be associated with the specified new value.

Specified by:
updateObject in interface DataIndex
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

public java.lang.Object removeObject(java.lang.Object anObject,
                                     java.lang.Object oldValue)
Description copied from interface: DataIndex
Removes an object from the index.

Specified by:
removeObject in interface DataIndex
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

public void clear()
Description copied from interface: DataIndex
Removes all objects from the index. Usually called before rebuilding the index.

Specified by:
clear in interface DataIndex

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright © 2006 null. All Rights Reserved.