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

java.lang.Object
  extended byorg.openmobileis.database.fastobjectdb.db.query.soda.FODBSodaQuery
All Implemented Interfaces:
org.odbms.Query

public final class FODBSodaQuery
extends java.lang.Object
implements org.odbms.Query

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

Since:
JDK 1.1
Version:
1.0.
Author:
Philippe Delrieu
See Also:
Constraint, ObjectSet, Query

Constructor Summary
FODBSodaQuery(CollectionManager colManager, FastObjectDB db)
           
 
Method Summary
 org.odbms.Constraint constrain(java.lang.Object constraint)
          adds a constraint to this node.
 org.odbms.Constraints constraints()
          returns a Constraints object that holds an array of all constraints on this node.
 org.odbms.Query descend(java.lang.String fieldName)
          returns a reference to a descendant node in the query graph.
 org.odbms.ObjectSet execute()
          executes the Query.
 org.odbms.Query orderAscending()
          adds an ascending ordering criteria to this node of the query graph.
 org.odbms.Query orderDescending()
          adds a descending order criteria to this node of the query graph.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FODBSodaQuery

public FODBSodaQuery(CollectionManager colManager,
                     FastObjectDB db)
Method Detail

constrain

public org.odbms.Constraint constrain(java.lang.Object constraint)
Description copied from interface: org.odbms.Query
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.

Specified by:
constrain in interface org.odbms.Query
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.

constraints

public org.odbms.Constraints constraints()
Description copied from interface: org.odbms.Query
returns a Constraints object that holds an array of all constraints on this node.

Specified by:
constraints in interface org.odbms.Query
Returns:
Constraints on this query node.

execute

public org.odbms.ObjectSet execute()
Description copied from interface: org.odbms.Query
executes the Query.

Specified by:
execute in interface org.odbms.Query
Returns:
ObjectSet - the result of the Query.

descend

public org.odbms.Query descend(java.lang.String fieldName)
Description copied from interface: org.odbms.Query
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.

Specified by:
descend in interface org.odbms.Query
Returns:
descendant Query node

orderAscending

public org.odbms.Query orderAscending()
Description copied from interface: org.odbms.Query
adds an ascending ordering criteria to this node of the query graph. Multiple ordering criteria will be applied in the order they were called.

Specified by:
orderAscending in interface org.odbms.Query
Returns:
this Query object to allow the chaining of method calls.

orderDescending

public org.odbms.Query orderDescending()
Description copied from interface: org.odbms.Query
adds a descending order criteria to this node of the query graph. Multiple ordering criteria will be applied in the order they were called.

Specified by:
orderDescending in interface org.odbms.Query
Returns:
this Query object to allow the chaining of method calls.


Copyright 2005 e-Care. All Rights Reserved.