org.tm4j.tolog
Class QueryEvaluator

java.lang.Object
  extended byorg.tm4j.tolog.QueryEvaluator

Deprecated. from 0.9.5 use the package org.tm4j.tologx

public class QueryEvaluator
extends java.lang.Object


Nested Class Summary
protected  class QueryEvaluator.ExpansionInfo
          Deprecated.  
protected  class QueryEvaluator.ListTable
          Deprecated.  
 
Constructor Summary
QueryEvaluator(TopicMap tm)
          Deprecated. Creates a new QueryEvaluator to evaluate Tolog queries over the topic map tm
 
Method Summary
 void addRule(java.lang.String ruleString)
          Deprecated.  
protected  void addRules(org.tm4j.tolog.parser.ASTScript script)
          Deprecated.  
protected  void dumpMatches(java.util.List matches)
          Deprecated.  
protected  void dumpVars(java.util.Hashtable vars, java.lang.String prefix)
          Deprecated.  
 TologResultsSet evaluate(java.lang.String queryString)
          Deprecated. Performs the evaluation of the query queryString.
protected  QueryEvaluator.ExpansionInfo expand(org.tm4j.tolog.parser.ASTClause clause)
          Deprecated.  
protected  org.tm4j.tolog.parser.ASTClauseList expand(org.tm4j.tolog.parser.ASTClauseList clauseList)
          Deprecated.  
protected  java.lang.String getExpandPrefix()
          Deprecated.  
protected  void getMatches(org.tm4j.tolog.parser.ASTAlternates alternates, java.util.Hashtable vars, java.util.List matches)
          Deprecated. Processes the alternatives construct represented by alt using the variable binding specified by vars.
protected  void getMatches(org.tm4j.tolog.parser.ASTClauseList clauseList, java.util.List matches)
          Deprecated.  
protected  boolean getMatches(org.tm4j.tolog.parser.ASTParameterList params, java.util.List prPairs, java.util.Hashtable vars, java.util.List matches)
          Deprecated.  
protected  void getMatches(java.util.List clauses, int clauseIx, java.util.Hashtable vars, java.util.List matches)
          Deprecated.  
protected  boolean getMatches(java.util.List params, int paramIx, java.util.List prPairs, java.util.Hashtable vars, java.util.List matches)
          Deprecated.  
protected  java.util.List getPlayerRolePairs(Association a)
          Deprecated.  
protected  boolean invokeExtension(java.lang.Class extCls, org.tm4j.tolog.parser.ASTParameterList params, java.util.Hashtable vars, java.util.List matches)
          Deprecated.  
protected  boolean invokeExtensionTest(java.lang.Class extCls, org.tm4j.tolog.parser.ASTParameterList params, java.util.Hashtable vars)
          Deprecated. Invokes the extension class extCls to test the extension predicate under the set of bound variables specified in vars
 void loadRules(java.lang.String fileName)
          Deprecated.  
protected  java.util.List optimiseClauseList(org.tm4j.tolog.parser.ASTClauseList clauseList)
          Deprecated. Optimises the contents of the clause list.
protected  java.util.List optimiseParams(org.tm4j.tolog.parser.ASTParameterList params, java.util.Hashtable vars)
          Deprecated. Alters the ordering of params so that all facts (parameters with no variables) occur at the start of the list.
protected  void populateReplacementVariablesFromExpandedClause(org.tm4j.tolog.parser.ASTParameterList params, org.tm4j.tolog.parser.ASTClause repHead, java.lang.String repPrefix, java.util.Map replacementVars)
          Deprecated. Processes the specified clause to map any bound variables in the clause to the new replacement variable name.
protected  org.tm4j.tolog.TologResultsSetImpl projectAllResults(java.util.List results)
          Deprecated. Creates a results set in which all variables in the original query are mapped to columns in the results set.
protected  org.tm4j.tolog.TologResultsSetImpl projectResults(java.util.List results, org.tm4j.tolog.parser.ASTProjection projection)
          Deprecated.  
protected  void pruneInternal(java.util.List matches)
          Deprecated.  
 void registerExtension(java.lang.String predicate, java.lang.Class implCls)
          Deprecated. Registers a new extension predicate with the query engine.
 void setSortComparator(java.util.Comparator comp)
          Deprecated. Registers a sort order comparator with the query engine.
protected static java.lang.String shortAddress(Topic t)
          Deprecated.  
