edu.wpi.cs.dsrg.xmldb.xat.component.sqlgeneration
Class QueryGenerator

java.lang.Object
  |
  +--edu.wpi.cs.dsrg.xmldb.xat.component.sqlgeneration.QueryGenerator

public class QueryGenerator
extends java.lang.Object

 IQueryGenerator is the primary class in Query Generation
 It is responsible for travering the XAT and finding operators to evaluate
 


Field Summary
protected static boolean debug
          the incremental statement to use
static int FULL
          full generation
static int MINIMAL
          minimal generation
protected  OperatorEvaluator opEval
          instance of the OperatorEvaluation
protected  IncrementalQuery qStmt
          the incremental statement to use
protected  XATTree queryTree
          the XAT to generate a query from
protected  int queryType
          the type of query to generate
protected static BindingTable variableTable
          binding BindingTable
 
Constructor Summary
QueryGenerator(BindingTable varTable)
          Start the generator.
QueryGenerator(BindingTable varTable, boolean deb)
          Start the generator.
 
Method Summary
protected  void addSQLOperator(XATOperator root)
          adds a new SQL operator as a child of root parameter
 void generateQuery(XATTree treeToGenerateSQL, int heuristic, int queryTypeIn)
          find an operator, using post order breadth first search call operator evaluator, then if take the resulting SQLFragment and add it to the SQLIncrementalStatement if the operator was evaluated
 BindingTable getVariableTable()
          Set the variable table
 void initialize(int heuristic, int queryType)
           
protected  boolean processOperator(XATOperator toProcess)
           processOperator will call evaluateOperator on the param operator then take the QueryResult object that was returned and will add the sql fragment to the incremental SQL statement if the operator was evaluated the toProcess operator will then be deleted from the tree
 void setVariableTable(BindingTable newVariableTable)
          Set the variable table
protected  void traverseTree(XATOperator root)
           Iterates over a tree starting at the root parameter traverses to the right child, then left child, then decides whether to evalutate this operator Once an operator's children have been examined, the operator is then processed and the result is added to sqlsmt.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

queryTree

protected XATTree queryTree
the XAT to generate a query from

FULL

public static final int FULL
full generation

MINIMAL

public static final int MINIMAL
minimal generation

variableTable

protected static BindingTable variableTable
binding BindingTable

opEval

protected OperatorEvaluator opEval
instance of the OperatorEvaluation

qStmt

protected IncrementalQuery qStmt
the incremental statement to use

debug

protected static boolean debug
the incremental statement to use

queryType

protected int queryType
the type of query to generate
Constructor Detail

QueryGenerator

public QueryGenerator(BindingTable varTable)
Start the generator.

QueryGenerator

public QueryGenerator(BindingTable varTable,
                      boolean deb)
Start the generator.
Method Detail

addSQLOperator

protected void addSQLOperator(XATOperator root)
adds a new SQL operator as a child of root parameter
Parameters:
root - the parent of the SQLOperator that will be created

generateQuery

public void generateQuery(XATTree treeToGenerateSQL,
                          int heuristic,
                          int queryTypeIn)
                   throws UnknownQueryType
find an operator, using post order breadth first search call operator evaluator, then if take the resulting SQLFragment and add it to the SQLIncrementalStatement if the operator was evaluated
Parameters:
treeToGenerateSQL - XATTree
heuristic - int
queryTypeIn - the type of query to generate

getVariableTable

public BindingTable getVariableTable()
Set the variable table
Parameters:
newVariableTable - BindingTable

initialize

public void initialize(int heuristic,
                       int queryType)
                throws UnknownQueryType

processOperator

protected boolean processOperator(XATOperator toProcess)
 processOperator will call evaluateOperator on the param operator
 then take the QueryResult object that was returned and will add the
 sql fragment to the incremental SQL statement if the operator was evaluated
 the toProcess operator will then be deleted from the tree
 
Returns:
boolean true if the operator was evaluated, false otherwise

setVariableTable

public void setVariableTable(BindingTable newVariableTable)
Set the variable table
Parameters:
newVariableTable - BindingTable

traverseTree

protected void traverseTree(XATOperator root)
  Iterates over a tree starting at the root parameter
  traverses to the right child, then left child, then decides whether to evalutate this operator
  Once an operator's children have been examined, the operator is then processed and the
  result is added to sqlsmt. An operator is deleted after it is processed
  If a Tagger or Aggregate operator is found, the incremental query is added to the 
 tree in addSQLOperator
 
sqlStmt is reset in case there are other operators
Parameters:
root - the root of the tree to traverse.