scale.common
Class Root

java.lang.Object
  extended by scale.common.Root
All Implemented Interfaces:
AnnotationInterface, DisplayNode
Direct Known Subclasses:
Domination, Node, Node, Note, PPBlock, PPCfg, PPEdge, Scribble, Suite

public abstract class Root
extends java.lang.Object
implements AnnotationInterface, DisplayNode

This class is the top level class for all Scale classes that may be annotated or graphically displayed.

$Id: Root.java,v 1.22 2007-08-13 12:32:02 burrill Exp $

Copyright 2008 by the Scale Compiler Group,
Department of Computer Science
University of Massachusetts,
Amherst MA. 01003, USA
All Rights Reserved.

Each instance has a unique id number associated with it.

See Also:
Annotation, Node, Note

Constructor Summary
protected Root()
           
 
Method Summary
 void addAnnotation(Annotation a)
          Adds an annotation to this node's annotation list.
 java.util.Enumeration<Annotation> allAnnotations()
          Returns an enumeration of all the annotations associated with this node.
 java.util.Enumeration<Annotation> allMatchingAnnotations(java.lang.Object annotation_key)
          Returns an enumeration of all the annotations of the given kind associated with this node.
 Annotation getAnnotation(java.lang.Object annotation_key)
          Returns an arbitrary annotation of the indicated kind.
 DColor getDisplayColorHint()
          Return a String specifying the color to use for coloring this node in a graphical display.
 java.lang.String getDisplayLabel()
          Return a String suitable for labeling this node in a graphical display.
 java.lang.String getDisplayName()
          Return a unique label for graphical displays.
 DShape getDisplayShapeHint()
          Return a String specifying a shape to use when drawing this node in a graphical display.
 java.lang.String getDisplayString(java.lang.String v)
          Convert a string to a form suitable for display.
static int getNodeCount()
          Return the number of nodes created so far.
 int getNodeID()
          Return the unique node label.
 boolean hasAnnotation(java.lang.Object annotation_key)
          Returns true if this node has the indicated kind of annotation.
 boolean hasEqualAnnotation(Annotation a)
          Returns true if this node has an annotation equal to the given annotation.
 int hashCode()
          Use the node ID as the hash code so that the order of processing is not affected by changes to the Java code.
 void removeAnnotation(Annotation a)
          Delete the given annotation.
 void removeAnnotations(java.lang.Object key)
          Delete all annotations which match the given key.
 java.lang.String toString()
           
 java.lang.String toStringAnnotations()
          Convert the annotations of this node to a string representation.
 java.lang.String toStringClass()
          Convert the class name of this node to a string representation.
 java.lang.String toStringSpecial()
          Return any special information of a node that is not a child or annotation.
 void trace(int id, java.lang.String msg)
          Print out a trace message to stdout if the node id of this node matches.
 void trace(int id, java.lang.String msg, boolean stkTrace)
          Print out a trace message to stdout if the node id of this node matches.
 void trace(int id, java.lang.String msg, boolean stkTrace, java.io.PrintStream str)
          Print out a trace message to specified stream if the node id of this node matches.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Root

protected Root()
Method Detail

getNodeID

public final int getNodeID()
Return the unique node label.


trace

public final void trace(int id,
                        java.lang.String msg)
Print out a trace message to stdout if the node id of this node matches. The trace message is the specified messsage followed by the display of this node.

Parameters:
id - is the node id to match
msg - is the beginning message text

trace

public final void trace(int id,
                        java.lang.String msg,
                        boolean stkTrace)
Print out a trace message to stdout if the node id of this node matches. The trace message is the specified messsage followed by the display of this node.

Parameters:
id - is the node id to match
msg - is the beginning message text
stkTrace - is true for a display of the Java stack

trace

public final void trace(int id,
                        java.lang.String msg,
                        boolean stkTrace,
                        java.io.PrintStream str)
