fipaos.skill.db.memorydatabase
Class MemoryDatabase


public class MemoryDatabase
implements Database

This Database implementation provides a simple non-persistent database


Inner Class Summary
 public classMemoryDatabase.DatabaseInfo
           

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

Method Summary
 voidaddObject(DatabaseObject obj)
          Method to add the given DatabaseObject to the database, in the given relation.
 voidcloseDatabase()
          Method to close the database store.
 voidcreateDatabase()
          Method to create the database store.
 voidcreateRelation(String relation)
          Creates the given relation within the Database
 voiddeleteDatabase()
          Method to remove the database store.
 voiddeleteRelation(String relation)
          Deletes the given relation from the Database
 voidendTransaction()
          Indicates that a transaction has finished.
 DatabaseObjectfindObject(String unique_id)
          Method to locate the object in the given relation with the given UID
 EnumerationgetIDs()
          Method to return an enumeration of the keys in the database
 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

MemoryDatabase

public MemoryDatabase(String name, DatabaseProfile db_profile)
Default constructor
Method Detail

addObject

public void addObject(DatabaseObject obj)
throws fipaos.skill.db.DatabaseException
Method to add the given DatabaseObject to the database, in the given relation.
Parameters:
obj - The DatabaseObject to add

closeDatabase

public void closeDatabase()
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 void createDatabase()
Method to create the database store. Either this method or openDatabase() should be called before attempting to interact with the Database

createRelation

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

deleteDatabase

public void deleteDatabase()
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()
Indicates that a transaction has finished. THIS MUST BE CALLED AFTER THE DATABASE HAS BEEN MANIPULATED IN ORDER TO COMMIT CHANGES.

findObject

public 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 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 void openDatabase()
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)
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
Parameters:
obj - The DatabaseObject to update

Association Links

to Class java.util.Hashtable

Contains all databases controlled by the MemoryDatabase

to Class java.util.Hashtable

The Hashtable that this represents as the DB

to Class java.lang.String

This Database name

to Class fipaos.skill.db.memorydatabase.MemoryDatabase.DatabaseInfo

Lock for our DB

to Class java.lang.Thread

Thread which is in the transaction

to Class fipaos.agent.profile.DatabaseProfile

DatabaseProfile to use