Package org.exolab.castor.jdo.oql
Class ParseTreeNode
- java.lang.Object
-
- org.exolab.castor.jdo.oql.ParseTreeNode
-
public final class ParseTreeNode extends java.lang.ObjectA Node in the Parse tree which is generated by theParseras the tree representation of the OQL Query. Each node has a link back to the parent node (null for the root node), and a vector of children. Each node contains theTokenwhich represents that part of the tree.- Version:
- $Revision: 8102 $ $Date: 2006-04-25 15:08:23 -0600 (Tue, 25 Apr 2006) $
- Author:
- Nissim Karpenstein
-
-
Constructor Summary
Constructors Constructor Description ParseTreeNode(ParseTreeNode parent, Token token)Creates a new Node with supplied parent and token.ParseTreeNode(Token token)Creates a new root Node with supplied token.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddChild(ParseTreeNode child)Adds a new node as a child of this node.java.util.Iterator<ParseTreeNode>children()Accessor method for an iteration of this nodes children.ParseTreeNodegetChild(int index)Accessor method for individual children of this node.intgetChildCount()Accessor method for the number of children of this node.ParseTreeNodegetParent()Accessor method for the parent of this node.TokengetToken()Accessor method for the token.booleanisLeaf()Specifies whether this node is a leaf.booleanisRoot()Specifies whether this node is the root of a tree.voidsetParent(ParseTreeNode parent)Changes the parent of this node.java.lang.StringtoString()java.lang.StringtoStringEx()
-
-
-
Constructor Detail
-
ParseTreeNode
public ParseTreeNode(ParseTreeNode parent, Token token)
Creates a new Node with supplied parent and token.- Parameters:
parent- The parent of this node (null for root)token- The token data in this node
-
ParseTreeNode
public ParseTreeNode(Token token)
Creates a new root Node with supplied token.- Parameters:
token- The token data in this node
-
-
Method Detail
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
toStringEx
public java.lang.String toStringEx()
-
setParent
public void setParent(ParseTreeNode parent)
Changes the parent of this node.- Parameters:
parent- The new parent.
-
addChild
public void addChild(ParseTreeNode child)
Adds a new node as a child of this node. Changes the nodes parent to this.- Parameters:
child- The new child
-
isRoot
public boolean isRoot()
Specifies whether this node is the root of a tree.- Returns:
- True if the node does not have a parent, otherwise false.
-
isLeaf
public boolean isLeaf()
Specifies whether this node is a leaf.- Returns:
- True if the node does not have any children, otherwise false.
-
getParent
public ParseTreeNode getParent()
Accessor method for the parent of this node.- Returns:
- The parent of this node.
-
children
public java.util.Iterator<ParseTreeNode> children()
Accessor method for an iteration of this nodes children.- Returns:
- An Iterator of children.
-
getChild
public ParseTreeNode getChild(int index)
Accessor method for individual children of this node.- Parameters:
index- the index of the child to retrieve.- Returns:
- the index child of this node.
-
getChildCount
public int getChildCount()
Accessor method for the number of children of this node.- Returns:
- the number of children of this node.
-
getToken
public Token getToken()
Accessor method for the token.- Returns:
- The token which is the datum of this node.
-
-