scale.common
Class Root

java.lang.Object
  |
  +--scale.common.Root
All Implemented Interfaces:
AnnotationInterface, DisplayNode, java.io.Serializable
Direct Known Subclasses:
CallNode, Clef, DominanceFrontier, Domination, Node, Note, Scribble, Suite

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

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

$Id: Root.java,v 1.14 2002/01/03 21:44:39 burrill Exp $

Copyright 2002 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, Serialized Form

Fields inherited from interface scale.common.DisplayNode
ANNO, CLEF, DD, DEFUSE, DOM, EXPR, MAYUSE, TYPE
 
Constructor Summary
protected Root()
           
 
Method Summary
 void addAnnotation(Annotation a)
          Adds an annotation to this node's annotation list.
 java.util.Enumeration allAnnotations()
          Returns an enumeration of all the annotations associated with this node.
 java.util.Enumeration 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.
 java.lang.String getDisplayColorHint()
          Return a String specifying the color to use for coloring this node in a graphical display.
 java.lang.String getDisplayName()
          Return a unique label for graphical displays.
 java.lang.String 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.
 java.lang.String getDisplayText()
          Return a String suitable for labeling this node in a graphical 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.
 
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.

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

getDisplayText

public java.lang.String getDisplayText()
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:
getDisplayText in interface DisplayNode

getDisplayColorHint

public java.lang.String 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

getDisplayShapeHint

public java.lang.String 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

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
Following copied from interface: scale.annot.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
Following copied from interface: scale.annot.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
Following copied from interface: scale.annot.AnnotationInterface
Parameters:
annotation_key - the annotation key
Returns:
true if an equivalent annotation is associated with the node. Note - the Creator, Beliefs, and the Combining Rule are not used in equivalence testing.

allAnnotations

public final java.util.Enumeration allAnnotations()
Returns an enumeration of all the annotations associated with this node.
Specified by:
allAnnotations in interface AnnotationInterface
Following copied from interface: scale.annot.AnnotationInterface
Returns:
an enumeration of all the annotations associated with this node.

allMatchingAnnotations

public final java.util.Enumeration 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
Following copied from interface: scale.annot.AnnotationInterface
Returns:
an enumeration of all the annotations of the given kind associated with this node.

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