org.objectweb.medor.query.lib
Class BasicQueryNode

java.lang.Object
  extended byBasicCloneable
      extended byorg.objectweb.medor.lib.BasicTupleStructure
          extended byorg.objectweb.medor.query.lib.BasicQueryTree
              extended byorg.objectweb.medor.query.lib.BasicQueryNode
All Implemented Interfaces:
AnnotationsHolder, java.lang.Cloneable, Cloneable, FilteredQueryTree, QueryNode, QueryTree, java.io.Serializable, TupleStructure
Direct Known Subclasses:
Cartesian, Intersection, JoinProject, Nest, Project, SelectProject, Union, Unnest

public abstract class BasicQueryNode
extends BasicQueryTree
implements QueryNode

A BasicQueryNode is an implementation of QueryNode. It also implements QueryIndexGenerator and RWTupleStructure (it is its own TupleStructure).

Author:
Sebastien Chassande-Barrioz
See Also:
Serialized Form

Field Summary
protected  java.util.ArrayList children
           
protected  Expression filter
           
protected  int[] indexes
          Contains ranges of attribute to be projected from the tuple resulting of the concatenation of the tuples from the children QueryTrees.
protected  java.util.HashSet inner
           
protected  TupleLoader tupleLoader
           
 
Fields inherited from class org.objectweb.medor.query.lib.BasicQueryTree
annotations, distinct, name, orderfields
 
Fields inherited from class org.objectweb.medor.lib.BasicTupleStructure
fields, logger, name2field
 
Constructor Summary
BasicQueryNode()
           
BasicQueryNode(java.lang.String name)
           
 
Method Summary
 CalculatedField addCalculatedField(java.lang.String name, PType type, Expression exp)
          Creates and adds a CalculatedField to the TupleStructure of the QueryNode.
protected  void addChild(QueryTree qt)
           
protected  void addField(Field f)
          Adds a Field to the current RWTupleStructure
 PropagatedField addPropagatedField(java.lang.String name, PType type, QueryTreeField[] anc)
          Creates and adds a PropagatedField to the TupleStructure of the QueryNode.
 java.lang.Object clone(java.lang.Object clone, java.util.Map obj2clone)
           
 QueryTree[] getChildren()
          It retreives the array of the QueryTree used by this QueryNode.
protected  java.lang.String getFieldName(java.lang.String nodeName, java.lang.String fieldName)
           
 Expression getQueryFilter()
          Retrieves the filter associated to the QueryTree.
 TupleLoader getTupleLoader()
          Returns the TupleLoader currently associated with this QueryNode.
abstract  short getType()
          It retrieves the operation type of the current QueryNode.
 boolean isOuter(QueryTree child)
          Indicates whether a row of nulls should be inserted for the given child if the filter condition fails for all rows in that child.
 QueryTreeField removeField(java.lang.String name)
          Removes a Field.
 QueryTreeField replace(QueryTreeField old, QueryTreeField neo)
           
 void setOuter(QueryTree child, boolean value)
           
 void setQueryFilter(Expression filter)
          The setQueryFilter method will be overwritten for implementations which do not support the operation.
 void setTupleLoader(TupleLoader loader)
          Associates a TupleLoader with this QueryNode.
 void updateCalculatedField(java.lang.String name, Expression e)
           
protected  void updateChildren()
          Updates the list of children by screening all Fields and the query filter.
 void updatePropagatedField(java.lang.String name, QueryTreeField[] previous)
           
 
Methods inherited from class org.objectweb.medor.query.lib.BasicQueryTree
getAnnotations, getDistinct, getName, getOrderBy, getTupleStructure, setDistinct, setOrderBy
 
Methods inherited from class org.objectweb.medor.lib.BasicTupleStructure
contains, contains, getField, getField, getFieldRank, getFields, getSize
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.objectweb.medor.query.api.QueryTree
getDistinct, getName, getOrderBy, getTupleStructure, setDistinct, setOrderBy
 
Methods inherited from interface org.objectweb.medor.query.api.AnnotationsHolder
getAnnotations
 
Methods inherited from interface org.objectweb.medor.api.Cloneable
clone
 

Field Detail

children

protected java.util.ArrayList children

inner

protected java.util.HashSet inner

tupleLoader

protected TupleLoader tupleLoader

filter

protected Expression filter

indexes

protected int[] indexes
Contains ranges of attribute to be projected from the tuple resulting of the concatenation of the tuples from the children QueryTrees.

Constructor Detail

BasicQueryNode

public BasicQueryNode()

BasicQueryNode

