AROM-2_2_13

arom.kr.query.engine
Class AQEngine

java.lang.Object
  |
  +--arom.kr.query.engine.AQEngine

public class AQEngine
extends Object

A class that implements the query engine.
there are 3 main classes in the AROMQuery API :
AQCondition is used to build a query.
AQEngine is used to compile and execute a query.
AQResult is used to iterate over the results of a query.
example:

  // Construct query engine
  AQEngine engine = new AQEngine(kb);
  // build conditions and query path
  AQCondition n1 = new AQCondition("Teacher", "Salary > 2000");
  AQCondition n2 = new AQCondition("Teaches", "");
  AQCondition n3 = new AQCondition("Student", "not graduated");
  n1.add(n2, "teacher");
  n2.add(n3, "student");
  // compile and execute query
  engine.compile(n1);
  AQResult res = engine.query(node);
  // print result
  while (res.hasNext()) {
    Iterator path = (Iterator) res.next();
    while (path.hasNext()) {
      AMInstance o = (AMInstance) path.next();
      System.out.print("[" + o.toString() + "] ");
    }
    System.out.println(" *");
  }
 

Author:
Alain Viari

Constructor Summary
AQEngine(KnowledgeBase kb)
          Constructs a new AQEngine.
AQEngine(KnowledgeBase kb, arom.kr.query.util.InstancesCollections instancesCollections)
          Constructs a new AQEngine.
 
Method Summary
 void compile(AQCondition node)
          compile full query path.
 void compileNode(AQCondition node)
          compile single Condition Node
 KnowledgeBase getKb()
          get current knowledge base
 AQResult query(AQCondition node)
          execute query
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AQEngine

public AQEngine(KnowledgeBase kb,
                arom.kr.query.util.InstancesCollections instancesCollections)
         throws NullPointerException
Constructs a new AQEngine.


AQEngine

public AQEngine(KnowledgeBase kb)
         throws NullPointerException
Constructs a new AQEngine.

Method Detail

getKb

public KnowledgeBase getKb()
get current knowledge base

Returns:
The kb value

compileNode

public void compileNode(AQCondition node)
                 throws AQParserException,
                        AQStructureException,
                        AQInstancesCollectionsException
compile single Condition Node

Parameters:
node - a AQCondition to compile
Throws:
AQParserException - if parsing of algebraic expression failed
AQStructureException
AQInstancesCollectionsException

compile

public void compile(AQCondition node)
             throws AQParserException,
                    AQStructureException,
                    AQInstancesCollectionsException
compile full query path.

Parameters:
node - the root of query path to compile
Throws:
AQParserException - if parsing of algebraic expression failed
AQStructureException
AQInstancesCollectionsException

query

public AQResult query(AQCondition node)
               throws AQInstancesCollectionsException
execute query

Parameters:
node - the root of query path to execute
Returns:
AQResult
AQInstancesCollectionsException

AROM-2_2_13