gov.llnl.babel.symbols

Class Symbol

Implemented Interfaces:
Comparable, Attributes, Comparable, IMetadata
Known Direct Subclasses:
Enumeration, Extendable, Package, Struct

public abstract class Symbol
extends SymbolID
implements 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
static int
ENUM
static int
INTERFACE
static int
PACKAGE
static String
SCOPE
static int
STRUCT
protected Context
d_context
static String[]
s_type

Fields inherited from class gov.llnl.babel.symbols.SymbolID

SCOPE

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(String keyword, String value)
Add a (keyword,value) pair to the metadata for this symbol.
void
freeze()
abstract Set
getAllSymbolReferences()
Return the symbol references for the whole type hierarchy rooted with this symbol.
String
getAttribute(String key)
Set
getAttributes()
abstract 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 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.
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(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(Collection symbols)
Return the minimum depth for a collection of symbols.
void
removeAttribute(String key)
void
setAttribute(String key)
void
setAttribute(String key, 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, freeze, protectCollection, protectList, protectMap, protectSet

Field Details

CLASS

public static final int CLASS
Field Value:
13

ENUM

public static final int ENUM
Field Value:
11

INTERFACE

public static final int INTERFACE
Field Value:
14

PACKAGE

public static final int PACKAGE
Field Value:
15

SCOPE

public static final String SCOPE

STRUCT

public static final int STRUCT
Field Value:
12

d_context

protected Context d_context

s_type

public static final String[] s_type

Constructor Details

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 Details

addMetadata

public void addMetadata(String keyword,
                        String value)
Add a (keyword,value) pair to the metadata for this symbol.
Specified by:
addMetadata in interface IMetadata

freeze

public void freeze()
Overrides:
freeze in interface ASTNode

getAllSymbolReferences

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

getAttribute

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

getAttributes

public Set getAttributes()
Specified by:
getAttributes in interface Attributes

getBasicArrayRefs

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

getComment

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

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.

getMetadata

public Metadata getMetadata()
Return the metadata associated with this symbol.
Specified by:
getMetadata in interface IMetadata

getSymbolID

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

getSymbolReferences

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

getSymbolType

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

getSymbolTypeString

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

getUserSpecified

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

hasAttribute

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

isClass

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

isInterface

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

isPackage

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

isStruct

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

minimumDepth

public static int minimumDepth(Collection symbols)
Return the minimum depth for a collection of symbols.
Returns:
This will always return a value greater or equal to zero.

removeAttribute

public void removeAttribute(String key)
            throws UnknownAttributeException
Specified by:
removeAttribute in interface Attributes

setAttribute

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

setAttribute

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

setComment

public void setComment(Comment comment)
Alter the comment.
Parameters:
comment - the new comment.

setUserSpecified

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