org.objectweb.medor.optim.lib
Class PushNotInExpressionRule
java.lang.Object
org.objectweb.medor.optim.lib.BasicRule
org.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:
- !(a && b) is replaced by (!a || !b)
- !(a > b) is replaced by (a <= b)
- !(a = b) is replaced by (a != b)
- !(a & !b) is replaced by (!a || b)
- !(!(a)) is replaced by a
- Author:
- S. Chassande-Barrioz
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
PushNotInExpressionRule
public PushNotInExpressionRule()
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
pushedhasANot
- is boolean which indicates if a not is currently being
push
- Throws:
MedorException
- if the expression is mal formed.