fipaos.skill.db.serializationdatabase
Class SerializationDatabase


public class SerializationDatabase
implements Database

This Database implementation provides a simple persistent database


Constructor Summary
SerializationDatabase(String name, DatabaseProfile db_profile)
          Default constructor

Method Summary
 synchronized voidaddObject(DatabaseObject obj)
          Method to add the given DatabaseObject to the database, in the given relation.
 synchronized voidcloseDatabase()
          Method to close the database store.
 synchronized voidcreateDatabase()
          Method to create the database store.
 voidcreateRelation(String relation)
          Creates the given relation within the Database
 synchronized voiddeleteDatabase()
          Method to remove the database store.
 voiddeleteRelation(String relation)
          Deletes the given relation from the Database
 voidendTransaction()
          Indicates that a transaction has finished.
 synchronized DatabaseObjectfindObject(String unique_id)
          Method to locate the object in the given relation with the given UID
 synchronized EnumerationgetIDs()
          Method to return an enumeration of the keys in the database
 synchronized voidopenDatabase()
          Method to re-open the database store.
 voidremoveObject(DatabaseObject obj)
          Method to remove the given DatabaseObject from the Database
 voidremoveObject(String unique_id)
          Method to remove the DatabaseObject from the Database with the given UID
 voidstartTransaction(boolean readonly)
          Indicates that a transaction is about to start.
 voidupdateObject(DatabaseObject obj)
          Method to update the given DatabaseObject in the Database.

Constructor Detail

SerializationDatabase

public SerializationDatabase(String name, DatabaseProfile db_profile)
Default constructor
Parameters:
name - The name of the database. Can be the fully specified path.
Method Detail

addObject

public synchronized void addObject(DatabaseObject obj)
throws fipaos.skill.db.DatabaseException
Method to add the given DatabaseObject to the database, in the given relation. This overwrites any object that has the same key as the given object
Parameters:
obj - The DatabaseObject to add

closeDatabase

public synchronized void closeDatabase()
throws fipaos.skill.db.DatabaseException
Method to close the database store. Should only be called after openDatabase() or createDatabase() have been used and after all necessary transactions have been made. Transactions cannot take place again until the database is re-opened.

createDatabase

public synchronized void createDatabase()
throws fipaos.skill.db.DatabaseException
Method to create the database store. Either this method or openDatabase() should be called before attempting to interact with the Database. If the Database already exists, it will be "overwritten"

createRelation

public void createRelation(String relation)
Creates the given relation within the Database
Parameters:
relation - The name of the relation to create

deleteDatabase

public synchronized void deleteDatabase()
throws fipaos.skill.db.DatabaseException
Method to remove the database store. The database will be closed if necessary before the store is removed. The database can only be used again once a new store has been created.

deleteRelation

public void deleteRelation(String relation)
Deletes the given relation from the Database
Parameters:
relation - The name of the relation to delete

endTransaction

public void endTransaction()
throws fipaos.skill.db.DatabaseException
Indicates that a transaction has finished. THIS MUST BE CALLED AFTER THE DATABASE HAS BEEN MANIPULATED IN ORDER TO COMMIT CHANGES.

findObject

public synchronized DatabaseObject findObject(String unique_id)
throws fipaos.skill.db.DatabaseException
Method to locate the object in the given relation with the given UID
Parameters:
unique_id - The unique id of the DatabaseObject to find

getIDs

public synchronized Enumeration getIDs()
throws fipaos.skill.db.DatabaseException
Method to return an enumeration of the keys in the database
Returns: An Enumeration of the ID's of the objects in the database

openDatabase

public synchronized void openDatabase()
throws fipaos.skill.db.DatabaseException
Method to re-open the database store. Either this method or createDatabase() should be called before attempting to interact with the Database

removeObject

public void removeObject(DatabaseObject obj)
throws fipaos.skill.db.DatabaseException
Method to remove the given DatabaseObject from the Database
Parameters:
obj - The DatabaseObject to remove

removeObject

public void removeObject(String unique_id)
throws fipaos.skill.db.DatabaseException
Method to remove the DatabaseObject from the Database with the given UID
Parameters:
unique_id - The unique id of the DatabaseObject to remove

startTransaction

public void startTransaction(boolean readonly)
throws fipaos.skill.db.DatabaseException
Indicates that a transaction is about to start. THIS MUST BE CALLED BEFORE THE DATABASE IS MANIPULATED.

updateObject

public void updateObject(DatabaseObject obj)
throws fipaos.skill.db.DatabaseException
Method to update the given DatabaseObject in the Database. This throws a RuntimeException if an object with the same key as the object given is not found within the database.
Parameters:
obj - The DatabaseObject to update

Association Links

to Class java.lang.String

This Databases name

to Class java.io.File

Reference to the directory containing the Databases' files

to Class java.lang.Thread

Thread which is in the transaction

to Class java.util.Stack

Stack containing type of lock required

to Class fipaos.agent.profile.DatabaseProfile

Profile being used by this DB