edu.wpi.cs.dsrg.xmldb.xat.common.treestructure
Interface XATTree

All Known Implementing Classes:
XATTreeImp

public interface XATTree
extends Visitable, XATQueryObject

This class defines an order un-sensitive XML algebra tree.

Since:
1.0

Method Summary
 void addNode(XATNode child, XATNode newparent)
          Add a new parent node for a given DOMPatternNode node.
 void addXATTree(XATTree childTree)
          For all the leaves, add the subtree to it.
 void appendXATNode(XATNode leave)
          Append a XAT Node to the leaves of the XATTree.
 java.lang.Object clone()
          Clone the XATTree.
 XATNode[] convertToArray()
          Get all the leaves of this XATTree.
 void deleteNode(XATNode Node)
          Delete node.
 java.util.Vector getAllLeafNodes(XATNode root)
          Get all the leaf node of given XATTree, which is rooted at given root node.
 BindingTable getBindingTable()
          Get the binding table of this Tree.
 XATNode[] getLeaves()
          Get all the leaves of this XATTree.
 XATLeaf[] getLeavesWithDepth()
          Get all the leaves of this XATTree along with their depth.
 XATNode getRoot()
          Get the root node of this XATTree.
 java.util.Iterator getRoots()
          Assuming the XATTree is a forest sometime, this method get all the roots of XAT.
 void insertRoot(XATNode root)
          Insert a new node as the root of this tree.
 void moveNode(XATNode child, XATNode new_parent)
          Move node.
 void moveNode(XATNode child, XATNode new_parent, int position)
          Move node.
 void replaceNode(XATNode oldNode, XATNode newNode)
          Replace oldNode in Tree with newNode.
 void setBindingTable(BindingTable bind)
          Set the binding table of this Tree.
 XATNode setRoot(XATNode new_root)
          Set root node.
 int size()
          Give number of nodes in this tree.
 boolean validate()
          This going to validate the parent-child relationship.
 
Methods inherited from interface edu.wpi.cs.dsrg.xmldb.xat.common.operator.XATQueryObject
getStatistics, isValidStatistic
 
Methods inherited from interface edu.wpi.cs.dsrg.xmldb.xat.common.operator.XATProperties
getProperties, getProperty, isValidPropertyName, setProperty
 

Method Detail

addNode

public void addNode(XATNode child,
                    XATNode newparent)
Add a new parent node for a given DOMPatternNode node. The parent node is updated to have a link to the child node. The child node is updates to have a link to the parent node.
Parameters:
parent - The parent node it attached to.
child - The child node attached.
Returns:
void
Since:
1.0

addXATTree

public void addXATTree(XATTree childTree)
For all the leaves, add the subtree to it. Note: We clone the subtree, and then added it to the tree. Hence, further modifications will not by automatically updated. Make sure create the subtree first, then added to the tree.
Parameters:
childTree - The XATTree attached.
Returns:
void
Since:
1.0

appendXATNode

public void appendXATNode(XATNode leave)
Append a XAT Node to the leaves of the XATTree.
Parameters:
XATNode - The XATNode append as leaf of XATTree.
Returns:
void
Since:
1.0

clone

public java.lang.Object clone()
Clone the XATTree.
Overrides:
clone in class java.lang.Object
Returns:
Object The cloned tree.
Since:
1.0

convertToArray

public XATNode[] convertToArray()
Get all the leaves of this XATTree.
Returns:
XATNode[] An array of XATNodes those are the leaf nodes.
Since:
1.0

deleteNode

public void deleteNode(XATNode Node)
                throws XATTreeNodeHasNoParentException
Delete node. It will affect number of nodes. All the children nodes of the to-be-deleted node will be the children of the parent node of the to-be-delete node. If the to-be-deleted node is the root node of the XATTree, the exception XATTreeNodeHasNoParentException will the throwed. Instead, the root node should be changed by setRoot() method.
Parameters:
node - the to-be-deleted child node.
Returns:
void
Since:
1.0

getAllLeafNodes

public java.util.Vector getAllLeafNodes(XATNode root)
Get all the leaf node of given XATTree, which is rooted at given root node.
 This method is used to find all of the Source operators in an XATTree
 Looks at all of the root's children and adds them to the vector
 if that nodes' operator is an XML source .  The function is then
 recurvsively called on each of root's children until there are no more nodes 
 to look at.  
 
Parameters:
root - The root of a tree to iterate over
Returns:
Vector of all the leaf nodes including the subtree of FOR and GB.
Since:
1.0
See Also:

getBindingTable

public BindingTable getBindingTable()
Get the binding table of this Tree.
Returns:
BindingTable The binding table of XATTree.
Since:
1.0

getLeaves

public XATNode[] getLeaves()
Get all the leaves of this XATTree.
Returns:
XATNode[] An array of XATNodes those are the leaf nodes.
Since:
1.0

getLeavesWithDepth

public XATLeaf[] getLeavesWithDepth()
Get all the leaves of this XATTree along with their depth.
Returns:
XATLeaf[] An array of XATNodes those are the leaf nodes.
Since:
1.0

getRoot

public XATNode getRoot()
Get the root node of this XATTree.
Returns:
XATNode The root of XATTree.
Since:
1.0

getRoots

public java.util.Iterator getRoots()
Assuming the XATTree is a forest sometime, this method get all the roots of XAT.
Returns:
java.util.Iterator All the roots of given XAT.
Since:
1.0

insertRoot

public void insertRoot(XATNode root)
Insert a new node as the root of this tree.
Parameters:
root - The root will be inserted in.
Returns:
void
Since:
1.0

moveNode

public void moveNode(XATNode child,
                     XATNode new_parent)
Move node. It will affect three nodes, the original parent node A, the child node B and the new parent node C. The A's children is updated, The B's parent is updated, and C's children is updated.

The child node will always move to the end of the children of the parent node.

Parameters:
child - The to-be-moved child node.
new_parent - The new parent node.
Returns:
void
Since:
1.0

moveNode

public void moveNode(XATNode child,
                     XATNode new_parent,
                     int position)
Move node. It will affect three nodes, the original parent node A, the child node B and the new parent node C. The A's children is updated, The B's parent is updated, and C's children is updated.

The child node will move to the specific position in the parent node.

Parameters:
child - The to-be-moved child node.
new_parent - The new parent node.
position - The new position in the parent node.
Returns:
void
Since:
1.0

replaceNode

public void replaceNode(XATNode oldNode,
                        XATNode newNode)
Replace oldNode in Tree with newNode.
Parameters:
oldNode - The old XATNode will be replaced.
newNode - The new XATNode used to replace the old one.
Returns:
void
Since:
1.0

setBindingTable

public void setBindingTable(BindingTable bind)
Set the binding table of this Tree.
Parameters:
bind - The new binding table for this tree.
Returns:
void
Since:
1.0

setRoot

public XATNode setRoot(XATNode new_root)
Set root node.
Parameters:
new_root - The new root node.
Returns:
XATNode The original root node.
Since:
1.0

size

public int size()
Give number of nodes in this tree.
Returns:
int The computed size of the tree.
Since:
1.0

validate

public boolean validate()
This going to validate the parent-child relationship. It's a top down traversal. And, if it find a children't parent is not set properly in the tree, a warning message will be shown, and also the parent link will be fixed.
Returns:
boolean Tree: This is a valid XATTree. False: otherwise.
Since:
1.0