edu.ksu.cis.projects.bogor.type
Class EnumType

java.lang.Object
  extended by edu.ksu.cis.projects.bogor.type.Type
      extended by edu.ksu.cis.projects.bogor.type.PrimitiveType
          extended by edu.ksu.cis.projects.bogor.type.EnumType
All Implemented Interfaces:
Disposable, Serializable

public final class EnumType
extends PrimitiveType

Represents an enum type.

Version:
CVS $Revision: 1.4 $ $Date: 2005/01/29 04:54:31 $
Author:
Robby
See Also:
Serialized Form

Field Summary
 
Fields inherited from class edu.ksu.cis.projects.bogor.type.Type
hashCode, typeId
 
Method Summary
 void addEnumConstant(String enumConstant)
          Adds an enum constant.
 void dispose()
          Removes reference to id and clears enum constants.
 boolean equals(Object o)
          Checks whether this object is equal to another object.
 String getEnumConstant(int index)
          Gets an enum constant at a specified index.
 int getEnumConstantCount()
          Gets the number of enum constants.
 int getEnumConstantIndex(String enumConstant)
          Gets an index of an enum constant.
 String getId()
          Gets the id.
 boolean hasEnumConstant(String enumConstant)
          Determine whether an enum constant is an enum constant of this enum type.
 ASTType toASTType()
          Get a newly constructed (unowned) syntax tree node suitable for declaring this type statically.
 String toString()
          Returns the string representation of this object.
 String toVerboseString()
          Returns the verbose string representation of this object.
 
Methods inherited from class edu.ksu.cis.projects.bogor.type.Type
getTypeId, hashCode
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

getEnumConstant

public String getEnumConstant(int index)
Gets an enum constant at a specified index.

Parameters:
index - The index of the enum constant.
Returns:
The enum constant at the specified index. Non-null.

getEnumConstantCount

public int getEnumConstantCount()
Gets the number of enum constants.

Returns:
The number of enum constants.

getEnumConstantIndex

public int getEnumConstantIndex(String enumConstant)
Gets an index of an enum constant.

Parameters:
enumConstant - The name of the enum constant. Must be an enum constant of this enum type.
Returns:
The index of the enum constant. At least zero.

getId

public String getId()
Gets the id.

Returns:
The id. Non-null.

addEnumConstant

public void addEnumConstant(String enumConstant)
Adds an enum constant.

Parameters:
enumConstant - The enum constant. Must be non-null. This enum must not already contains the enum constant.

dispose

public void dispose()
Removes reference to id and clears enum constants. Once called, avoid using this object.


equals

public boolean equals(Object o)
Checks whether this object is equal to another object.

Overrides:
equals in class Object
Parameters:
o - Another object to check equality to.
Returns:
True, if the enum names are the same. False, otherwise.

hasEnumConstant

public boolean hasEnumConstant(String enumConstant)
Determine whether an enum constant is an enum constant of this enum type.

Parameters:
enumConstant - The enum constant. Must be non-null.
Returns:
True, if the enum constant is an enum constant of this enum type. False, otherwise.

toString

public String toString()
Returns the string representation of this object.

Overrides:
toString in class Object
Returns:
"id".

toVerboseString

public String toVerboseString()
Returns the verbose string representation of this object.

Returns:
"enum id { ( "," enumconstants )+ }".

toASTType

public ASTType toASTType()
Get a newly constructed (unowned) syntax tree node suitable for declaring this type statically.

Specified by:
toASTType in class Type
Returns:
the node, or null if the type is undeclarable