org.objectweb.medor.optim.lib

Class 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

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.

Method Details

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.


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.