Main Page | Packages | Class Hierarchy | Class List | Directories | File List | Class Members | Related Pages

org.openmobileis.database.fastobjectdb.db.query.soda.FODBSodaQuery Class Reference

Inheritance diagram for org.openmobileis.database.fastobjectdb.db.query.soda.FODBSodaQuery:

org.odbms.Query List of all members.

Detailed Description

Base class to query FODB.

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();

See also:
org.odbms.Constraint

org.odbms.ObjectSet

org.odbms.Query

Author:
Philippe Delrieu
Since:
JDK 1.1
Version:
1.0.

Definition at line 117 of file FODBSodaQuery.java.

Public Member Functions

 FODBSodaQuery (CollectionManager colManager, FastObjectDB db)
Constraint constrain (Object constraint)
 adds a constraint to this node.
Constraints constraints ()
 returns a Constraints object that holds an array of all constraints on this node.
ObjectSet execute ()
 executes the Query.
Query descend (String fieldName)
 returns a reference to a descendant node in the query graph.
Query orderAscending ()
 adds an ascending ordering criteria to this node of the query graph.
Query orderDescending ()
 adds a descending order criteria to this node of the query graph.

Package Functions

Constraint or (Constraint with)
void setCollection (FODBCollection collection)
void setFirstConstraint (FODBSodaConstraint constraint)
FODBSodaConstraint getFirstConstraint ()


Member Function Documentation

Constraint org.openmobileis.database.fastobjectdb.db.query.soda.FODBSodaQuery.constrain Object  constraint  ) 
 

adds a constraint to this node.



If the constraint contains attributes that are not yet present in the query graph, the query graph is extended accordingly.

Special behaviour for:

  • class : confine the result to objects of one class (if the Class object represents a class) or to objects implementing a specific interface (if the Class object represents an interface).
  • interface Evaluation: run evaluation callbacks against all candidates.
Parameters:
constraint the constraint to be added to this Query.
Returns:
Constraint a new Constraint for this query node or null for objects implementing the Evaluation interface.

Implements org.odbms.Query.

Definition at line 137 of file FODBSodaQuery.java.

References org.openmobileis.database.fastobjectdb.db.CollectionManager.getCollectionByName(), org.openmobileis.database.fastobjectdb.db.CollectionManager.getCollectionByType(), org.openmobileis.database.fastobjectdb.db.FODBCollection.getIndexByMember(), org.openmobileis.database.fastobjectdb.db.query.soda.FODBSodaConstraint.getIndexMember(), org.openmobileis.database.fastobjectdb.db.query.soda.FODBSodaConstraint.hasOperande, org.openmobileis.database.fastobjectdb.db.query.soda.FODBSodaConstraint.setIndex(), and org.openmobileis.database.fastobjectdb.db.query.soda.FODBSodaConstraint.setOperand().

Constraints org.openmobileis.database.fastobjectdb.db.query.soda.FODBSodaQuery.constraints  ) 
 

returns a Constraints object that holds an array of all constraints on this node.

Returns:
Constraints on this query node.

Implements org.odbms.Query.

Definition at line 175 of file FODBSodaQuery.java.

Query org.openmobileis.database.fastobjectdb.db.query.soda.FODBSodaQuery.descend String  fieldName  ) 
 

returns a reference to a descendant node in the query graph.



If the node does not exist, it will be created.

All classes represented in the query node are tested, whether they contain a field with the specified field name. The descendant Query node will be created from all possible candidate classes.

Parameters:
field path to the descendant.
Returns:
descendant Query node

Implements org.odbms.Query.

Definition at line 205 of file FODBSodaQuery.java.

References org.openmobileis.database.fastobjectdb.db.query.soda.FODBSodaQuery.FODBSodaQuery(), org.openmobileis.database.fastobjectdb.db.query.soda.FODBSodaQuery.getFirstConstraint(), org.openmobileis.database.fastobjectdb.db.FODBCollection.getIndexByMember(), org.openmobileis.database.fastobjectdb.db.query.soda.FODBSodaConstraint.hasIndex(), org.openmobileis.database.fastobjectdb.db.query.soda.FODBSodaQuery.setCollection(), org.openmobileis.database.fastobjectdb.db.query.soda.FODBSodaQuery.setError(), org.openmobileis.database.fastobjectdb.db.query.soda.FODBSodaQuery.setFirstConstraint(), and org.openmobileis.database.fastobjectdb.db.query.soda.FODBSodaConstraint.setIndex().

ObjectSet org.openmobileis.database.fastobjectdb.db.query.soda.FODBSodaQuery.execute  ) 
 

executes the Query.

Returns:
ObjectSet - the result of the Query.

Implements org.odbms.Query.

Definition at line 182 of file FODBSodaQuery.java.

References org.openmobileis.database.fastobjectdb.db.query.soda.FODBSodaObjectSet.addCollectionPtrs(), org.openmobileis.database.fastobjectdb.db.transaction.TransactionManager.begin(), org.openmobileis.database.fastobjectdb.db.transaction.TransactionManager.commit(), org.openmobileis.database.fastobjectdb.db.transaction.TransactionManager.enterTransaction(), org.openmobileis.database.fastobjectdb.db.query.soda.FODBSodaConstraint.execute(), org.openmobileis.database.fastobjectdb.db.FODBCollection.getName(), org.openmobileis.database.fastobjectdb.FastObjectDB.getTransactionManager(), and org.openmobileis.common.util.collection.LongArray.toArray().

Query org.openmobileis.database.fastobjectdb.db.query.soda.FODBSodaQuery.orderAscending  ) 
 

adds an ascending ordering criteria to this node of the query graph.

Multiple ordering criteria will be applied in the order they were called.

Returns:
this Query object to allow the chaining of method calls.

Implements org.odbms.Query.

Definition at line 240 of file FODBSodaQuery.java.

Query org.openmobileis.database.fastobjectdb.db.query.soda.FODBSodaQuery.orderDescending  ) 
 

adds a descending order criteria to this node of the query graph.

Multiple ordering criteria will be applied in the order they were called.

Returns:
this Query object to allow the chaining of method calls.

Implements org.odbms.Query.

Definition at line 248 of file FODBSodaQuery.java.

void org.openmobileis.database.fastobjectdb.db.query.soda.FODBSodaQuery.setCollection FODBCollection  collection  )  [package]
 

Parameters:
collection 

Definition at line 264 of file FODBSodaQuery.java.

Referenced by org.openmobileis.database.fastobjectdb.db.query.soda.FODBSodaQuery.descend().

void org.openmobileis.database.fastobjectdb.db.query.soda.FODBSodaQuery.setFirstConstraint FODBSodaConstraint  constraint  )  [package]
 

Parameters:
constraint 

Definition at line 271 of file FODBSodaQuery.java.

Referenced by org.openmobileis.database.fastobjectdb.db.query.soda.FODBSodaQuery.descend().


The documentation for this class was generated from the following file:
Generated on Wed Dec 14 21:05:38 2005 for OpenMobileIS by  doxygen 1.4.4