org.objectweb.medor.optim.lib
Class PushNotInExpressionRule

java.lang.Object
  extended byorg.objectweb.medor.optim.lib.BasicRule
      extended byorg.objectweb.medor.optim.lib.PushNotInExpressionRule
All Implemented Interfaces:
RewriteRule

public class PushNotInExpressionRule
extends BasicRule

This class is a RewriteRule implementation which vists a tree of QueryTree in order to push the not operator in the filters. In addition it removes useless not operators.

Somes examples:

Author:
S. Chassande-Barrioz

Nested Class Summary
 
Nested classes inherited from class org.objectweb.medor.optim.lib.BasicRule
BasicRule.ModifiedExpression
 
Field Summary
 
Fields inherited from class org.objectweb.medor.optim.lib.BasicRule
debug, log
 
Constructor Summary
PushNotInExpressionRule()
           
 
Method Summary
 BasicRule.ModifiedExpression pushNotInExpression(Expression e, boolean hasANot)
          This recursive method push the Not operator in an expression.
 QueryTree rewrite(QueryTree qt, QueryNode _parent)
          It modifies the expressions used as filter in a (tree of) QueryTree by pushing the not operator.
 
Methods inherited from class org.objectweb.medor.optim.lib.BasicRule
replaceUsage, rewrite
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PushNotInExpressionRule

public PushNotInExpressionRule()
Method Detail

rewrite

public QueryTree rewrite(QueryTree qt,
                         QueryNode _parent)
                  throws MedorException
It modifies the expressions used as filter in a (tree of) QueryTree by pushing the not operator. Somes examples: !(a && b) is replaced by (!a || !b) !(a > b) is replaced by (a <= b) !(a = b) is replaced by (a != b) ...

Parameters:
qt - is the query on which the rule must be applied
_parent - the parent QueryNode for which modification of propagated field, if they are replaced in the qt, should be done.
Returns:
the rewritten QueryTree
Throws:
MedorException - if filters are malforrmed

pushNotInExpression

public BasicRule.ModifiedExpression pushNotInExpression(Expression e,
                                                        boolean hasANot)
                                                 throws MedorException
This recursive method push the Not operator in an expression.

Parameters:
e - the current expression inside which the not operator must be pushed
hasANot - is boolean which indicates if a not is currently being push
Throws:
MedorException - if the expression is mal formed.