com.g11ntoolkit.parser.java
Class SimpleNode

java.lang.Object
  |
  +--com.g11ntoolkit.parser.java.SimpleNode
All Implemented Interfaces:
Node
Direct Known Subclasses:
LTAdditiveExpression, LTAllocationExpression, LTAndExpression, LTArgumentList, LTArguments, LTArrayDimsAndInits, LTArrayInitializer, LTAssertStatement, LTAssignmentOperator, LTBlock, LTBlockStatement, LTBooleanLiteral, LTBreakStatement, LTCastExpression, LTCastLookahead, LTClassBody, LTClassBodyDeclaration, LTClassDeclaration, LTCompilationUnit, LTConditionalAndExpression, LTConditionalExpression, LTConditionalOrExpression, LTConstructorDeclaration, LTContinueStatement, LTDoStatement, LTEmptyStatement, LTEqualityExpression, LTExclusiveOrExpression, LTExplicitConstructorInvocation, LTExpression, LTFieldDeclaration, LTForInit, LTFormalParameter, LTFormalParameters, LTForStatement, LTForUpdate, LTIfStatement, LTImportDeclaration, LTInclusiveOrExpression, LTInitializer, LTInstanceOfExpression, LTInterfaceDeclaration, LTInterfaceMemberDeclaration, LTLabeledStatement, LTLiteral, LTLocalVariableDeclaration, LTMethodDeclaration, LTMethodDeclarationLookahead, LTMethodDeclarator, LTMultiplicativeExpression, LTName, LTNameList, LTNestedClassDeclaration, LTNestedInterfaceDeclaration, LTNullLiteral, LTPackageDeclaration, LTPostfixExpression, LTPreDecrementExpression, LTPreIncrementExpression, LTPrimaryExpression, LTPrimaryPrefix, LTPrimarySuffix, LTPrimitiveType, LTRelationalExpression, LTResultType, LTReturnStatement, LTShiftExpression, LTStatement, LTStatementExpression, LTStatementExpressionList, LTSwitchLabel, LTSwitchStatement, LTSynchronizedStatement, LTThrowStatement, LTTryStatement, LTType, LTTypeDeclaration, LTUnaryExpression, LTUnaryExpressionNotPlusMinus, LTUnmodifiedClassDeclaration, LTUnmodifiedInterfaceDeclaration, LTVariableDeclarator, LTVariableDeclaratorId, LTVariableInitializer, LTWhileStatement

public class SimpleNode
extends java.lang.Object
implements Node

An implementation of the JavaCC generated Node interface.

This contains code needed for the G11NToolKit Tokenizer.

Version:
2005/06/30
Author:
Bill Rich, Wilandra Consulting LLC
Copyright © 2004-2005, Wilandra Consulting LLC, all rights reserved.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

See License Agreement.


Field Summary
protected  Node[] children
          The children nodes of the current node.
protected  Token first
          The first token for the node.
protected  int id
          The node identifier.
protected  Token last
          The last token for the node.
private static java.util.logging.Logger log
          The log used for all messages from this class.
protected  Node parent
          The parent of the current node.
protected  JavaParser parser
          The parser class.
 
Constructor Summary
SimpleNode(int i)
          Constructor for a node given a node id.
SimpleNode(JavaParser p, int i)
          Constructor for a given node id from a particular parser.
 
Method Summary
 java.lang.Object acceptChildren(JavaParserVisitor visitor, java.lang.Object data)
          Accepts the children nodes contained by the visitor node.
 void dump(java.lang.String prefix)
          Display all the nodes beginning at the current node and descending through all the children nodes.
 Token getFirstToken()
          Returns the first token for the current node.
 Token getLastToken()
          Returns the last token for the current node.
 java.lang.Object jjtAccept(JavaParserVisitor visitor, java.lang.Object data)
          Accepts the visitor node.
 void jjtAddChild(Node n, int i)
          Adds a child node to the current node.
 void jjtClose()
          Close the current node.
static Node jjtCreate(JavaParser p, int id)
          Creates a node given the parser and a node id.
 Node jjtGetChild(int i)
          Returns the specified child node of the current node.
 int jjtGetNumChildren()
          Returns the number of children nodes for the current node.
 Node jjtGetParent()
          Returns the parent node for the current node.
 void jjtOpen()
          Opens the current node.
 void jjtSetParent(Node n)
          Sets the parent node to the specified node.
 java.lang.String toString()
          Returns the string representation of the name of the current node.
 java.lang.String toString(java.lang.String prefix)
          Returns the string representation of the name of the current node plus the specified prefix string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