protected  void sortResults(org.tm4j.tolog.TologResultsSetImpl results, org.tm4j.tolog.parser.ASTSort sort)
          Deprecated.  
protected  boolean test(org.tm4j.tolog.parser.ASTClause clause, java.util.Hashtable vars)
          Deprecated.  
protected  boolean testMatches(org.tm4j.tolog.parser.ASTParameterList params, java.util.List prPairs, java.util.Hashtable vars)
          Deprecated. Tests the parameters in params against the bound variables in vars.
protected  void testMatches(java.util.List clauses, int clauseIx, java.util.Hashtable vars, java.util.List matches)
          Deprecated. Implementation of not() processing.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

QueryEvaluator

public QueryEvaluator(TopicMap tm)
               throws IndexManagerException,
                      IndexException
Deprecated. 
Creates a new QueryEvaluator to evaluate Tolog queries over the topic map tm

Parameters:
tm - The topic map to be queried.
Throws:
IndexManagerException - If a problem was encountered in retrieving the AssociationTypesIndex of tm
IndexException - If a problem was encountered while opening the AssociationTypesIndex of tm
Method Detail

getExpandPrefix

protected java.lang.String getExpandPrefix()
Deprecated. 

registerExtension

public void registerExtension(java.lang.String predicate,
                              java.lang.Class implCls)
                       throws java.lang.IllegalArgumentException
Deprecated. 
Registers a new extension predicate with the query engine. For details of extension predicates, see the documentation of the Extension inteface.

Parameters:
predicate - The predicate which the extension implements.
implCls - The class providing the implementation. This class must implement the Extension interface.
Throws:
java.lang.IllegalArgumentException - If implCls is not a class implementing the Extension interface.

setSortComparator

public void setSortComparator(java.util.Comparator comp)
Deprecated. 
Registers a sort order comparator with the query engine. The comparator comp will be used to determine the sort order of results for queries which include an "order by" clause.


evaluate

public TologResultsSet evaluate(java.lang.String queryString)
                         throws TologParserException,
                                TologEvaluationException
Deprecated. 
Performs the evaluation of the query queryString.

Parameters:
queryString - The tolog query to be evaluated.
Returns:
A TologResultsSet for the query evaluation
Throws:
TologParserException - if the query is not syntactically correct.
TologEvaluationException - if the query is syntactically correct but cannot be evaluated for some other reason.

projectAllResults

protected org.tm4j.tolog.TologResultsSetImpl projectAllResults(java.util.List results)
Deprecated. 
Creates a results set in which all variables in the original query are mapped to columns in the results set.

Parameters:
results - The list of matches to be processed into a results set
Returns:
A TologResultsSet containing the mapped results.

projectResults

protected org.tm4j.tolog.TologResultsSetImpl projectResults(java.util.List results,
                                                            org.tm4j.tolog.parser.ASTProjection projection)
Deprecated. 

sortResults

protected void sortResults(org.tm4j.tolog.TologResultsSetImpl results,
                           org.tm4j.tolog.parser.ASTSort sort)
Deprecated. 

pruneInternal

protected void pruneInternal(java.util.List matches)
Deprecated. 

getMatches

protected void getMatches(org.tm4j.tolog.parser.ASTClauseList clauseList,
                          java.util.List matches)
                   throws TologEvaluationException
Deprecated. 
Throws:
TologEvaluationException

expand

protected org.tm4j.tolog.parser.ASTClauseList expand(org.tm4j.tolog.parser.ASTClauseList clauseList)
Deprecated. 

expand

protected QueryEvaluator.ExpansionInfo expand(org.tm4j.tolog.parser.ASTClause clause)
Deprecated. 

populateReplacementVariablesFromExpandedClause

protected void populateReplacementVariablesFromExpandedClause(org.tm4j.tolog.parser.ASTParameterList params,
                                                              org.tm4j.tolog.parser.ASTClause repHead,
                                                              java.lang.String repPrefix,
                                                              java.util.Map replacementVars)
Deprecated. 
Processes the specified clause to map any bound variables in the clause to the new replacement variable name.

Parameters:
params - the parameter list from the clause being expanded
repHead - the head clause of the replacement expansion
repPrefix - the prefix used to generate a replacement variable name from an existing variable name
replacementVars - the replacement variable map - this is updated in-place by this method.

optimiseClauseList

protected java.util.List optimiseClauseList(org.tm4j.tolog.parser.ASTClauseList clauseList)
Deprecated. 
Optimises the contents of the clause list. This implementation simply moves equality tests to the end of the list.


