openjava.ptree
Class ParseTreeObject

java.lang.Object
  |
  +--openjava.ptree.ParseTreeObject
All Implemented Interfaces:
Cloneable, ParseTree
Direct Known Subclasses:
Leaf, List, NonLeaf

public abstract class ParseTreeObject
extends Object
implements ParseTree, 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.

See Also:
Leaf, NonLeaf

Field Summary
protected static boolean debugFlag
          to write debugging code
protected static int debugLevel
           
private static int idCount
          The idCount counts up generated ptree objects
protected static String LN
           
private static int nest
          to write debugging code
private  int objectID
          The object ID is object identifier number in order to determine two ptree variables refer to the same object.
protected static PrintWriter out
          this is used as like grobal variable in ParseTree class-family.
private  ParseTreeObject parent
           
private static String tab
          to write debugging code
protected static WriterStack writerStack
          this is used as like grobal variable in ParseTree class-family.
 
Constructor Summary
ParseTreeObject()
          Arrocates new parse-tree object and set identifier number on the object.
 
Method Summary
abstract  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.
abstract  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.
protected  Object clone()
          clone() is fixed as a shallow copy.
 boolean eq(ParseTree p)
          Tests if this parse-tree-node's value equals to the specified ptree-node's.
static boolean eq(ParseTree p, ParseTree q)
          Return true if only they refer to the same object.
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.
static void flushPrintWriter()
           
static boolean getDebugFlag()
           
static int getNest()
           
 int getObjectID()
          Returns name the ID represents
 ParseTreeObject getParent()
           
static PrintWriter getPrintWriter()
           
static String getTab()
           
 int hashCode()
           
static int lastObjectID()
           
 ParseTree makeCopy()
          shallow copy
abstract  ParseTree makeRecursiveCopy()
          deep copy
static void popNest()
           
static PrintWriter popPrintWriter()
           
static void pushNest()
           
static void pushPrintWriter(PrintWriter pw)
           
 void replace(ParseTree replacement)
           
protected abstract  void replaceChildWith(ParseTree dist, ParseTree replacement)
           
static void setDebugFlag(boolean df)
           
static void setDebugLevel(int n)
           
static void setNest(int i)
           
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)
           
static void setPrintStream(PrintStream pstream)
          Sets the writer to the one from the specified stream.
static void setTab(String str)
           
 String toFlattenString()
          Generates the string expression from this node.
 String toString()
          Generates a string object of regular Java source code representing this parse-tree.
abstract  void writeCode()
          Deprecated.  
protected static void writeDebug(String str)
           
protected  void writeDebugL()
           
protected static void writeDebugLln()
           
protected static void writeDebugln()
           
protected static void writeDebugLR()
           
protected static void writeDebugR()
           
protected static void writeDebugRln()
           
protected static void writeTab()
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

LN

protected static String LN

parent

private ParseTreeObject parent

writerStack

protected static WriterStack writerStack
this is used as like grobal variable in ParseTree class-family.


out

protected static PrintWriter out
this is used as like grobal variable in ParseTree class-family.


debugFlag

protected static boolean debugFlag
to write debugging code


debugLevel

protected static int debugLevel

tab

private static String tab
to write debugging code


nest

private static int nest
to write debugging code


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
ParseTreeException

replaceChildWith

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

clone

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

Overrides:
clone in class Object
Returns:
the copy of this ptree-node.

makeCopy

public ParseTree makeCopy()
shallow copy

Specified by:
makeCopy in interface ParseTree
Returns:
the copy of this nonleaf-node as a ptree-node.

makeRecursiveCopy

public abstract ParseTree makeRecursiveCopy()
deep copy

Specified by:
makeRecursiveCopy in interface ParseTree
Returns:
the copy of this nonleaf-node as a ptree-node.

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
Returns:
true if two values are same.

eq

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

Specified by:
eq in interface ParseTree
Returns:
true if two this and p refer to the same ptree object.

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

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

Specified by:
toString in interface ParseTree
Overrides:
toString in class Object
Returns:
string which represents this parse-tree

setPrintStream

public static void setPrintStream(PrintStream pstream)
Sets the writer to the one from the specified stream.

Parameters:
pstream - print stream

getPrintWriter

public static PrintWriter getPrintWriter()

popPrintWriter

public static PrintWriter popPrintWriter()

pushPrintWriter

public static void pushPrintWriter(PrintWriter pw)

flushPrintWriter

public static void flushPrintWriter()

setDebugFlag

public static void setDebugFlag(boolean df)

setDebugLevel

public static void setDebugLevel(int n)

getDebugFlag

public static boolean getDebugFlag()

setTab

public static void setTab(String str)

getTab

public static String getTab()

setNest

public static void setNest(int i)

getNest

public static int getNest()

pushNest

public static void pushNest()

popNest

public static void popNest()

writeDebugL

protected void writeDebugL()

writeDebugR

protected static void writeDebugR()

writeDebugLR

protected static void writeDebugLR()

writeDebugLln

protected static void writeDebugLln()

writeDebugRln

protected static void writeDebugRln()

writeDebugln

protected static void writeDebugln()

writeDebug

protected static void writeDebug(String str)

writeTab

protected static void writeTab()

writeCode

public abstract void writeCode()
Deprecated.  

Use accept(SourceCodeWriter).

Specified by:
writeCode in interface ParseTree

eq

public static final boolean eq(ParseTree p,
                               ParseTree q)
Return true if only they refer to the same object. If two objects are both null, this returns true.

Parameters:
p - the ptree-node
q - the ptree-node
Returns:
true if p and q refer to same object.

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.

Parameters:
p - the node
q - the node to compare
Returns:
true if p equals c

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 name the ID represents

Specified by:
getObjectID in interface ParseTree
Returns:
Name the ID represents

toFlattenString

public 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
Returns:
the flatten string which this node represents

accept

public abstract 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.

Specified by:
accept in interface ParseTree
Parameters:
visitor - a visitor
ParseTreeException

childrenAccept

public abstract 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.

Specified by:
childrenAccept in interface ParseTree
Parameters:
visitor - a visitor
ParseTreeException

SourceForge.net_Logo