gov.llnl.babel.symbols
Class Symbol

java.lang.Object
  extended by gov.llnl.babel.symbols.ASTNode
      extended by gov.llnl.babel.symbols.SymbolID
          extended by gov.llnl.babel.symbols.Symbol
All Implemented Interfaces:
Attributes, IMetadata, java.lang.Comparable
Direct Known Subclasses:
Enumeration, Extendable, Package, Struct

public abstract class Symbol
extends SymbolID
implements java.lang.Comparable, Attributes, IMetadata

The Symbol abstract base class describes the basic characteristics shared by all symbols in the symbol table. All SIDL symbols have a symbol identifier, a symbol type, a metadata description, and an associated comment. Four different types of symbols are supported: package, enum, class, and interface.


Field Summary
static int CLASS
           
protected  Context d_context
           
static int ENUM
           
static int INTERFACE
           
static int PACKAGE
           
static java.lang.String[] s_type
           
static java.lang.String SCOPE
           
static int STRUCT
           
 
Fields inherited from class gov.llnl.babel.symbols.ASTNode
d_frozen
 
Constructor Summary
Symbol(SymbolID id, int type, Comment comment, Context context)
          Initialize the Symbol abstact base class by providing a symbol identifier and its type (one of CLASS, ENUM, INTERFACE, or PACKAGE, or STRUCT).
Symbol(SymbolID id, int type, Comment comment, Metadata metadata, Context context)
          Initialize the Symbol abstract base class by providing a symbol identifier, a symbol type, a comment, and a metadata object.
 
Method Summary
 void addMetadata(java.lang.String keyword, java.lang.String value)
          Add a (keyword,value) pair to the metadata for this symbol.
 void freeze()
           
abstract  java.util.Set getAllSymbolReferences()
          Return the symbol references for the whole type hierarchy rooted with this symbol.
 java.lang.String getAttribute(java.lang.String key)
           
 java.util.Set getAttributes()
           
abstract  java.util.Set getBasicArrayRefs()
          Return the set of all references to arrays of fundamental types.
 Comment getComment()
          Return the comment associated with this symbol.
 int getDepth()
          Return how many levels of refinement this type is from a basic type.
 Metadata getMetadata()
          Return the metadata associated with this symbol.
 SymbolID getSymbolID()
          Return the identifier associated with this symbol.
abstract  java.util.Set getSymbolReferences()
          Return the set of symbols (in the form of SymbolID) referenced by this particular symbol.
 int getSymbolType()
          Return the type of this symbol, one of CLASS, ENUM, INTERFACE, or PACKAGE.
 java.lang.String getSymbolTypeString()
          Return the type string associated with this symbol.
 boolean getUserSpecified()
          Indicate whether this is a user-specified symbol (or one resulting from dependency resolution)
 boolean hasAttribute(java.lang.String key)
           
 boolean isClass()
          Return TRUE if the symbol is a class; otherwise, return FALSE.
 boolean isInterface()
          Return TRUE if the type of this symbol is an interface; otherwise, return FALSE.
 boolean isPackage()
          Return TRUE if the symbol is a package; otherwise, return FALSE.
 boolean isStruct()
          Return TRUE if the symbol is a class; otherwise, return FALSE.
static int minimumDepth(java.util.Collection symbols)
          Return the minimum depth for a collection of symbols.
 void removeAttribute(java.lang.String key)
           
 void setAttribute(java.lang.String key)
           
 void setAttribute(java.lang.String key, java.lang.String value)
           
 void setComment(Comment comment)
          Alter the comment.
 void setUserSpecified(boolean val)
          Specify whether this symbol was given by the user on the Babel command line
 
Methods inherited from class gov.llnl.babel.symbols.SymbolID
compareTo, equals, fromXML, getFullName, getShortName, getShortName, getSymbolName, getVersion, hashCode, setFromXML
 
Methods inherited from class gov.llnl.babel.symbols.ASTNode
checkFrozen, clone, protectCollection, protectList, protectMap, protectSet
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.lang.Comparable
compareTo
 

Field Detail

ENUM

public static final int ENUM
See Also:
Constant Field Values

STRUCT

public static final int STRUCT
See Also:
Constant Field Values

CLASS

public static final int CLASS
See Also:
Constant Field Values

