org.exolab.castor.jdo.oql
Class ParseTreeNode

java.lang.Object
  extended by org.exolab.castor.jdo.oql.ParseTreeNode
All Implemented Interfaces:
TokenTypes

public class ParseTreeNode
extends java.lang.Object
implements TokenTypes

A Node in the Parse tree which is generated by the Parser as 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 the Token which represents that part of the tree.

Version:
$Revision: 1.2 $ $Date: 2004/03/31 09:00:15 $
Author:
Nissim Karpenstein

Field Summary
 
Fields inherited from interface org.exolab.castor.jdo.oql.TokenTypes
ARROW, BOOLEAN_LITERAL, CHAR_LITERAL, COLON, COMMA, CONCAT, DATE_LITERAL, DIVIDE, DOLLAR, DOT, DOUBLE_LITERAL, END_OF_QUERY, EQUAL, GT, GTE, IDENTIFIER, KEYWORD_ABS, KEYWORD_AND, KEYWORD_AS, KEYWORD_ASC, KEYWORD_AVG, KEYWORD_BETWEEN, KEYWORD_BY, KEYWORD_COUNT, KEYWORD_DESC, KEYWORD_DISTINCT, KEYWORD_FROM, KEYWORD_IN, KEYWORD_IS_DEFINED, KEYWORD_IS_UNDEFINED, KEYWORD_LIKE, KEYWORD_LIMIT, KEYWORD_LIST, KEYWORD_MAX, KEYWORD_MIN, KEYWORD_MOD, KEYWORD_NIL, KEYWORD_NOT, KEYWORD_OFFSET, KEYWORD_OR, KEYWORD_ORDER, KEYWORD_SELECT, KEYWORD_SUM, KEYWORD_UNDEFINED, KEYWORD_WHERE, LONG_LITERAL, LPAREN, LT, LTE, MINUS, NOT_EQUAL, PLUS, RPAREN, STRING_LITERAL, TIME_LITERAL, TIMES, TIMESTAMP_LITERAL
 
Constructor Summary
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
 void addChild(ParseTreeNode child)
          Adds a new node as a child of this node.
 java.util.Enumeration children()
          Accessor method for an enumeration of this nodes children.
 ParseTreeNode getChild(int index)
          Accessor method for individual children of this node.
 int getChildCount()
          Accessor method for the number of children of this node.
 ParseTreeNode getParent()
          Accessor method for the parent of this node.
 Token getToken()
          Accessor method for the token.
 boolean isLeaf()
          Specifies whether this node is a leaf.
 boolean isRoot()
          Specifies whether this node is the root of a tree.
 void setParent(ParseTreeNode parent)
          Changes the parent of this node.
 java.lang.String toString()
           
 java.lang.String toStringEx()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

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:
toString in class java.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.Enumeration children()
Accessor method for an enumeration of this nodes children.

Returns:
An Enumeration 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.


Intalio Inc. (C) 1999-2004. All rights reserved http://www.intalio.com