org.apache.jdo.impl.jdoql.tree
Class NodeImpl

java.lang.Object
  extended byantlr.BaseAST
      extended byantlr.CommonAST
          extended byorg.apache.jdo.impl.jdoql.jdoqlc.JDOQLAST
              extended byorg.apache.jdo.impl.jdoql.tree.NodeImpl
All Implemented Interfaces:
antlr.collections.AST, java.lang.Cloneable, Node, java.io.Serializable
Direct Known Subclasses:
CandidateClassImpl, Decl, Expr, OrderingExpr, Tree, TypeImpl

public class NodeImpl
extends JDOQLAST
implements Node

This is the base class of all nodes. Examples of nodes are , Declaration, Expression and OrderingExpression. This class is not defined abstract to allow the syntactical analysis to construct general nodes, which are replaced by the semantic analysis with their specialized counterparts.

Author:
Michael Watzek
See Also:
Serialized Form

Field Summary
(package private)  Node[] children
           
(package private)  java.lang.Class clazz
           
private static org.apache.jdo.impl.model.java.runtime.RuntimeJavaModelFactory javaModelFactory
          RuntimeJavaModelFactory.
(package private) static org.apache.jdo.util.I18NHelper msg
          I18N support
(package private)  java.lang.Object object
           
(package private)  Node parent
           
 
Fields inherited from class org.apache.jdo.impl.jdoql.jdoqlc.JDOQLAST
column, line, typeInfo
 
Fields inherited from class antlr.CommonAST
 
Fields inherited from class antlr.BaseAST
down, right
 
Constructor Summary
  NodeImpl()
          The noarg constructor is needed for ANTLR support and deserialization.
(package private) NodeImpl(int tokenType, java.lang.String tokenName, java.lang.Class clazz)
          This constructor is called by specialized nodes.
  NodeImpl(antlr.Token token)
          The noarg constructor is needed for ANTLR support.
 
Method Summary
 void arrive(NodeVisitor visitor)
          Implements a noop as a default implementation.
(package private)  void ASTToChildren()
          This method initializes the children of this node based on underlying ANTLR tree structure.
protected  java.lang.Object clone()
          Creates and returns a copy of this object nullifying fields parent, children and clazz.
 Node[] getChildren()
          Returns this node's children.
 java.lang.Class getJavaClass()
          Returns the Java type of this node.
 java.lang.Object getObject()
          Returns the user object.
 Node getParent()
          Returns this node's parent node.
 int getTokenType()
          Returns the token type of this node.
 java.lang.Object leave(NodeVisitor visitor, java.lang.Object[] results)
          Returns null as a default implementation.
(package private)  void setChildren(Node[] children)
          Sets the children of this node specified by the argument children.
 void setObject(java.lang.Object object)
          Sets the user object.
 void setParent(Node parent)
          Sets the parent of this node.
 java.lang.String toString()
          Returns a string representation of this JDOQLAST.
 boolean walkNextChild(NodeVisitor visitor, java.lang.Object resultOfPreviousChild, int indexOfNextChild)
          Returns true as a default implementation.
 
Methods inherited from class org.apache.jdo.impl.jdoql.jdoqlc.JDOQLAST
getColumn, getLine, getTypeInfo, initialize, initialize, initialize, setColumn, setLine, setTypeInfo, treeToString
 
Methods inherited from class antlr.CommonAST
getText, getType, initialize, setText, setType
 
Methods inherited from class antlr.BaseAST
addChild, decode, encode, equals, equalsList, equalsListPartial, equalsTree, equalsTreePartial, findAll, findAllPartial, getFirstChild, getNextSibling, getNumberOfChildren, getTokenNames, removeChildren, setFirstChild, setNextSibling, setVerboseStringConversion, toStringList, toStringTree, xmlSerialize, xmlSerializeNode, xmlSerializeRootClose, xmlSerializeRootOpen
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

msg

static final org.apache.jdo.util.I18NHelper msg
I18N support


