com.coyotegulch.jisp
Interface ObjectIndex

All Known Implementing Classes:
BTreeIndex

public interface ObjectIndex

ObjectIndex defines the concept of an index that associates key values with references to serializable objects. Concrete subclasses of ObjectIndex assume that an object's position (as given by a long value) is constant, regardless of the actual meaning of that position. In general, the position represents the * location (file pointer) of a Serializable object in an IndexedObjectDatabase. *

* Use the IndexedObjectDatabase.attachIndex method to attach an ObjectIndex * to a database. A database updates all attached indexes when it writes or removes objects * from its file.

See Also:
ObjectIndex, IndexedObjectDatabase

Method Summary
 long[] findKey(OrderedObject key)
          Find the position of the object associated with a given key.
 void insertKey(OrderedObject key, long reference)
          Insert a key into the database, associating a record position with the given key.
 void removeKey(OrderedObject key, long reference)
          Removes specified reference from the entry for the given key, and removes the key itself if it no longer has an references.
 void removeKeyAll(OrderedObject key)
          Removes the given key from the index, no matter how many references it might be associated with.
 boolean supportsDupes()
          Tells if this index supports duplicate keys.
 

Method Detail

insertKey

public void insertKey(OrderedObject key,
                      long reference)
               throws java.io.IOException,
                      java.lang.ClassNotFoundException
Insert a key into the database, associating a record position with the given key. Throws a DuplicateKeyException exception if the key already exists.

Parameters:
key - A key identifying the record to be read.
reference - File position of record associated with key
Throws:
java.io.IOException - when an I/O exception is thrown by an underlying java.io.* class
java.lang.ClassNotFoundException - for a casting error, usually when a persistent object or index does match the expected type
DuplicateKeyException - when inserting a duplicate key into an index that does not support duplicates
See Also:
DuplicateKeyException, OrderedObject

findKey

public long[] findKey(OrderedObject key)
               throws java.io.IOException,
                      java.lang.ClassNotFoundException
Find the position of the object associated with a given key.

Parameters:
key - A key identifying the record to be read.
Returns:
The position of the record associated with key.
Throws:
java.io.IOException - when an I/O exception is thrown by an underlying java.io.* class
java.lang.ClassNotFoundException - for a casting error, usually when a persistent object or index does match the expected type
KeyNotFoundException - when the specified key can not be found in the index
See Also:
KeyNotFoundException, OrderedObject

removeKey

public void removeKey(OrderedObject key,
                      long reference)
               throws java.io.IOException,
                      java.lang.ClassNotFoundException
Removes specified reference from the entry for the given key, and removes the key itself if it no longer has an references. This method is used internally by IndexedObjectDatabase

Parameters:
key - A key identifying the record to be read.
reference -
Throws:
java.io.IOException - when an I/O exception is thrown by an underlying java.io.* class
java.lang.ClassNotFoundException - for a casting error, usually when a persistent object or index does match the expected type
KeyNotFoundException - when the specified key can not be found in the index
See Also:
KeyNotFoundException, OrderedObject

removeKeyAll

public void removeKeyAll(OrderedObject key)
                  throws java.io.IOException,
                         java.lang.ClassNotFoundException
Removes the given key from the index, no matter how many references it might be associated with.

Parameters:
key - A key identifying the record to be read.
Throws:
java.io.IOException - when an I/O exception is thrown by an underlying java.io.* class
java.lang.ClassNotFoundException - for a casting error, usually when a persistent object or index does match the expected type
KeyNotFoundException - when the specified key can not be found in the index
See Also:
KeyNotFoundException, OrderedObject

supportsDupes

public boolean supportsDupes()
Tells if this index supports duplicate keys.

Returns:
true if the index supports duplicate keys; false if not