ter.API.AdvancedEngineSearch
Class AdvancedEngineSearch

java.lang.Object
  |
  +--ter.API.AdvancedEngineSearch.AdvancedEngineSearch

public class AdvancedEngineSearch
extends java.lang.Object

Title: AdvancedEngineSearch.

Description: This class gives an advanced Search. This search is based on a expression ( a string ). The expression has to be parse by a parser. The grammar is describe in the AdvSearchParser class documentation.

Copyright: Copyright (c) 2003

Company: UNICE

Version:
1.0
Author:
Zerbib Gabriel - Charbit Lucas - Galbois Xavier - Gahide Jérôme
See Also:
AdvSearchParser

Constructor Summary
AdvancedEngineSearch(ClassifierAnalyser classifier)
          Construct a new Advanced search with the classifier
AdvancedEngineSearch(Inspector inspector)
          Construct a new Advanced search with the inspector
 
Method Summary
 void addCriterion(Criterion c)
          Add a criterion to the search If a problem occur, the criterion is not added and a message is printed on std err.
 boolean checkCriterion(Criterion c)
          Check if the criterion c is present in the Advanced Search.
 boolean checkCriterion(java.lang.String criterionName)
          Check if the criterion name is present in the Advanced Search.
 boolean evaluateTree(Tree t, java.lang.reflect.Member m)
          this evaluate the tree t for a member m.
 java.util.Hashtable getCriterion()
          This HashTable represent the list of all criterion that are present in this advanced search.
 java.util.ArrayList search()
          This function execute the search on the classifier or on the inspector( it depends on the constructor call at the instanciation of this object.).
 void setClassifierAnalyser(ClassifierAnalyser ca)
          To change the classifier analyser if necessary.
 void setExpression(java.lang.String expr)
          Set the expression to parse.
 void setExpressionTree(Tree t)
          Set the Tree of expression for this advenced Search.
 void setInspector(Inspector inspector)
          To change the inspector if necessary
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AdvancedEngineSearch

public AdvancedEngineSearch(Inspector inspector)
Construct a new Advanced search with the inspector

Parameters:
inspector - the inspector to use for making some search.
See Also:
Inspector

AdvancedEngineSearch

public AdvancedEngineSearch(ClassifierAnalyser classifier)
Construct a new Advanced search with the classifier

Parameters:
classifier - the classifier to use for making some search.
See Also:
ClassifierAnalyser
Method Detail

setInspector

public void setInspector(Inspector inspector)
To change the inspector if necessary

Parameters:
inspector - the new inspector

setClassifierAnalyser

public void setClassifierAnalyser(ClassifierAnalyser ca)
To change the classifier analyser if necessary.

Parameters:
ca - the new classifier analyser

addCriterion

public void addCriterion(Criterion c)
Add a criterion to the search If a problem occur, the criterion is not added and a message is printed on std err.

Parameters:
c - the criterion to add.

getCriterion

public java.util.Hashtable getCriterion()
This HashTable represent the list of all criterion that are present in this advanced search.

Returns:
the Hashtable of the criterion.

checkCriterion

public boolean checkCriterion(Criterion c)
Check if the criterion c is present in the Advanced Search.

Parameters:
c - the criterion to check.
Returns:
true if the criterion is in the search

checkCriterion

public boolean checkCriterion(java.lang.String criterionName)
Check if the criterion name is present in the Advanced Search.

Parameters:
criterionName - the criterionName to check.
Returns:
true if the criterion is in the search

setExpressionTree

public void setExpressionTree(Tree t)
                       throws java.lang.Exception
Set the Tree of expression for this advenced Search. This procedure automaticaly check for some error in the tree. If the tree is not good sementicaly, an exception will be throw.

Parameters:
t - the tree to set.
Throws:
java.lang.Exception
See Also:
Tree

setExpression

public void setExpression(java.lang.String expr)
                   throws ParseException
Set the expression to parse. This procedure do the parsing of the String and assign the tree. if the String is not Valid, an analys execption is thrown. It also check if the tree is a Valid tree (sementicaly). If an error occur, an error message will be printed on the std err.

Parameters:
expr - the expression to parse.
Throws:
ParseException

evaluateTree

public boolean evaluateTree(Tree t,
                            java.lang.reflect.Member m)
                     throws java.lang.NullPointerException,
                            java.lang.Exception
this evaluate the tree t for a member m. This means that the function course the tree and make an evaluation of the member on each leaf. NB : the tree has to be lexicaly , syntaxly and sementically correct. NB : the evaluation tree is made for the grammar of parser. If the grammar change, this fundtion have also to change.

Parameters:
t - the expression tree.
m - the member to evaluate
Returns:
true if the member is ok with all the leaf( the criterion) else false.
Throws:
java.lang.NullPointerException
java.lang.Exception
See Also:
setExpressionTree, AdvSearchParser

search

public java.util.ArrayList search()
This function execute the search on the classifier or on the inspector( it depends on the constructor call at the instanciation of this object.).

Returns:
the ArrayList of Member that match with the search.