public BasicQueryNode(java.lang.String name)
Method Detail

clone

public java.lang.Object clone(java.lang.Object clone,
                              java.util.Map obj2clone)
                       throws java.lang.CloneNotSupportedException
Overrides:
clone in class BasicQueryTree
Throws:
java.lang.CloneNotSupportedException

addPropagatedField

public PropagatedField addPropagatedField(java.lang.String name,
                                          PType type,
                                          QueryTreeField[] anc)
                                   throws MedorException
Creates and adds a PropagatedField to the TupleStructure of the QueryNode.

Specified by:
addPropagatedField in interface QueryNode
Parameters:
name - is the name of the Field to be added.
type - is the PType of the Field to be added.
anc - are the origin Fields for the PropagatedField to be created.
Returns:
the newly created PropagatedField
Throws:
MedorException - when a Field with the same name already exists.

addCalculatedField

public CalculatedField addCalculatedField(java.lang.String name,
                                          PType type,
                                          Expression exp)
                                   throws MedorException
Creates and adds a CalculatedField to the TupleStructure of the QueryNode.

Specified by:
addCalculatedField in interface QueryNode
Parameters:
name - is the name of the Field to be added.
type - is the PType of the Field to be added.
exp - is the Expression for calculating the new Field.
Returns:
the newly created CalculatedField
Throws:
MedorException - when a Field with the same name already exists.

removeField

public QueryTreeField removeField(java.lang.String name)
                           throws MedorException
Removes a Field.

Specified by:
removeField in interface QueryNode
Parameters:
name - is the name of the Field to be removed.
Returns:
the Field which has been removed, or null if no such Field could be removed.
Throws:
MedorException - when no Field with such name exist.

getChildren

public QueryTree[] getChildren()
Description copied from interface: QueryNode
It retreives the array of the QueryTree used by this QueryNode.

Specified by:
getChildren in interface QueryNode

isOuter

public boolean isOuter(QueryTree child)
Description copied from interface: QueryNode
Indicates whether a row of nulls should be inserted for the given child if the filter condition fails for all rows in that child.

Specified by:
isOuter in interface QueryNode

setOuter

public void setOuter(QueryTree child,
                     boolean value)
Specified by:
setOuter in interface QueryNode

replace

public QueryTreeField replace(QueryTreeField old,
                              QueryTreeField neo)
Specified by:
replace in interface QueryNode

setQueryFilter

public void setQueryFilter(Expression filter)
                    throws java.lang.UnsupportedOperationException
The setQueryFilter method will be overwritten for implementations which do not support the operation.

Specified by:
setQueryFilter in interface FilteredQueryTree
Parameters:
filter - is the Expression representing the query filter of the current QueryNode.
Throws:
java.lang.UnsupportedOperationException - when it is not supported (for Union, Intersection, Cartesian, Projection).
See Also:
Expression

getQueryFilter

public Expression getQueryFilter()
Description copied from interface: FilteredQueryTree
Retrieves the filter associated to the QueryTree. This filter is represented by an Expression.

Specified by:
getQueryFilter in interface FilteredQueryTree
Returns:
the query filter Expression associated to the QueryNode.
See Also:
Expression

getType

public abstract short getType()
Description copied from interface: QueryNode
It retrieves the operation type of the current QueryNode.

Specified by:
getType in interface QueryNode

getTupleLoader

public TupleLoader getTupleLoader()
Description copied from interface: QueryNode
Returns the TupleLoader currently associated with this QueryNode. Note that TupleLoaders are only used at evaluation time.

Specified by:
getTupleLoader in interface QueryNode

setTupleLoader

public void setTupleLoader(TupleLoader loader)
Description copied from interface: QueryNode
Associates a TupleLoader with this QueryNode.

Specified by:
setTupleLoader in interface QueryNode

updatePropagatedField

public void updatePropagatedField(java.lang.String name,
                                  QueryTreeField[] previous)
                           throws MedorException
Specified by:
updatePropagatedField in interface QueryNode
Throws:
MedorException

updateCalculatedField

public void updateCalculatedField(java.lang.String name,
                                  Expression e)
                           throws MedorException
Specified by:
updateCalculatedField in interface QueryNode
Throws:
MedorException

addField

protected void addField(Field f)
Adds a Field to the current RWTupleStructure

Parameters:
f - The Field to be added.

updateChildren

protected void updateChildren()
Updates the list of children by screening all Fields and the query filter.


getFieldName

protected java.lang.String getFieldName(java.lang.String nodeName,
                                        java.lang.String fieldName)

addChild

protected void addChild(QueryTree qt)