org.objectweb.medor.optim.lib
Class QueryNodeReplacer

java.lang.Object
  extended byorg.objectweb.medor.optim.lib.QueryNodeReplacer

public class QueryNodeReplacer
extends java.lang.Object

This class is an helper class for managing the replacement of a QueryTree in a medor query represented by another QueryTree.

Author:
S.Chassande-Barrioz

Constructor Summary
QueryNodeReplacer()
           
 
Method Summary
 void replaceFields(Field[] oldFields, Field[] neoFields, Expression exp)
          Replace the references to old field by references to new fields in an expression (Recusrive method).
 QueryTree replaceNode(QueryTree old, QueryTree neo, QueryTree root)
          Replace a QueryTree by another.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

QueryNodeReplacer

public QueryNodeReplacer()
Method Detail

replaceNode

public QueryTree replaceNode(QueryTree old,
                             QueryTree neo,
                             QueryTree root)
Replace a QueryTree by another. this is doing by replacing the usage of its field in all tree.

Parameters:
old - is the node to replace
neo - is the new node replacing the old
root - is the QueryTree from the search must start.
Returns:
if the root queryTree is the one searched, then the newer is returned, otherwise the root QueryTree is returned.

replaceFields

public void replaceFields(Field[] oldFields,
                          Field[] neoFields,
                          Expression exp)
Replace the references to old field by references to new fields in an expression (Recusrive method).

Parameters:
oldFields - the list of old field to replace
neoFields - the list of new field replacing the old
exp - is the current medor expression to treat.