org.garret.perst
Interface Index<T extends IPersistent>

All Superinterfaces:
java.util.Collection, java.io.Externalizable, GenericIndex, IPersistent, IResource, java.lang.Iterable, java.io.Serializable

public interface Index<T extends IPersistent>
extends GenericIndex<T>

Interface of object index. Index is used to provide fast access to the object by key. Object in the index are stored ordered by key value. It is possible to select object using exact value of the key or select set of objects which key belongs to the specified interval (each boundary can be specified or unspecified and can be inclusive or exclusive) Key should be of scalar, String, java.util.Date or peristent object type.


Field Summary
 
Fields inherited from interface org.garret.perst.GenericIndex
ASCENT_ORDER, DESCENT_ORDER
 
Method Summary
 boolean put(Key key, T obj)
          Put new object in the index.
 boolean put(java.lang.Object key, T obj)
          Put new object in the index.
 T remove(Key key)
          Remove key from the unique index.
 void remove(Key key, T obj)
          Remove object with specified key from the index
 void remove(java.lang.Object key, T obj)
          Remove object with specified key from the index
 T remove(java.lang.String key)
          Remove key from the unique string index.
 T removeKey(java.lang.Object key)
          Remove key from the unique index.
 T set(Key key, T obj)
          Associate new value with the key.
 T set(java.lang.Object key, T obj)
          Associate new value with specified key.
 
Methods inherited from interface org.garret.perst.GenericIndex
clear, entryIterator, entryIterator, entryIterator, get, get, get, get, getKeyType, getKeyTypes, getList, getList, getPrefix, getPrefixList, iterator, iterator, iterator, prefixIterator, prefixSearch, prefixSearchList, size, toPersistentArray
 
Methods inherited from interface org.garret.perst.IPersistent
assignOid, deallocate, getOid, getStorage, invalidate, isDeleted, isModified, isPersistent, isRaw, load, loadAndModify, makePersistent, modify, onLoad, onStore, recursiveLoading, store
 
Methods inherited from interface java.io.Externalizable
readExternal, writeExternal
 
Methods inherited from interface org.garret.perst.IResource
exclusiveLock, exclusiveLock, reset, sharedLock, sharedLock, unlock
 
Methods inherited from interface java.util.Collection
add, addAll, contains, containsAll, equals, hashCode, isEmpty, remove, removeAll, retainAll, toArray, toArray
 

Method Detail

put

boolean put(Key key,
            T obj)
Put new object in the index.

Parameters:
key - object key
obj - object associated with this key. Object can be not yet peristent, in this case its forced to become persistent by assigning OID to it.
Returns:
true if object is successfully inserted in the index, false if index was declared as unique and there is already object with such value of the key in the index.

put

boolean put(java.lang.Object key,
            T obj)
Put new object in the index.

Parameters:
key - packed key
obj - object associated with this key. Object can be not yet peristent, in this case its forced to become persistent by assigning OID to it.
Returns:
true if object is successfully inserted in the index, false if index was declared as unique and there is already object with such value of the key in the index.

remove

T remove(Key key)
Remove key from the unique index.

Parameters:
key - value of removed key
Returns:
removed object
Throws:
StorageError(StorageError.KEY_NOT_FOUND) - exception if there is no such key in the index, or StorageError(StorageError.KEY_NOT_UNIQUE) if index is not unique.

remove

void remove(Key key,
            T obj)
Remove object with specified key from the index

Parameters:
key - value of the key of removed object
obj - object removed from the index
Throws:
StorageError(StorageError.KEY_NOT_FOUND) - exception if there is no such key in the index

remove

void remove(java.lang.Object key,
            T obj)
Remove object with specified key from the index

Parameters:
key - value of the key of removed object
obj - object removed from the index
Throws:
StorageError(StorageError.KEY_NOT_FOUND) - exception if there is no such key in the index

remove

T remove(java.lang.String key)
Remove key from the unique string index.

Parameters:
key - packed value of removed key
Returns:
removed object
Throws:
StorageError(StorageError.KEY_NOT_FOUND) - exception if there is no such key in the index, or StorageError(StorageError.KEY_NOT_UNIQUE) if index is not unique.

removeKey

T removeKey(java.lang.Object key)
Remove key from the unique index.

Parameters:
key - packed value of removed key
Returns:
removed object
Throws:
StorageError(StorageError.KEY_NOT_FOUND) - exception if there is no such key in the index, or StorageError(StorageError.KEY_NOT_UNIQUE) if index is not unique.

set

T set(Key key,
      T obj)
Associate new value with the key. If there is already object with such key in the index, then it will be removed from the index and new value associated with this key.

Parameters:
key - object key
obj - object associated with this key. Object can be not yet peristent, in this case its forced to become persistent by assigning OID to it.
Returns:
object previously associated with this key, null if there was no such object

set

T set(java.lang.Object key,
      T obj)
Associate new value with specified key. If there is already object with such key in the index, then it will be removed from the index and new value associated with this key.

Parameters:
key - packed key
obj - object associated with this key. Object can be not yet peristent, in this case its forced to become persistent by assigning OID to it.
Returns:
object previously associated with this key, null if there was no such object