INTERFACE

public static final int INTERFACE
See Also:
Constant Field Values

PACKAGE

public static final int PACKAGE
See Also:
Constant Field Values

s_type

public static final java.lang.String[] s_type

SCOPE

public static final java.lang.String SCOPE
See Also:
Constant Field Values

d_context

protected Context d_context
Constructor Detail

Symbol

public Symbol(SymbolID id,
              int type,
              Comment comment,
              Context context)
Initialize the Symbol abstact base class by providing a symbol identifier and its type (one of CLASS, ENUM, INTERFACE, or PACKAGE, or STRUCT). The metadata is constructed using the current date and time.


Symbol

public Symbol(SymbolID id,
              int type,
              Comment comment,
              Metadata metadata,
              Context context)
Initialize the Symbol abstract base class by providing a symbol identifier, a symbol type, a comment, and a metadata object.

Method Detail

getComment

public Comment getComment()
Return the comment associated with this symbol. The return argument may be null if no comment was defined.


setComment

public void setComment(Comment comment)
Alter the comment.

Parameters:
comment - the new comment.

getUserSpecified

public boolean getUserSpecified()
Indicate whether this is a user-specified symbol (or one resulting from dependency resolution)


getDepth

public int getDepth()
Return how many levels of refinement this type is from a basic type. For enumerations and packages, this returns zero. For classes, it returns the distance from sidl.BaseClass. For interfaces, it returns the distance from sidl.BaseInterface.


minimumDepth

public static int minimumDepth(java.util.Collection symbols)
Return the minimum depth for a collection of symbols.

Returns:
This will always return a value greater or equal to zero.

setUserSpecified

public void setUserSpecified(boolean val)
Specify whether this symbol was given by the user on the Babel command line


getMetadata

public Metadata getMetadata()
Return the metadata associated with this symbol.

Specified by:
getMetadata in interface IMetadata

addMetadata

public void addMetadata(java.lang.String keyword,
                        java.lang.String value)
Add a (keyword,value) pair to the metadata for this symbol.

Specified by:
addMetadata in interface IMetadata

getSymbolID

public SymbolID getSymbolID()
Return the identifier associated with this symbol.


getSymbolType

public int getSymbolType()
Return the type of this symbol, one of CLASS, ENUM, INTERFACE, or PACKAGE.


isPackage

public boolean isPackage()
Return TRUE if the symbol is a package; otherwise, return FALSE.


isInterface

public boolean isInterface()
Return TRUE if the type of this symbol is an interface; otherwise, return FALSE.


isClass

public boolean isClass()
Return TRUE if the symbol is a class; otherwise, return FALSE.


isStruct

public boolean isStruct()
Return TRUE if the symbol is a class; otherwise, return FALSE.


getSymbolTypeString

public java.lang.String getSymbolTypeString()
Return the type string associated with this symbol. The return argument may be null if no type was defined.


getSymbolReferences

public abstract java.util.Set getSymbolReferences()
Return the set of symbols (in the form of SymbolID) referenced by this particular symbol. The return argument may be null if this symbol contains no external references.


getAllSymbolReferences

public abstract java.util.Set getAllSymbolReferences()
Return the symbol references for the whole type hierarchy rooted with this symbol. For packages, this recurses down the package hierarchy.


getBasicArrayRefs

public abstract java.util.Set getBasicArrayRefs()
Return the set of all references to arrays of fundamental types.


hasAttribute

public boolean hasAttribute(java.lang.String key)
Specified by:
hasAttribute in interface Attributes

getAttribute

public java.lang.String getAttribute(java.lang.String key)
Specified by:
getAttribute in interface Attributes

setAttribute

public void setAttribute(java.lang.String key)
Specified by:
setAttribute in interface Attributes

setAttribute

public void setAttribute(java.lang.String key,
                         java.lang.String value)
Specified by:
setAttribute in interface Attributes

getAttributes

public java.util.Set getAttributes()
Specified by:
getAttributes in interface Attributes

removeAttribute

public void removeAttribute(java.lang.String key)
                     throws UnknownAttributeException
Specified by:
removeAttribute in interface Attributes
Throws:
UnknownAttributeException

freeze

public void freeze()
Overrides:
freeze in class ASTNode