gov.llnl.babel.symbols

Class Enumeration

Implemented Interfaces:
Comparable, Attributes, Comparable, IMetadata

public class Enumeration
extends Symbol

The Enumeration class represents a collection of enumerated symbols with specified integer values. Values for enumeration symbols not specified by the user are assigned values in an arbitrary fashion.

Field Summary

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

CLASS, ENUM, INTERFACE, PACKAGE, SCOPE, STRUCT, d_context, 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

Enumeration(SymbolID id, Comment comment, Context context)
Create a new Enumeration with the specified symbol identifier and comment.
Enumeration(SymbolID id, Comment comment, Metadata metadata, Context context)
Create a new Enumeration with the specified symbol identifier, comment, and metadata.

Method Summary

void
addEnumerator(String name, Comment comment)
Add a new enumerator without a specified value.
void
addEnumerator(String name, int value, boolean from_user)
Add a new enumerator with a specified value.
void
addEnumerator(String name, int value, boolean from_user, Comment comment)
Add a new enumerator with a specified value.
void
addEnumerator(String name, int value, Comment comment)
Add a new enumerator with a specified value.
boolean
definedByUser(String name)
Return whether the specified enumerator name was defined by the user (true) or given a value (false).
void
freeze()
Set
getAllSymbolReferences()
Set
getBasicArrayRefs()
Return a null object that represents the external basic arrays references by this enumerated type.
Comment
getEnumeratorComment(String name)
Return the comment, if any, for the specified enumerated name.
int
getEnumeratorValue(String name)
Return the value for the specified enumerated name.
List
getEnumerators()
Return the list of enumerators as a sorted list.
Iterator
getIterator()
Return an Iterator that will iterate over the elements of the enumeration.
Set
getSymbolReferences()
Return a null object that represents the external symbols referenced by this enumerated type.
boolean
hasEnumerator(String name)
Return whether the current enumeration contains an enumerator with the specified name.

Methods inherited from class gov.llnl.babel.symbols.Symbol

addMetadata, freeze, getAllSymbolReferences, getAttribute, getAttributes, getBasicArrayRefs, getComment, getDepth, getMetadata, getSymbolID, getSymbolReferences, getSymbolType, getSymbolTypeString, getUserSpecified, hasAttribute, isClass, isInterface, isPackage, isStruct, minimumDepth, removeAttribute, setAttribute, setAttribute, setComment, setUserSpecified

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

Constructor Details

Enumeration

public Enumeration(SymbolID id,
                   Comment comment,
                   Context context)
Create a new Enumeration with the specified symbol identifier and comment.

Enumeration

public Enumeration(SymbolID id,
                   Comment comment,
                   Metadata metadata,
                   Context context)
Create a new Enumeration with the specified symbol identifier, comment, and metadata.

Method Details

addEnumerator

public void addEnumerator(String name,
                          Comment comment)
Add a new enumerator without a specified value. If a previous enumerator exists with the same name, then this enumerator will replace the previous one. This enumerator will be assigned a value when its value is requested.

addEnumerator

public void addEnumerator(String name,
                          int value,
                          boolean from_user)
Add a new enumerator with a specified value. The flag indicates whether the value was assigned by the user or by the parser.

addEnumerator

public void addEnumerator(String name,
                          int value,
                          boolean from_user,
                          Comment comment)
Add a new enumerator with a specified value. The flag indicates whether the value was assigned by the user or by the parser. If a previous enumerator exists with the same name, then this enumerator will replace the previous one.

addEnumerator

public void addEnumerator(String name,
                          int value,
                          Comment comment)
Add a new enumerator with a specified value. If a previous enumerator exists with the same name, then this enumerator will replace the previous one.

definedByUser

public boolean definedByUser(String name)
Return whether the specified enumerator name was defined by the user (true) or given a value (false). If the specified name is not part of this enumerated collection, then return false.

freeze

public void freeze()
Overrides:
freeze in interface Symbol

getAllSymbolReferences

public Set getAllSymbolReferences()
Overrides:
getAllSymbolReferences in interface Symbol

getBasicArrayRefs

public Set getBasicArrayRefs()
Return a null object that represents the external basic arrays references by this enumerated type.
Overrides:
getBasicArrayRefs in interface Symbol

getEnumeratorComment

public Comment getEnumeratorComment(String name)
Return the comment, if any, for the specified enumerated name.

getEnumeratorValue

public int getEnumeratorValue(String name)
Return the value for the specified enumerated name. If the name was not previously defined, then assign it a unique integer value.

getEnumerators

public List getEnumerators()
Return the list of enumerators as a sorted list. Each element of the list is an element of the enumeration, each of which is a string.

getIterator

public Iterator getIterator()
Return an Iterator that will iterate over the elements of the enumeration. The iterator will iterate over the names of the elements of the enumeration, each of which is a string.

getSymbolReferences

public Set getSymbolReferences()
Return a null object that represents the external symbols referenced by this enumerated type.
Overrides:
getSymbolReferences in interface Symbol

hasEnumerator

public boolean hasEnumerator(String name)
Return whether the current enumeration contains an enumerator with the specified name.