Inheritance diagram for org.openmobileis.database.fastobjectdb.FastObjectDB:
FastObjectDB is the main class of the librairie. All base function are accessed by this class
FastObjectDB is an Object collection based database. Object are stored in collection. Object are retrieved using Index that are attached to collections. A SODA like API is use to request collection.
FODB creation : db = FastObjectDB.open(dbdir, "testdb"); if (!FODBCollection.isCollectionExist(db, "TESTSEARCH")) { // if not created create it. db.createCollection("TESTSEARCH", TestSearchData.class); FODBUniqueIntIndexDescriptor KeyDescriptor = new FODBUniqueIntIndexDescriptor("KEY", "getKey()", 5); db.addIndex("TESTSEARCH", KeyDescriptor); FODBMultipleIntIndexDescriptor debKeyDescriptor = new FODBMultipleIntIndexDescriptor("DIZ", "getDizaine()", 5, 5); db.addIndex("TESTSEARCH", debKeyDescriptor); }
Definition at line 70 of file FastObjectDB.java.
Public Member Functions | |
String | getRootDir () |
String | getName () |
FODBCollection | getCollection (String name) |
boolean | isCollectionExist (String colName) |
boolean | createCollection (FODBCollectionDescriptor descriptor) throws IOException, ClassNotFoundException, BadDataFormatException, FODBException |
Add a new collection to the database. | |
boolean | createCollection (String collectionName, Class objectType) throws IOException, ClassNotFoundException, BadDataFormatException, FODBException |
Add a new collection to the database. | |
boolean | isCollectionEmpty (String colName) throws DatabaseException |
boolean | addIndex (String colName, FODBIndexDescriptor descriptor) throws BadDataFormatException, FODBException |
Add an index to a Collection of the Database. | |
boolean | add (String colName, Object obj) throws FODBException |
Add an element to a Collection of the database. | |
boolean | replace (String colName, Object obj) throws FODBException |
Replace an existing element in a Collection of the database. | |
Query | query () |
use to get base class to query FODB. | |
boolean | delete (String colName, Object obj) throws FODBException |
Delete an element of a Collection. | |
boolean | deleteWithId (String colName, Object id) throws FODBException |
Delete an object of a Collection with its id. | |
String | toString () |
FODBCollection[] | getDatabaseCollectionArray () |
TransactionManager | getTransactionManager () |
Static Public Member Functions | |
static FastObjectDB | open (String dbRootDir, String dbName) throws IOException, ClassNotFoundException, BadDataFormatException, FODBException |
The function is called to open a database. | |
Protected Member Functions | |
FastObjectDB (String dbRootDir, String dbName, FODBMainFile fmf, int action) throws BadDataFormatException, FODBException | |
The Constructor. | |
boolean | openCollection (String collectionName) throws IOException, ClassNotFoundException, BadDataFormatException, FODBException |
Open an existing collection. | |
Protected Attributes | |
CollectionManager | colManager |
Static Protected Attributes | |
static final int | ACTION_CREATE = 0 |
static final int | ACTION_OPEN = 1 |
org.openmobileis.database.fastobjectdb.FastObjectDB.FastObjectDB | ( | String | dbRootDir, | |
String | dbName, | |||
FODBMainFile | fmf, | |||
int | action | |||
) | throws BadDataFormatException, FODBException [protected] |
The Constructor.
It is private, it is called by local methods create and open
dbRootDir | - database root directory | |
dbName | - database name. | |
fmf | - database main file. | |
action | - ACTION_CREATE or ACTION_OPEN |
BadDataFormatException | ||
FODBException |
Definition at line 94 of file FastObjectDB.java.
References org.openmobileis.database.fastobjectdb.FastObjectDB.ACTION_OPEN, org.openmobileis.database.fastobjectdb.FastObjectDB.colManager, org.openmobileis.database.fastobjectdb.db.store.FODBMainFile.getCollectionsList(), and org.openmobileis.database.fastobjectdb.FastObjectDB.openCollection().
Referenced by org.openmobileis.database.fastobjectdb.FastObjectDB.open().
static FastObjectDB org.openmobileis.database.fastobjectdb.FastObjectDB.open | ( | String | dbRootDir, | |
String | dbName | |||
) | throws IOException, ClassNotFoundException, BadDataFormatException, FODBException [static] |
The function is called to open a database.
If the database does not exist, It's created.
dbRootDir | - database directory | |
dbName | - database name |
IOException | ||
ClassNotFoundException | ||
BadDataFormatException | ||
FODBException |
Reimplemented in org.openmobileis.database.fastobjectdb.synchro.client.SynchroFastObjectDB.
Definition at line 128 of file FastObjectDB.java.
References org.openmobileis.database.fastobjectdb.FastObjectDB.ACTION_CREATE, org.openmobileis.database.fastobjectdb.FastObjectDB.ACTION_OPEN, and org.openmobileis.database.fastobjectdb.FastObjectDB.FastObjectDB().
Referenced by org.openmobileis.database.fastobjectdb.synchro.client.SynchroFastObjectDBManager.getCurrentFODB(), org.openmobileis.database.fastobjectdb.FastObjectDBManager.getCurrentFODB(), and org.openmobileis.database.fastobjectdb.db.test.TestFastObjectDB.openDB().
boolean org.openmobileis.database.fastobjectdb.FastObjectDB.createCollection | ( | FODBCollectionDescriptor | descriptor | ) | throws IOException, ClassNotFoundException, BadDataFormatException, FODBException |
Add a new collection to the database.
collectionName | - name of the new colletion | |
objectType | - type of objects stored in this collection. | |
synchro | - if set to false the collection wont be synchronized when FODB is in synchro mode. |
IOException | ||
ClassNotFoundException | ||
BadDataFormatException | ||
FODBException |
Reimplemented in org.openmobileis.database.fastobjectdb.synchro.client.SynchroFastObjectDB.
Definition at line 177 of file FastObjectDB.java.
References org.openmobileis.database.fastobjectdb.db.store.FODBMainFile.addCollection(), org.openmobileis.database.fastobjectdb.db.CollectionManager.addCollection(), org.openmobileis.database.fastobjectdb.FastObjectDB.colManager, org.openmobileis.database.fastobjectdb.db.FODBCollection.createCollection(), and org.openmobileis.database.fastobjectdb.db.CollectionManager.getCollectionByName().
Referenced by org.openmobileis.synchro.journal.JournalQueryManager.createJournalTable(), org.openmobileis.modules.common.history.FODBHistoryManager.FODBHistoryManager(), org.openmobileis.modules.common.database.fodb.FODBLabelFactory.FODBLabelFactory(), org.openmobileis.modules.common.database.fodb.FODBTerminalUserFactory.FODBTerminalUserFactory(), org.openmobileis.database.fastobjectdb.synchro.client.FODBSyncActionDBQueryManager.initDB(), org.openmobileis.database.fastobjectdb.db.test.TestFastObjectDB.openDB(), org.openmobileis.test.database.TestFODBSynchro.setUp(), and org.openmobileis.database.fastobjectdb.db.test.TestFastObjectDB.testDBSearch().
boolean org.openmobileis.database.fastobjectdb.FastObjectDB.createCollection | ( | String | collectionName, | |
Class | objectType | |||
) | throws IOException, ClassNotFoundException, BadDataFormatException, FODBException |
Add a new collection to the database.
the synchro parameter is set to true.
collectionName | - name of the new colletion | |
objectType | - type of objects stored in this collection. |
IOException | ||
ClassNotFoundException | ||
BadDataFormatException | ||
FODBDataFileException | ||
FODBCollectionException |
Reimplemented in org.openmobileis.database.fastobjectdb.synchro.client.SynchroFastObjectDB.
Definition at line 202 of file FastObjectDB.java.
boolean org.openmobileis.database.fastobjectdb.FastObjectDB.openCollection | ( | String | collectionName | ) | throws IOException, ClassNotFoundException, BadDataFormatException, FODBException [protected] |
Open an existing collection.
This is not used and should be suppressed.
collectionName | - name of the collection |
IOException | ||
ClassNotFoundException | ||
BadDataFormatException | ||
FODBException |
Reimplemented in org.openmobileis.database.fastobjectdb.synchro.client.SynchroFastObjectDB.
Definition at line 217 of file FastObjectDB.java.
References org.openmobileis.database.fastobjectdb.db.CollectionManager.addCollection(), org.openmobileis.database.fastobjectdb.FastObjectDB.colManager, org.openmobileis.database.fastobjectdb.db.CollectionManager.getCollectionByName(), and org.openmobileis.database.fastobjectdb.db.FODBCollection.openCollection().
Referenced by org.openmobileis.database.fastobjectdb.FastObjectDB.FastObjectDB().
boolean org.openmobileis.database.fastobjectdb.FastObjectDB.addIndex | ( | String | colName, | |
FODBIndexDescriptor | descriptor | |||
) | throws BadDataFormatException, FODBException |
Add an index to a Collection of the Database.
colName | - name of the Collection | |
descriptor | - descriptor representing the index to add. |
BadDataFormatException | ||
FODBException |
Definition at line 256 of file FastObjectDB.java.
References org.openmobileis.database.fastobjectdb.db.FODBCollection.addIndex(), org.openmobileis.database.fastobjectdb.FastObjectDB.colManager, org.openmobileis.database.fastobjectdb.db.CollectionManager.getCollectionByName(), and org.openmobileis.database.fastobjectdb.db.FODBCollection.getName().
Referenced by org.openmobileis.synchro.journal.JournalQueryManager.createJournalTable(), org.openmobileis.modules.common.history.FODBHistoryManager.FODBHistoryManager(), org.openmobileis.modules.common.database.fodb.FODBLabelFactory.FODBLabelFactory(), org.openmobileis.modules.common.database.fodb.FODBTerminalUserFactory.FODBTerminalUserFactory(), org.openmobileis.database.fastobjectdb.synchro.client.FODBSyncActionDBQueryManager.initDB(), org.openmobileis.database.fastobjectdb.db.test.TestFastObjectDB.openDB(), org.openmobileis.test.database.TestFODBSynchro.setUp(), and org.openmobileis.database.fastobjectdb.db.test.TestFastObjectDB.testDBSearch().
boolean org.openmobileis.database.fastobjectdb.FastObjectDB.add | ( | String | colName, | |
Object | obj | |||
) | throws FODBException |
Add an element to a Collection of the database.
colName | - Name of the collection | |
obj | - object to add. |
FODBException |
Reimplemented in org.openmobileis.database.fastobjectdb.synchro.client.SynchroFastObjectDB.
Definition at line 273 of file FastObjectDB.java.
References org.openmobileis.database.fastobjectdb.db.FODBCollection.addElement(), org.openmobileis.database.fastobjectdb.FastObjectDB.colManager, org.openmobileis.database.fastobjectdb.db.CollectionManager.getCollectionByName(), and org.openmobileis.database.fastobjectdb.db.FODBCollection.getName().
Referenced by org.openmobileis.modules.common.database.fodb.FODBLabelFactory.storeLabel(), org.openmobileis.database.fastobjectdb.db.test.TestFastObjectDB.testDataWithArray(), org.openmobileis.database.fastobjectdb.db.test.TestFastObjectDB.TestDBAndIndex(), org.openmobileis.database.fastobjectdb.db.test.TestFastObjectDB.testDBSearch(), and org.openmobileis.database.fastobjectdb.db.test.TestFastObjectDB.testMultithread().
boolean org.openmobileis.database.fastobjectdb.FastObjectDB.replace | ( | String | colName, | |
Object | obj | |||
) | throws FODBException |
Replace an existing element in a Collection of the database.
colName | - Name of the Collection | |
obj | - Object to replace. |
FODBException |
Reimplemented in org.openmobileis.database.fastobjectdb.synchro.client.SynchroFastObjectDB.
Definition at line 291 of file FastObjectDB.java.
References org.openmobileis.database.fastobjectdb.FastObjectDB.colManager, org.openmobileis.database.fastobjectdb.db.CollectionManager.getCollectionByName(), org.openmobileis.database.fastobjectdb.db.FODBCollection.getName(), and org.openmobileis.database.fastobjectdb.db.FODBCollection.replaceElement().
Referenced by org.openmobileis.modules.common.database.fodb.FODBLabelFactory.storeLabel().
Query org.openmobileis.database.fastobjectdb.FastObjectDB.query | ( | ) |
use to get base class to query FODB.
The FODB query API use the SODA API (http://http://odbms.org/soda) as a base API. From Soda specification the differences are : * only query on FODB collection : use query.constrain(MyCollectionObject.class) to declare it. * only query using index. use query.descend("IndexedFieldName") to specify an index.
Exemple of use: Data class :TestSearchData class signature public final class TestSearchData implements Serializable { public int getKey(); public int getDizaine(); }
FODB creation : db = FastObjectDB.open(dbdir, "testdb"); if (!FODBCollection.isCollectionExist(db, "TESTSEARCH")) { // if not created create it. db.createCollection("TESTSEARCH", TestSearchData.class); FODBUniqueIntIndexDescriptor KeyDescriptor = new FODBUniqueIntIndexDescriptor("KEY", "getKey()", 5); db.addIndex("TESTSEARCH", KeyDescriptor); FODBMultipleIntIndexDescriptor debKeyDescriptor = new FODBMultipleIntIndexDescriptor("DIZ", "getDizaine()", 5, 5); db.addIndex("TESTSEARCH", debKeyDescriptor); }
The collection TestData where keys are in the interval [0..30]. for (int i=0; i<NB_SEARCH_CREATED_DATA; i++) { db.add("TESTSEARCH", new TestSearchData(i)); }
Exemple of query :
//query SELECT * FROM TESTSEARCH Query q = db.query(); q.constrain(TestSearchData.class); Query subq = q.descend("getKey()"); //specify an index to request. ObjectSet set = q.execute();
//query SELECT * FROM TESTSEARCH where getKey<14 q = db.query(); q.constrain(TestSearchData.class); subq = q.descend("getKey()"); subq.constrain(new Integer(14)).smaller(); set = q.execute();
//query SELECT * FROM TESTSEARCH where getKey>16 AND getKey<23 q = db.query(); q.constrain(TestSearchData.class); subq = q.descend("getKey()"); Constraint c = subq.constrain(new Integer(16)).greater(); Constraint d = subq.constrain(new Integer(23)).smaller(); c.and(d); set = q.execute();
//query SELECT * FROM TESTSEARCH where getKey>16 AND getDizaine=2 q = db.query(); q.constrain(TestSearchData.class); subq = q.descend("getKey()"); c = subq.constrain(new Integer(16)).greater(); Query subq2 = subq.descend("getDizaine()"); d = subq2.constrain(new Integer(2)).equal(); c.and(d); set = q.execute();
Definition at line 380 of file FastObjectDB.java.
References org.openmobileis.database.fastobjectdb.FastObjectDB.colManager.
Referenced by org.openmobileis.database.fastobjectdb.db.test.TestThreadRequest2.run(), org.openmobileis.database.fastobjectdb.db.test.TestThreadRequest.run(), org.openmobileis.database.fastobjectdb.db.test.TestFastObjectDB.testDataWithArray(), org.openmobileis.database.fastobjectdb.db.test.TestFastObjectDB.testDBSearch(), org.openmobileis.database.fastobjectdb.db.test.TestFastObjectDB.testFindLike(), org.openmobileis.database.fastobjectdb.db.test.TestFastObjectDB.testMultipleIndex(), org.openmobileis.database.fastobjectdb.db.test.TestFastObjectDB.testRomvedTree(), and org.openmobileis.database.fastobjectdb.db.test.TestFastObjectDB.testTree().
boolean org.openmobileis.database.fastobjectdb.FastObjectDB.delete | ( | String | colName, | |
Object | obj | |||
) | throws FODBException |
Delete an element of a Collection.
colName | - name of the Collection. | |
obj | - object to delete. |
FODBException |
Reimplemented in org.openmobileis.database.fastobjectdb.synchro.client.SynchroFastObjectDB.
Definition at line 392 of file FastObjectDB.java.
References org.openmobileis.database.fastobjectdb.FastObjectDB.colManager, org.openmobileis.database.fastobjectdb.db.FODBCollection.deleteSingleElement(), org.openmobileis.database.fastobjectdb.db.CollectionManager.getCollectionByName(), and org.openmobileis.database.fastobjectdb.db.FODBCollection.getName().
Referenced by org.openmobileis.database.fastobjectdb.db.test.TestFastObjectDB.testDBSearch().
boolean org.openmobileis.database.fastobjectdb.FastObjectDB.deleteWithId | ( | String | colName, | |
Object | id | |||
) | throws FODBException |
Delete an object of a Collection with its id.
colName | - name of the Collection. | |
id | - id of the object to delete. |
FODBException |
Reimplemented in org.openmobileis.database.fastobjectdb.synchro.client.SynchroFastObjectDB.
Definition at line 411 of file FastObjectDB.java.
References org.openmobileis.database.fastobjectdb.FastObjectDB.colManager, org.openmobileis.database.fastobjectdb.db.FODBCollection.deleteObjectWithId(), org.openmobileis.database.fastobjectdb.db.CollectionManager.getCollectionByName(), and org.openmobileis.database.fastobjectdb.db.FODBCollection.getName().
Referenced by org.openmobileis.examples.simpleappli.data.FODB.FODBBaseDataFactory.deleteBaseData(), org.openmobileis.modules.common.database.fodb.FODBLabelFactory.deleteLabel(), and org.openmobileis.database.fastobjectdb.db.test.TestFastObjectDB.testDataWithArray().