|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.coyotegulch.jisp.ObjectDatabaseFile
com.coyotegulch.jisp.IndexedObjectDatabase
The IndexedObjectDatabase
class provides a mechanism for
using a key value to an object serialized to a file.
A IndexedObjectDatabase
object encapsulates access to a
ObjectDatabaseFile
via a set of ObjectIndex
s.
When an object is stored, it is associated with a key value by storing the
key and an object reference in each attached ObjectIndex
.
Objects may then be retrieved either by providing a key and index pair,
or through an iterator created for an index associated with the database.
BTreeIndex
,
DatabaseException
,
OrderedObject
,
ObjectIndex
Field Summary |
Fields inherited from class com.coyotegulch.jisp.ObjectDatabaseFile |
DEL_LIST_END, IS_ACTIVE, IS_DELETED, m_dataFile, m_fileName, m_filter, m_firstDeleted |
Constructor Summary | |
IndexedObjectDatabase(java.lang.String filename,
boolean is_new)
Opens an existing IndexedObjectDatabase , using a supplied file name. |
Method Summary | |
void |
attachIndex(ObjectIndex index)
Attaches an index object to this database. |
void |
insert(OrderedObject[] key,
java.io.Serializable obj)
Write a new object to the database, associating it with the provided keys. |
java.util.Vector |
read(IndexIterator iterator)
Read the object associated with a given iterator. |
java.util.Vector |
read(OrderedObject key,
ObjectIndex index)
Read the object(s) associated with a given key. |
void |
remove(OrderedObject key,
ObjectIndex index)
Delete the record associated with a given key. |
void |
removeIndex(ObjectIndex index)
Removes the association of an index with this database. |
void |
write(OrderedObject[] keys,
java.io.Serializable obj)
Writes an object to the database, associating it with the provided key, replacing an existing object with a new one. |
Methods inherited from class com.coyotegulch.jisp.ObjectDatabaseFile |
assignFilter, close, compact, delete, getFD, getFilePointer, getNextOpen, length, readObject, rewind, rewriteObject, seek, skip, writeObject |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public IndexedObjectDatabase(java.lang.String filename, boolean is_new) throws java.io.IOException
IndexedObjectDatabase
, using a supplied file name.
filename
- The name of an external database file containing serialized objects.
If filename
exists, it is opened; otherwise, the constructor
creates the file and initializes it.
java.io.IOException
- when an I/O exception is thrown by an underlying java.io.* classMethod Detail |
public void attachIndex(ObjectIndex index)
index
- An ObjectIndex
to be associated with this database.ObjectIndex
public void removeIndex(ObjectIndex index)
index
- An ObjectIndex
that should no longer be associated with this database.ObjectIndex
public void insert(OrderedObject[] key, java.io.Serializable obj) throws java.io.IOException, java.lang.ClassNotFoundException
key
- The key values associated with obj
. There must be
one key for each attached index; the keys are associated with
the indexes in order of attachment; in other words, the first key
is associated with the first index attached, etc.obj
- The object to be stored in the database.
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
DatabaseException
- when an error occurs during database processingDatabaseException
,
OrderedObject
public void write(OrderedObject[] keys, java.io.Serializable obj) throws java.io.IOException, java.lang.ClassNotFoundException
keys
- key values associated with obj
. There must be
one key for each attached index; the keys are associated with
the indexes in order of attachment; in other words, the first key
is associated with the first index attached, etc.obj
- record object to be stored in the database.
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
DatabaseException
- when an error occurs during database processingDatabaseException
,
OrderedObject
public java.util.Vector read(OrderedObject key, ObjectIndex index) throws java.io.IOException, java.lang.ClassNotFoundException
key
- key identifying the record to be readindex
- index used to retrieve the object by key
.
key
, or null
if no such object could be found.
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
DatabaseException
- when an error occurs during database processingDatabaseException
,
OrderedObject
public java.util.Vector read(IndexIterator iterator) throws java.io.IOException, java.lang.ClassNotFoundException
iterator
- a BTreeIterator
pointing to the requested record
iterator
, or null
if the iterator was invalid or no such record could be found.
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
DatabaseException
- when an error occurs during database processingDatabaseException
,
BTreeIterator
,
OrderedObject
public void remove(OrderedObject key, ObjectIndex index) throws java.io.IOException, DatabaseException, java.lang.ClassNotFoundException
key
- array of keys identifying the record to be deleted.index
- index used to retrive the object by key
.
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
DatabaseException
- when an error occurs during database processingDatabaseException
,
OrderedObject
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |