openjava.ptree
Interface ParseTree

All Known Subinterfaces:
Expression, MemberDeclaration, Statement, VariableInitializer
All Known Implementing Classes:
DoWhileStatement, ForStatement, Leaf, List, NonLeaf, ParseTreeObject, SynchronizedStatement, TryStatement, IfStatement, ReturnStatement, ClassDeclaration, WhileStatement

public interface ParseTree

The ParseTree class presents for the node of parse tree. This may be a token node, Leaf, or may be a nonterminal node, NonLeaf.

See Also:
Leaf, NonLeaf

Method Summary
 void accept(ParseTreeVisitor visitor)
          Accepts a ParseTreeVisitor object as the role of a Visitor in the Visitor pattern, as the role of an Element in the Visitor pattern. This invoke an appropriate visit() method on the accepted visitor.
 void childrenAccept(ParseTreeVisitor visitor)
          Accepts a ParseTreeVisitor object as the role of a Visitor in the Visitor pattern, as the role of an Element in the Visitor pattern. This invoke an appropriate visit() method on each child ParseTree object with this visitor.
 boolean eq(ParseTree p)
          Tests if this parse-tree-node's value equals to the specified ptree-node's.
 boolean equals(ParseTree p)
          Tests if this parse-tree-node's value equals to the specified ptree-node's.
 int getObjectID()
          Returns the Identifier Number of this object
 ParseTree makeCopy()
          Makes a new copy of this nonleaf-node as a ptree-node.
 ParseTree makeRecursiveCopy()
          Makes a new copy (another object) of this nonleaf-node recursively.
 void replace(ParseTree replacement)
           
 java.lang.String toFlattenString()
          Generates the string expression from this node.
 java.lang.String toString()
          Generates string which presents for this parse-tree
 void writeCode()
          Deprecated.  
 

Method Detail

replace

public void replace(ParseTree replacement)
             throws ParseTreeException

makeRecursiveCopy

public ParseTree makeRecursiveCopy()
Makes a new copy (another object) of this nonleaf-node recursively. The objects contained by this object will also be copied.
Returns:
the copy of this nonleaf-node as a ptree-node.

makeCopy

public ParseTree makeCopy()
Makes a new copy of this nonleaf-node as a ptree-node. The objects contained by the new object are same as these contained by the original object.
Returns:
the copy of this nonleaf-node as a ptree-node.

equals

public boolean equals(ParseTree p)
Tests if this parse-tree-node's value equals to the specified ptree-node's.
Returns:
true if two values are same.

eq

public boolean eq(ParseTree p)
Tests if this parse-tree-node's value equals to the specified ptree-node's.
Returns:
true if two this and p refer to the same ptree object.

toString

public java.lang.String toString()
Generates string which presents for this parse-tree
Overrides:
toString in class java.lang.Object
Returns:
string which presents for this parse-tree

writeCode

public void writeCode()
Deprecated.  


toFlattenString

public java.lang.String toFlattenString()
Generates the string expression from this node. Returned string doesn't have '"' without cancel ( \" ) and doesn't have newline.

This method is useful to embed ptree objects as a string literal in source code.

Returns:
the flatten string which this node represents

getObjectID

public int getObjectID()
Returns the Identifier Number of this object
Returns:
the ID number of this object

accept

public void accept(ParseTreeVisitor visitor)
            throws ParseTreeException
Accepts a ParseTreeVisitor object as the role of a Visitor in the Visitor pattern, as the role of an Element in the Visitor pattern.

This invoke an appropriate visit() method on the accepted visitor.

Parameters:
visitor - a visitor

childrenAccept

public void childrenAccept(ParseTreeVisitor visitor)
                    throws ParseTreeException
Accepts a ParseTreeVisitor object as the role of a Visitor in the Visitor pattern, as the role of an Element in the Visitor pattern.

This invoke an appropriate visit() method on each child ParseTree object with this visitor.

Parameters:
visitor - a visitor