org.objectweb.medor.optim.lib
Class DropUselessNodeRule

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

public class DropUselessNodeRule
extends BasicRule

This rule removes the query node which are useless.

A node is useless when it does not have any filter and all fields are propagated fields which have only one ancestor.

Author:
S. Chassande-Barrioz

Nested Class Summary
 class DropUselessNodeRule.UsedFields
           
 
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
DropUselessNodeRule()
           
 
Method Summary
protected  DropUselessNodeRule.UsedFields isUseless(QueryTree qt)
           
protected  Field replaceField(QueryTreeField qtf, java.util.Map map)
           
protected  boolean replaceInFilter(Expression e, java.util.Map map)
           
 QueryTree rewrite(QueryTree qt, QueryNode _parent)
          This method applies a single rule.
 
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

DropUselessNodeRule

public DropUselessNodeRule()
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

isUseless

protected DropUselessNodeRule.UsedFields isUseless(QueryTree qt)
                                            throws MedorException
Throws:
MedorException

replaceInFilter

protected boolean replaceInFilter(Expression e,
                                  java.util.Map map)
                           throws MedorException
Throws:
MedorException

replaceField

protected Field replaceField(QueryTreeField qtf,
                             java.util.Map map)
                      throws MedorException
Throws:
MedorException