org.objectweb.medor.optim.lib
Class PushSelectionRule

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

public class PushSelectionRule
extends BasicRule

This class represents the rule to push selections down a QueryTree.


Nested Class Summary
 class PushSelectionRule.SameQT
           
 
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
PushSelectionRule()
           
 
Method Summary
 BasicRule.ModifiedExpression extractMapFromExpression(Expression e, java.util.Map qt2e, int op)
          This methods does two things.
 BasicRule.ModifiedExpression goDownFieldOperand(Expression e)
           
 PushSelectionRule.SameQT isSameQT(Expression e)
          It evaluates if inside an expression all QueryTreeField referenced in FieldOperands come from the same QueryTree.
 BasicRule.ModifiedExpression merge(Expression origin, Expression addExp, int op)
          It merges an source expresion with an additional expression.
 QueryTree rewrite(QueryTree qt, QueryNode parent)
          This method applies a single rule.
protected  void rewriteExp(QueryTree qt, Expression addedExp)
           
 
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

PushSelectionRule

public PushSelectionRule()
Method Detail

rewrite

public QueryTree rewrite(QueryTree qt,
                         QueryNode parent)
                  throws MedorException
Description copied from interface: RewriteRule
This method applies a single rule.

It is typically called by the QueryRewriter for applying the entire rewriting process.

Parameters:
qt - the QueryTree to be rewritten
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

rewriteExp

protected void rewriteExp(QueryTree qt,
                          Expression addedExp)
                   throws MedorException
Throws:
MedorException

merge

public BasicRule.ModifiedExpression merge(Expression origin,
                                          Expression addExp,
                                          int op)
It merges an source expresion with an additional expression.

Parameters:
origin - is the source expression
addExp - is the additionnal expression which will be merge with the source.
Returns:
a ModifiedExpression instance. The 'isModified' field indicates if the source expression has been modified ou replaced. The 'e' field references the result of the merge.

extractMapFromExpression

public BasicRule.ModifiedExpression extractMapFromExpression(Expression e,
                                                             java.util.Map qt2e,
                                                             int op)
                                                      throws MedorException
This methods does two things. It extracts the expressions which can be moved to a QueryTree child. The extracted expression are grouped by QueryTree child in the Map parameter.

Parameters:
e - is the expression in which sub expression could be extracted
qt2e - is a map result parameter which must be fill with the the extractable sub expressions.
Returns:
a modifiedExpression instance. The 'isModified' field indicates if the source expression has been modified ou replaced. The 'e' field references the rest of the expression.
Throws:
MedorException

isSameQT

public PushSelectionRule.SameQT isSameQT(Expression e)
                                  throws MedorException
It evaluates if inside an expression all QueryTreeField referenced in FieldOperands come from the same QueryTree.

Parameters:
e - is the expression in which the FieldOperand field will be searched
Returns:
a SameQt instance. The 'isSame' field indicates if in the given expression all Fields are linked to the same QueryTree. If 'isSame' is true, the 'qt' field is the QueryTree with which all fieldoperand of expression are linked.
Throws:
MedorException

goDownFieldOperand

public BasicRule.ModifiedExpression goDownFieldOperand(Expression e)
                                                throws MedorException
Throws:
MedorException