getMatches

protected void getMatches(java.util.List clauses,
                          int clauseIx,
                          java.util.Hashtable vars,
                          java.util.List matches)
                   throws TologEvaluationException
Deprecated. 
Throws:
TologEvaluationException

getMatches

protected void getMatches(org.tm4j.tolog.parser.ASTAlternates alternates,
                          java.util.Hashtable vars,
                          java.util.List matches)
                   throws TologEvaluationException
Deprecated. 
Processes the alternatives construct represented by alt using the variable binding specified by vars. Each alternate clause list in alternates is processed inidividually and all of the matches added to the output variable matches

Throws:
TologEvaluationException

testMatches

protected void testMatches(java.util.List clauses,
                           int clauseIx,
                           java.util.Hashtable vars,
                           java.util.List matches)
                    throws TologEvaluationException
Deprecated. 
Implementation of not() processing. Tests the bound variables in vars against the list of child clauses contained in the not(). If one of these child clauses evaluates to true, then the test returns If none of the child clauses evaluates to true then a recursive call is made into getMatches()

Throws:
TologEvaluationException

test

protected boolean test(org.tm4j.tolog.parser.ASTClause clause,
                       java.util.Hashtable vars)
                throws TologEvaluationException
Deprecated. 
Throws:
TologEvaluationException

dumpMatches

protected void dumpMatches(java.util.List matches)
Deprecated. 

dumpVars

protected void dumpVars(java.util.Hashtable vars,
                        java.lang.String prefix)
Deprecated. 

getMatches

protected boolean getMatches(org.tm4j.tolog.parser.ASTParameterList params,
                             java.util.List prPairs,
                             java.util.Hashtable vars,
                             java.util.List matches)
                      throws TologEvaluationException
Deprecated. 
Throws:
TologEvaluationException

getMatches

protected boolean getMatches(java.util.List params,
                             int paramIx,
                             java.util.List prPairs,
                             java.util.Hashtable vars,
                             java.util.List matches)
Deprecated. 

testMatches

protected boolean testMatches(org.tm4j.tolog.parser.ASTParameterList params,
                              java.util.List prPairs,
                              java.util.Hashtable vars)
                       throws TologEvaluationException
Deprecated. 
Tests the parameters in params against the bound variables in vars. Returns true if all of the parameters have one or more matches in prPairs under the variable set vars. Returns false if there is no such match found.

Throws:
TologEvaluationException

optimiseParams

protected java.util.List optimiseParams(org.tm4j.tolog.parser.ASTParameterList params,
                                        java.util.Hashtable vars)
                                 throws TologEvaluationException
Deprecated. 
Alters the ordering of params so that all facts (parameters with no variables) occur at the start of the list. This method also replaces any variables with the assumed value specified in vars.

Parameters:
params - The ASTParameterList of the parsed query
vars - The assumed values for the variables so far
Returns:
A List of PlayerRole objects representing the parameters
Throws:
TologEvaluationException

getPlayerRolePairs

protected java.util.List getPlayerRolePairs(Association a)
Deprecated. 

shortAddress

protected static java.lang.String shortAddress(Topic t)
Deprecated. 

addRule

public void addRule(java.lang.String ruleString)
             throws org.tm4j.tolog.parser.ParseException
Deprecated. 
Throws:
org.tm4j.tolog.parser.ParseException

loadRules

public void loadRules(java.lang.String fileName)
               throws java.io.FileNotFoundException,
                      TologParserException
Deprecated. 
Throws:
java.io.FileNotFoundException
TologParserException

addRules

protected void addRules(org.tm4j.tolog.parser.ASTScript script)
Deprecated. 

invokeExtension

protected boolean invokeExtension(java.lang.Class extCls,
                                  org.tm4j.tolog.parser.ASTParameterList params,
                                  java.util.Hashtable vars,
                                  java.util.List matches)
                           throws TologEvaluationException
Deprecated. 
Throws:
TologEvaluationException

invokeExtensionTest

protected boolean invokeExtensionTest(java.lang.Class extCls,
                                      org.tm4j.tolog.parser.ASTParameterList params,
                                      java.util.Hashtable vars)
                               throws TologEvaluationException
Deprecated. 
Invokes the extension class extCls to test the extension predicate under the set of bound variables specified in vars

Returns:
true if the extension predicate evaluates to true under vars, false otherwise
Throws:
TologEvaluationException - If one or more variables in params are not bound under vars, or if the extension class can not be instantiated.