log

private static java.util.logging.Logger log
The log used for all messages from this class.


parent

protected Node parent
The parent of the current node.


children

protected Node[] children
The children nodes of the current node.


id

protected int id
The node identifier.


parser

protected JavaParser parser
The parser class.


first

protected Token first
The first token for the node.


last

protected Token last
The last token for the node.

Constructor Detail

SimpleNode

public SimpleNode(int i)
Constructor for a node given a node id.

Parameters:
i - an int specifying the node id

SimpleNode

public SimpleNode(JavaParser p,
                  int i)
Constructor for a given node id from a particular parser.

Parameters:
p - a JavaParser specifying the parser to use
i - an int specifying the node id
Method Detail

jjtCreate

public static Node jjtCreate(JavaParser p,
                             int id)
Creates a node given the parser and a node id.

Parameters:
p - a JavaParser specifying the parser to use
Returns:
a Node representing the node created

jjtOpen

public void jjtOpen()
Opens the current node.

Specified by:
jjtOpen in interface Node

jjtClose

public void jjtClose()
Close the current node.

Specified by:
jjtClose in interface Node

getFirstToken

public Token getFirstToken()
Returns the first token for the current node.

Returns:
a Token representing the first token for the current node

getLastToken

public Token getLastToken()
Returns the last token for the current node.

Returns:
a Token representing the last token for the current node

jjtSetParent

public void jjtSetParent(Node n)
Sets the parent node to the specified node.

Specified by:
jjtSetParent in interface Node
Parameters:
n - a Node specifying the new parent node
See Also:
jjtGetParent()

jjtGetParent

public Node jjtGetParent()
Returns the parent node for the current node.

Specified by:
jjtGetParent in interface Node
Returns:
a Node representing the parent node for the current node
See Also:
jjtSetParent(com.g11ntoolkit.parser.java.Node)

jjtAddChild

public void jjtAddChild(Node n,
                        int i)
Adds a child node to the current node.

Specified by:
jjtAddChild in interface Node
Parameters:
n - a Node specifying the node to add as a child of the current node
i - an int specifying the node identifier of the node to be added as a child of the current node
See Also:
jjtGetChild(int)

jjtGetChild

public Node jjtGetChild(int i)
Returns the specified child node of the current node.

Specified by:
jjtGetChild in interface Node
Parameters:
i - an int specifying the node identifier of the requested child node
Returns:
a Node representing the requested child node
Throws:
exceptionname - description
See Also:
jjtGetChild(int)

jjtGetNumChildren

public int jjtGetNumChildren()
Returns the number of children nodes for the current node.

Specified by:
jjtGetNumChildren in interface Node
Returns:
an int representing the number of children nodes for the current node

jjtAccept

public java.lang.Object jjtAccept(JavaParserVisitor visitor,
                                  java.lang.Object data)
Accepts the visitor node.

Specified by:
jjtAccept in interface Node
Parameters:
visitor - a JavaParserVisitor specifying the visitor node to accept
data - an Object specifying ???
Returns:
an Object representing ???

acceptChildren

public java.lang.Object acceptChildren(JavaParserVisitor visitor,
                                       java.lang.Object data)
Accepts the children nodes contained by the visitor node.

Parameters:
visitor - a JavaParserVisitor specifying the visitor node that contains the children nodes to accept
data - an Object specifying ???
Returns:
an Object representing ???

toString

public java.lang.String toString()
Returns the string representation of the name of the current node.

This method can be overriden in a subclasse of SimpleNode to customize the way the node appears when the tree is dumped. If the output uses more than one line, override the toString(String) method, otherwise overriding this method is probably adequate.

Overrides:
toString in class java.lang.Object
Returns:
a String representing the name of the current node
See Also:
toString(String prefix)

toString

public java.lang.String toString(java.lang.String prefix)
Returns the string representation of the name of the current node plus the specified prefix string.

This method can be overriden in a subclasse of SimpleNode to customize the way the node appears when the tree is dumped. If the output uses more than one line, override this method, otherwise overriding the toString() method is probably adequate.

Parameters:
prefix - a String specifying the prefix string to add to the name of the current node
Returns:
a String representing the name of the current node plus the prefix string
See Also:
toString()

dump

public void dump(java.lang.String prefix)
Display all the nodes beginning at the current node and descending through all the children nodes.

Override this method to customize how the node dumps out its children.

Parameters:
prefix - a String specifying the prefix string to add to the name of each node