org.garret.perst
Interface Index

All Superinterfaces:
java.io.Externalizable, GenericIndex, IPersistent, IResource, ITable, java.io.Serializable

public interface Index
extends GenericIndex

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, IPersistent obj)
          Put new object in the index.
 boolean put(java.lang.String key, IPersistent obj)
          Put new object in the string index.
 IPersistent remove(Key key)
          Remove key from the unique index.
 void remove(Key key, IPersistent obj)
          Remove object with specified key from the index
 IPersistent remove(java.lang.String key)
          Remove key from the unique string index.
 void remove(java.lang.String key, IPersistent obj)
          Remove object with specified string key from the index
 IPersistent set(Key key, IPersistent obj)
          Associate new value with the key.
 IPersistent set(java.lang.String key, IPersistent obj)
          Associate new value with string key.
 
Methods inherited from interface org.garret.perst.GenericIndex
clear, entryIterator, entryIterator, get, get, get, getKeyType, getKeyTypes, getPrefix, iterator, iterator, prefixIterator, prefixSearch, size, toPersistentArray, 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 org.garret.perst.ITable
select
 

Method Detail

put

public boolean put(Key key,
                   IPersistent 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

public boolean put(java.lang.String key,
                   IPersistent obj)
Put new object in the string index.

Parameters:
key - string 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

public IPersistent 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

public void remove(Key key,
                   IPersistent 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

public IPersistent remove(java.lang.String key)
Remove key from the unique string 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

public void remove(java.lang.String key,
                   IPersistent obj)
Remove object with specified string 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

set

public IPersistent set(Key key,
                       IPersistent 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

public IPersistent set(java.lang.String key,
                       IPersistent obj)
Associate new value with string 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 - string 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