java.lang.Objectorg.objectweb.telosys.common.tinydb.TinyDatabase
This class represents a "tiny database" instance
A "tiny database" is a set of "tables" ( based on Java Hashtable instances )
It works as an "in memory database", it can be useful for tests or very small databases
The database dictionary and the database tables are stored in the filesystem by serialization
Constructor Summary | |
TinyDatabase(java.lang.String sFolder)
Constructs a new TinyDatabse located in the given folder |
Method Summary | |
TinyTable |
createTable(java.lang.String sTableName,
java.lang.Class keyClass,
java.lang.Class recordClass)
Creates a new table in the database |
boolean |
dropTable(java.lang.String sTableName)
|
static TinyDatabase |
getCurrentDatabase()
Returns the current database |
java.lang.String |
getDatabaseFolder()
Returns the database filesystem folder (where the tables are saved as files) |
TinyTable |
getTable(java.lang.String sTableName)
Returns the table object for the given table name If the table doesn't exist an exception is thrown The table returned is ready to use (its records are loaded) |
TinyTable |
getTable(java.lang.String sTableName,
boolean mustExist)
Returns the table object for the given table name (or null if the table is unknown and 'mustExist' flag = 'false') If a table is returned, it is ready to use (its records are loaded) |
java.lang.String[] |
getTableNames()
Returns all the table names registered in the database dictionary |
void |
loadAllTables()
Loads all the tables in memory |
void |
saveAllTables()
Saves all the tables in the filesystem |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public TinyDatabase(java.lang.String sFolder)
sFolder
- Method Detail |
public java.lang.String getDatabaseFolder()
public static TinyDatabase getCurrentDatabase()
public void loadAllTables()
public void saveAllTables()
public java.lang.String[] getTableNames()
public TinyTable getTable(java.lang.String sTableName)
sTableName
- the table name
public TinyTable getTable(java.lang.String sTableName, boolean mustExist)
sTableName
- the table namemustExist
- if true the table must exist (if it doesn't exist an exception is thrown), public TinyTable createTable(java.lang.String sTableName, java.lang.Class keyClass, java.lang.Class recordClass)
sTableName
- the name of the tablerecordClass
- the class of the records stored in this table
public boolean dropTable(java.lang.String sTableName)