gov.llnl.babel.symbols
Class Enumeration

java.lang.Object
  extended by gov.llnl.babel.symbols.ASTNode
      extended by gov.llnl.babel.symbols.SymbolID
          extended by gov.llnl.babel.symbols.Symbol
              extended by gov.llnl.babel.symbols.Enumeration
All Implemented Interfaces:
Attributes, IMetadata, java.lang.Comparable

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, d_context, ENUM, INTERFACE, PACKAGE, s_type, SCOPE, STRUCT
 
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(java.lang.String name, Comment comment)
          Add a new enumerator without a specified value.
 void addEnumerator(java.lang.String name, int value, boolean from_user)
          Add a new enumerator with a specified value.
 void addEnumerator(java.lang.String name, int value, boolean from_user, Comment comment)
          Add a new enumerator with a specified value.
 void addEnumerator(java.lang.String name, int value, Comment comment)
          Add a new enumerator with a specified value.
 boolean definedByUser(java.lang.String name)
          Return whether the specified enumerator name was defined by the user (true) or given a value (false).
 void freeze()
           
 java.util.Set getAllSymbolReferences()
          Return the symbol references for the whole type hierarchy rooted with this symbol.
 java.util.Set getBasicArrayRefs()
          Return a null object that represents the external basic arrays references by this enumerated type.
 Comment getEnumeratorComment(java.lang.String name)
          Return the comment, if any, for the specified enumerated name.
 java.util.List getEnumerators()
          Return the list of enumerators as a sorted list.
 int getEnumeratorValue(java.lang.String name)
          Return the value for the specified enumerated name.
 java.util.Iterator getIterator()
          Return an Iterator that will iterate over the elements of the enumeration.
 java.util.Set getSymbolReferences()
          Return a null object that represents the external symbols referenced by this enumerated type.
 boolean hasEnumerator(java.lang.String name)
          Return whether the current enumeration contains an enumerator with the specified name.
 
Methods inherited from class gov.llnl.babel.symbols.Symbol
addMetadata, getAttribute, getAttributes, getComment, getDepth, getMetadata, getSymbolID, 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, 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
 

Constructor Detail

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 Detail

addEnumerator

public void addEnumerator(java.lang.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(java.lang.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.


addEnumerator

public void addEnumerator(java.lang.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(java.lang.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.


hasEnumerator

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


getEnumerators

public java.util.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 java.util.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.


definedByUser

public boolean definedByUser(java.lang.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.


getEnumeratorValue

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


getEnumeratorComment

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


getSymbolReferences

public java.util.Set getSymbolReferences()
Return a null object that represents the external symbols referenced by this enumerated type.

Specified by:
getSymbolReferences in class Symbol

getAllSymbolReferences

public java.util.Set getAllSymbolReferences()
Description copied from class: Symbol
Return the symbol references for the whole type hierarchy rooted with this symbol. For packages, this recurses down the package hierarchy.

Specified by:
getAllSymbolReferences in class Symbol

getBasicArrayRefs

public java.util.Set getBasicArrayRefs()
Return a null object that represents the external basic arrays references by this enumerated type.

Specified by:
getBasicArrayRefs in class Symbol

freeze

public void freeze()
Overrides:
freeze in class Symbol