|
Side of Software Persistence Library 2.0 |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectsos.db.AbstractDatabase
sos.db.AbstractSerializationDatabase
sos.db.FileDatabase
public class FileDatabase
A persistent database that stores objects in a random-access file.
AbstractSerializationDatabase for more information.
AbstractSerializationDatabase for more information.
AbstractSerializationDatabase,
TransactionPolicy,
InMemoryDatabase| Field Summary |
|---|
| Fields inherited from interface sos.db.Database |
|---|
logger |
| Constructor Summary | |
|---|---|
FileDatabase(java.lang.String databaseName,
java.lang.String fileName)
Creates a FileDatabase with the specified database name. |
|
FileDatabase(java.lang.String databaseName,
java.lang.String fileName,
TransactionPolicy policy)
Creates a FileDatabase with the specified database name and
transaction policy. |
|
| Method Summary | |
|---|---|
protected void |
doClose()
Performs the action of close. |
protected boolean |
doCreate(java.lang.Object root)
Performs the action of create. |
protected boolean |
doDelete()
Performs the action of delete. |
protected boolean |
doExists()
Performs the action of exists. |
protected byte[] |
doFetchObject(long id)
Returns the serialized object associated with id. |
protected boolean |
doFlush(LongMap<byte[]> newObjects,
LongMap<byte[]> modifiedObjects,
Progress progress)
Adds new objects, re-saves modified objects, and removes old objects from this database in a single, atomic step. |
protected long |
doNextKey(long fromKey)
Returns the next key greater than or equal to fromKey that
corresponds to an object in this database. |
protected void |
doOpen(boolean readOnly)
Performs the action of open. |
protected void |
doRemoveObject(long oldKey)
Removes the specified object from this database. |
| Methods inherited from class sos.db.AbstractDatabase |
|---|
abortTransaction, addObject, close, commitTransaction, containsObject, create, delete, exists, getRoot, isOpen, open, startTransaction, transactionDepth |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface sos.db.Database |
|---|
abortTransaction, addObject, close, commitTransaction, containsObject, create, delete, exists, getName, getRoot, getTransactionPolicy, isOpen, open, startTransaction, transactionDepth |
| Constructor Detail |
|---|
public FileDatabase(java.lang.String databaseName,
java.lang.String fileName)
FileDatabase with the specified database name.
databaseName - name of the databasefileName - name of the file to use the database
java.lang.NullPointerException - if fileName is nullFileDatabase(String,String,TransactionPolicy)
public FileDatabase(java.lang.String databaseName,
java.lang.String fileName,
TransactionPolicy policy)
FileDatabase with the specified database name and
transaction policy.
databaseName - name of the databasefileName - name of the file to use the databasepolicy - policy to use to control transactions (may be null)
java.lang.NullPointerException - if fileName is null| Method Detail |
|---|
protected void doClose()
throws java.io.IOException
AbstractDatabaseclose. This method is called
inside close if this database is in
an acceptable state. It has the same semantics as
close.
doClose in class AbstractSerializationDatabasejava.io.IOException - if an I/O error occursAbstractDatabase.close()
protected boolean doCreate(java.lang.Object root)
throws java.io.IOException
AbstractDatabasecreate. This method is called
inside create if this database is in
an acceptable state. It has the same semantics as
create.
doCreate in class AbstractSerializationDatabaseroot - the root of this database
true if this database does not exist and was successfully created;
false if this database already exists
java.io.IOException - if an I/O error occursAbstractDatabase.create(java.lang.Object)
protected boolean doDelete()
throws java.io.IOException
AbstractDatabasedelete. This method is called
inside delete if this database is in
an acceptable state. It has the same semantics as
delete.
doDelete in class AbstractSerializationDatabasetrue if this database is successfully deleted
java.io.IOException - if an I/O error occursAbstractDatabase.delete()protected boolean doExists()
AbstractDatabaseexists. This method is called
inside exists if this database is in
an acceptable state. It has the same semantics as
exists.
doExists in class AbstractDatabasetrue if this database existsAbstractDatabase.exists()
protected byte[] doFetchObject(long id)
throws java.io.IOException
AbstractSerializationDatabaseid.This method is called while holding this database's monitor.
doFetchObject in class AbstractSerializationDatabaseid - id of object to fetch
id
java.io.IOException - if an I/O error occurs
protected boolean doFlush(LongMap<byte[]> newObjects,
LongMap<byte[]> modifiedObjects,
Progress progress)
throws java.io.IOException
AbstractSerializationDatabaseThis method is called when a top-level transaction commits. It is called while holding this database's monitor.
doFlush in class AbstractSerializationDatabasenewObjects - a mapping of new ids (as Longs) to
new database objects (as byte[]s)modifiedObjects - a mapping of ids (as Longs) to
modified database objects (as byte[]s)progress - an object to be updated and checked as the flush is occurring
(may be null)
false if it is interrupted because the progress is canceled;
true otherwise
java.io.IOException - if an I/O error occurs
protected long doNextKey(long fromKey)
throws java.io.IOException
AbstractSerializationDatabasefromKey that
corresponds to an object in this database.
This method is called while holding this database's monitor.
doNextKey in class AbstractSerializationDatabasefromKey - key from which to start the search
java.io.IOException - if an I/O error occurs
protected void doRemoveObject(long oldKey)
throws java.io.IOException
AbstractSerializationDatabaseThis method is called when a garbage collection finds the object unreachable. It is called while holding this database's monitor.
doRemoveObject in class AbstractSerializationDatabaseoldKey - keys of the object to remove from this database
java.io.IOException - if an I/O error occurs
protected void doOpen(boolean readOnly)
throws java.io.IOException
AbstractDatabaseopen. This method is called
inside open if this database is in
an acceptable state. It has the same semantics as
open.
doOpen in class AbstractSerializationDatabasereadOnly - true if database updates are not allowed
java.io.IOException - if an I/O error occursAbstractDatabase.open
|
Side of Software Persistence Library 2.0 |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||