javaModelFactory

private static final org.apache.jdo.impl.model.java.runtime.RuntimeJavaModelFactory javaModelFactory
RuntimeJavaModelFactory.


parent

Node parent

children

Node[] children

object

java.lang.Object object

clazz

transient java.lang.Class clazz
Constructor Detail

NodeImpl

public NodeImpl()
The noarg constructor is needed for ANTLR support and deserialization. The caller must make sure to set the ANTLR tree structure himself or, call setChildren optionally.


NodeImpl

public NodeImpl(antlr.Token token)
The noarg constructor is needed for ANTLR support. The caller must make sure to set the ANTLR tree structure himself or, call setChildren optionally.


NodeImpl

NodeImpl(int tokenType,
         java.lang.String tokenName,
         java.lang.Class clazz)
This constructor is called by specialized nodes. The caller must make sure to set the ANTLR tree structure himself or, call setChildren optionally.

Parameters:
tokenType - the token tpye
tokenName - the name of this node
clazz - the Java type of this node
Method Detail

clone

protected java.lang.Object clone()
                          throws java.lang.CloneNotSupportedException
Creates and returns a copy of this object nullifying fields parent, children and clazz.

Overrides:
clone in class JDOQLAST
Returns:
the copy
Throws:
java.lang.CloneNotSupportedException - thrown by super.clone()

toString

public java.lang.String toString()
Description copied from class: JDOQLAST
Returns a string representation of this JDOQLAST.

Specified by:
toString in interface antlr.collections.AST
Overrides:
toString in class JDOQLAST
Returns:
a string representation of the object.

getJavaClass

public java.lang.Class getJavaClass()
Returns the Java type of this node.

Specified by:
getJavaClass in interface Node
Returns:
the Java type

getTokenType

public int getTokenType()
Returns the token type of this node.

Specified by:
getTokenType in interface Node
Returns:
the token type

getObject

public java.lang.Object getObject()
Returns the user object.

Specified by:
getObject in interface Node
Returns:
the ouser object

setObject

public void setObject(java.lang.Object object)
Sets the user object.

Specified by:
setObject in interface Node
Parameters:
object - the user object

getParent

public Node getParent()
Returns this node's parent node.

Specified by:
getParent in interface Node
Returns:
the parent node

setParent

public void setParent(Node parent)
Sets the parent of this node.

Specified by:
setParent in interface Node
Parameters:
parent - the parent node

getChildren

public Node[] getChildren()
Returns this node's children. Ensures that this node's children corresponds with the underlying ANTLR tree structure.

Specified by:
getChildren in interface Node
Returns:
the children

arrive

public void arrive(NodeVisitor visitor)
Implements a noop as a default implementation.

Specified by:
arrive in interface Node
Parameters:
visitor - the node visitor

leave

public java.lang.Object leave(NodeVisitor visitor,
                              java.lang.Object[] results)
Returns null as a default implementation.

Specified by:
leave in interface Node
Parameters:
visitor - the node visitor
results - the result array containing result instances of this node's children
Returns:
the result instance of the delegation call of the argument visitor

walkNextChild

public boolean walkNextChild(NodeVisitor visitor,
                             java.lang.Object resultOfPreviousChild,
                             int indexOfNextChild)
Returns true as a default implementation.

Specified by:
walkNextChild in interface Node
Parameters:
visitor - the node visitor
resultOfPreviousChild - the result computed by leaving the previous child node
indexOfNextChild - the index in the children array of the next child to walk
Returns:
true

setChildren

void setChildren(Node[] children)
Sets the children of this node specified by the argument children. It is called in constructors of specialized nodes. These constructors are called by factory methods when you build the tree yourself.

Parameters:
children - the child nodes
Throws:
JDOQueryException - if an instance in the children array is null or already has a parent node

ASTToChildren

void ASTToChildren()
This method initializes the children of this node based on underlying ANTLR tree structure. It is called in method getChildren of this class.