Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

openjava.ptree
Class ParseTreeObject  view ParseTreeObject download ParseTreeObject.java

java.lang.Object
  extended byopenjava.ptree.ParseTreeObject
All Implemented Interfaces:
java.lang.Cloneable, ParseTree
Direct Known Subclasses:
Leaf, List, NonLeaf

public abstract class ParseTreeObject
extends java.lang.Object
implements ParseTree, java.lang.Cloneable

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


Field Summary
private static int idCount
          The idCount counts up generated ptree objects
protected static java.lang.String LN
          Why this modifier is not final ? - Because of javac bug in excuting it with -O option.
private  int objectID
          The object ID is object identifier number in order to determine two ptree variables refer to the same object.
private  ParseTreeObject parent
           
 
Constructor Summary
ParseTreeObject()
          Arrocates new parse-tree object and set identifier number on the object.
 
Method Summary
abstract  void accept(openjava.ptree.util.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.
abstract  void childrenAccept(openjava.ptree.util.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.
protected  java.lang.Object clone()
          clone() is fixed as a shallow copy.
static boolean equal(ParseTree p, ParseTree q)
          May return true if two ptree-nodes don't refer to not the same objects but their contents are equivalent.
abstract  boolean equals(ParseTree p)
          Tests if this parse-tree-node's value equals to the specified ptree-node's.
 int getObjectID()
          Returns
 ParseTreeObject getParent()
           
 int hashCode()
          Get a value that represents this Object, as uniquely as possible within the confines of an int.
static int lastObjectID()
           
 ParseTree makeCopy()
          shallow copy
abstract  ParseTree makeRecursiveCopy()
          deep copy
 void replace(ParseTree replacement)
           
protected abstract  void replaceChildWith(ParseTree dist, ParseTree replacement)
           
private  void setObjectID()
          Increments idCount class variable and set the instance's object identifier number to the number of idCount variable.
protected  void setParent(ParseTreeObject parent)
           
 java.lang.String toFlattenString()
          Generates the string expression from this node.
 java.lang.String toString()
          Generates a string object of regular Java source code representing this parse-tree.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

LN

protected static java.lang.String LN
Why this modifier is not final ? - Because of javac bug in excuting it with -O option.


parent

private ParseTreeObject parent

objectID

private int objectID
The object ID is object identifier number in order to determine two ptree variables refer to the same object.


idCount

private static int idCount
The idCount counts up generated ptree objects

Constructor Detail

ParseTreeObject

public ParseTreeObject()
Arrocates new parse-tree object and set identifier number on the object.

Method Detail

getParent

public final ParseTreeObject getParent()

setParent

protected final void setParent(ParseTreeObject parent)

replace

public final void replace(ParseTree replacement)
                   throws ParseTreeException
Specified by:
replace in interface ParseTree

replaceChildWith

protected abstract void replaceChildWith(ParseTree dist,
                                         ParseTree replacement)
                                  throws ParseTreeException

clone

protected final java.lang.Object clone()
clone() is fixed as a shallow copy.


makeCopy

public ParseTree makeCopy()
shallow copy

Specified by:
makeCopy in interface ParseTree

makeRecursiveCopy

public abstract ParseTree makeRecursiveCopy()
deep copy

Specified by:
makeRecursiveCopy in interface ParseTree

equals

public abstract boolean equals(ParseTree p)
Tests if this parse-tree-node's value equals to the specified ptree-node's.

Specified by:
equals in interface ParseTree

hashCode

public int hashCode()
Description copied from class: java.lang.Object
Get a value that represents this Object, as uniquely as possible within the confines of an int.

There are some requirements on this method which subclasses must follow:

  • Semantic equality implies identical hashcodes. In other words, if a.equals(b) is true, then a.hashCode() == b.hashCode() must be as well. However, the reverse is not necessarily true, and two objects may have the same hashcode without being equal.
  • It must be consistent. Whichever value o.hashCode() returns on the first invocation must be the value returned on all later invocations as long as the object exists. Notice, however, that the result of hashCode may change between separate executions of a Virtual Machine, because it is not invoked on the same object.

Notice that since hashCode is used in java.util.Hashtable and other hashing classes, a poor implementation will degrade the performance of hashing (so don't blindly implement it as returning a constant!). Also, if calculating the hash is time-consuming, a class may consider caching the results.

The default implementation returns System.identityHashCode(this)


toString

public java.lang.String toString()
Generates a string object of regular Java source code representing this parse-tree.

Specified by:
toString in interface ParseTree

equal

public static final boolean equal(ParseTree p,
                                  ParseTree q)
May return true if two ptree-nodes don't refer to not the same objects but their contents are equivalent.


lastObjectID

public static final int lastObjectID()

setObjectID

private final void setObjectID()
Increments idCount class variable and set the instance's object identifier number to the number of idCount variable.


getObjectID

public final int getObjectID()
Returns

Specified by:
getObjectID in interface ParseTree

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.

Specified by:
toFlattenString in interface ParseTree

accept

public abstract void accept(openjava.ptree.util.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.

Specified by:
accept in interface ParseTree

childrenAccept

public abstract void childrenAccept(openjava.ptree.util.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.

Specified by:
childrenAccept in interface ParseTree