Print out a trace message to specified stream if the node id of this node matches. The trace message is the specified messsage followed by the display of this node.

Parameters:
id - is the node id to match
msg - is the beginning message text
stkTrace - is true for a stack trace
str - is the stream to use

getNodeCount

public static final int getNodeCount()
Return the number of nodes created so far.


getDisplayName

public java.lang.String getDisplayName()
Return a unique label for graphical displays.

Specified by:
getDisplayName in interface DisplayNode

getDisplayLabel

public java.lang.String getDisplayLabel()
Return a String suitable for labeling this node in a graphical display. This method should be over-ridden as it simplay returns the class name.

Specified by:
getDisplayLabel in interface DisplayNode

getDisplayColorHint

public DColor getDisplayColorHint()
Return a String specifying the color to use for coloring this node in a graphical display. This method should be over-ridden as it simplay returns the color red.

Specified by:
getDisplayColorHint in interface DisplayNode
See Also:
DColor

getDisplayShapeHint

public DShape getDisplayShapeHint()
Return a String specifying a shape to use when drawing this node in a graphical display. This method should be over-ridden as it simplay returns the shape "box".

Specified by:
getDisplayShapeHint in interface DisplayNode
See Also:
DShape

addAnnotation

public final void addAnnotation(Annotation a)
Adds an annotation to this node's annotation list. Redundant annotations are permitted.

Specified by:
addAnnotation in interface AnnotationInterface

removeAnnotation

public final void removeAnnotation(Annotation a)
Delete the given annotation.

Specified by:
removeAnnotation in interface AnnotationInterface

removeAnnotations

public final void removeAnnotations(java.lang.Object key)
Delete all annotations which match the given key.


getAnnotation

public final Annotation getAnnotation(java.lang.Object annotation_key)
Returns an arbitrary annotation of the indicated kind.

Specified by:
getAnnotation in interface AnnotationInterface
Parameters:
annotation_key - the annotation key
Returns:
an arbitrary annotation of the indicated kind or null.

hasAnnotation

public final boolean hasAnnotation(java.lang.Object annotation_key)
Returns true if this node has the indicated kind of annotation.

Specified by:
hasAnnotation in interface AnnotationInterface
Parameters:
annotation_key - the annotation key
Returns:
true if the indicated kind of annotation is associated with the node.

hasEqualAnnotation

public final boolean hasEqualAnnotation(Annotation a)
Returns true if this node has an annotation equal to the given annotation.

Specified by:
hasEqualAnnotation in interface AnnotationInterface
Parameters:
a - the annotation key

allAnnotations

public final java.util.Enumeration<Annotation> allAnnotations()
Returns an enumeration of all the annotations associated with this node.

Specified by:
allAnnotations in interface AnnotationInterface

allMatchingAnnotations

public final java.util.Enumeration<Annotation> allMatchingAnnotations(java.lang.Object annotation_key)
Returns an enumeration of all the annotations of the given kind associated with this node.

Specified by:
allMatchingAnnotations in interface AnnotationInterface

toStringAnnotations

public final java.lang.String toStringAnnotations()
Convert the annotations of this node to a string representation.


toStringSpecial

public java.lang.String toStringSpecial()
Return any special information of a node that is not a child or annotation. This method is meant to be overridden by nodes that need to provide special output.


toStringClass

public final java.lang.String toStringClass()
Convert the class name of this node to a string representation.


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

hashCode

public int hashCode()
Use the node ID as the hash code so that the order of processing is not affected by changes to the Java code. Without this method, the order in which enumerations of hash set and hash maps return elements depends on the address of the element which is affected by many things including the particular parameters selected when executing the Scale compiler.

Overrides:
hashCode in class java.lang.Object

getDisplayString

public java.lang.String getDisplayString(java.lang.String v)
Convert a string to a form suitable for display. For example, a double quote (") is converted to "\"" and "\0" is converted to "\\0".

Parameters:
v - the original string
Returns:
the converted string