org.imemex.logicalplan
Class AbstractLogicalNode

java.lang.Object
  extended by org.imemex.logicalplan.AbstractLogicalNode
All Implemented Interfaces:
LogicalNode
Direct Known Subclasses:
AddLineage, Display, LogicalNodes.All, LogicalNodes.BlackBox, LogicalNodes.Boost, LogicalNodes.Choose, LogicalNodes.DeepUnnest, LogicalNodes.Distinct, LogicalNodes.Empty, LogicalNodes.Filter, LogicalNodes.GetParents, LogicalNodes.GreyBox, LogicalNodes.GroupBy, LogicalNodes.Intersect, LogicalNodes.Join, LogicalNodes.Minus, LogicalNodes.NAryUnion, LogicalNodes.Not, LogicalNodes.OrderBy, LogicalNodes.Progressive, LogicalNodes.Project, LogicalNodes.Rank, LogicalNodes.ShallowUnnest, LogicalNodes.StartViews, LogicalNodes.TopK, LogicalNodes.Union, VersionMerge

public abstract class AbstractLogicalNode
extends java.lang.Object
implements LogicalNode

The abstract logical node implements the following common functinality of logical nodes:

Author:
ogirard, revised by Lukas Blunschi

Field Summary
 
Fields inherited from interface org.imemex.logicalplan.LogicalNode
COPY_ANNOTATION
 
Constructor Summary
AbstractLogicalNode(java.lang.String alias, LogicalNodeType type)
           
AbstractLogicalNode(java.lang.String alias, LogicalNodeType type, LogicalNodeMetaData lnmd)
           
 
Method Summary
 boolean equals(LogicalNode lognode, boolean recursive, boolean deep)
          Perform equality test.
 java.lang.String getAlias()
          Get alias of this logical node.
 LogicalNode getChild(int index)
          Get a single child.
 java.util.List<LogicalNode> getChildren()
          Get direct children of this node.
 java.lang.String getCompareKey()
          Get compare key of this logical node (equally calculated for each node type and states!)
 java.lang.String getDesc()
          Get description.
 LogicalNodeMetaData getMetaData()
          Get metadata of this logical node.
 int getTreeSize()
          Get number of nodes in the complete subtree of this node.
 LogicalNodeType getType()
          Get type of this logical node.
 int nrOfChildren()
          Get number of direct children.
 boolean remove(LogicalNode child)
          Remove a given child.
 boolean replace(LogicalNode oldChild, LogicalNode newChild)
          Replace one child with another.
 void setAlias(java.lang.String alias)
          Set alias of this logical node node.
 void setDesc(java.lang.String description)
          Set description.
 java.lang.String toString()
           
 java.lang.String toString(boolean verbose)
           
 java.lang.String toXML()
          Generate XML output.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.imemex.logicalplan.LogicalNode
copy
 

Constructor Detail

AbstractLogicalNode

public AbstractLogicalNode(java.lang.String alias,
                           LogicalNodeType type)

AbstractLogicalNode

public AbstractLogicalNode(java.lang.String alias,
                           LogicalNodeType type,
                           LogicalNodeMetaData lnmd)
Method Detail

getType

public final LogicalNodeType getType()
Description copied from interface: LogicalNode
Get type of this logical node. The type of a logical node is read-only.

Specified by:
getType in interface LogicalNode
Returns:
type.

getAlias

public final java.lang.String getAlias()
Description copied from interface: LogicalNode
Get alias of this logical node. An alias is used in a similar way as in SQL: join(a as A, b as B, where A.size == B.length).

Specified by:
getAlias in interface LogicalNode
Returns:
alias.

setAlias

public final void setAlias(java.lang.String alias)
Description copied from interface: LogicalNode
Set alias of this logical node node.

Specified by:
setAlias in interface LogicalNode
Parameters:
alias - new alias for this logical node.

getDesc

public final java.lang.String getDesc()
Description copied from interface: LogicalNode
Get description.

Specified by:
getDesc in interface LogicalNode
Returns:
description.

setDesc

public final void setDesc(java.lang.String description)
Description copied from interface: LogicalNode
Set description.

Specified by:
setDesc in interface LogicalNode

nrOfChildren

public final int nrOfChildren()
Description copied from interface: LogicalNode
Get number of direct children.

Specified by:
nrOfChildren in interface LogicalNode
Returns:
number of direct children.

getChild

public final LogicalNode getChild(int index)
Description copied from interface: LogicalNode
Get a single child.

Specified by:
getChild in interface LogicalNode
Parameters:
index - index of child to get.
Returns:
child (no copy).

getChildren

public final java.util.List<LogicalNode> getChildren()
Description copied from interface: LogicalNode
Get direct children of this node.

Specified by:
getChildren in interface LogicalNode
Returns:
shallow copy of the list of direct children.

getTreeSize

public final int getTreeSize()
Description copied from interface: LogicalNode
Get number of nodes in the complete subtree of this node.

Specified by:
getTreeSize in interface LogicalNode
Returns:
number of all children in this tree.

replace

public final boolean replace(LogicalNode oldChild,
                             LogicalNode newChild)
Replace one child with another. This method may be heavely used!

Specified by:
replace in interface LogicalNode
Parameters:
oldChild - old child to replace.
newChild - new child to insert.
Returns:
true if old child successfully replaced with new child, false if old child is null, given children are the same, old child not found or removal of old child not possible.

remove

public final boolean remove(LogicalNode child)
Remove a given child.

Specified by:
remove in interface LogicalNode
Parameters:
child - child to remove.
Returns:
true if child successfully removed, false if given child is null or given child not found.

getMetaData

public final LogicalNodeMetaData getMetaData()
Description copied from interface: LogicalNode
Get metadata of this logical node.

Specified by:
getMetaData in interface LogicalNode
Returns:
metadata.

equals

public boolean equals(LogicalNode lognode,
                      boolean recursive,
                      boolean deep)
Perform equality test. If requested, by setting the recursive flag, all children are also tested for equality.

Specified by:
equals in interface LogicalNode
Parameters:
lognode - logical node to compare against.
recursive - true to perform deep test.
deep - ??? TODO
Returns:
true if given logical node is equal to this one.

getCompareKey

public java.lang.String getCompareKey()
Description copied from interface: LogicalNode
Get compare key of this logical node (equally calculated for each node type and states!)

The compare key is used to order logical nodes in a canonical way.

Specified by:
getCompareKey in interface LogicalNode
Returns:
compare key.

toXML

public java.lang.String toXML()
Generate XML output.

Specified by:
toXML in interface LogicalNode
Returns:
XML string.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

toString

public java.lang.String toString(boolean verbose)