Main Page | Packages | Class Hierarchy | Class List | File List | Class Members

treebuilder.TypeSafeEnum Class Reference

Inheritance diagram for treebuilder.TypeSafeEnum:

Inheritance graph
[legend]
List of all members.

Detailed Description

Yet another type safe enumeration base class.

This class supports the creation of multiple enumeration subclasses. In each subclass the enumeration values start at 0.

Documentation for this class can be found here. Apparently TypeSafeEnums are supported in the new version of Java. So at some point the classes that use this class should be replaced with something more generic.


Public Member Functions

 TypeSafeEnum (String name, Class cls)
String getName ()
int getValue ()
String toString ()

Static Public Member Functions

Iterator enumValues (Class cls)

Static Private Member Functions

enumInfo findInfo (Class cls, boolean add)
 Find the entry for the enumeration, if it exists.

Private Attributes

String mName
int mValue

Static Private Attributes

ArrayList infoVec = new ArrayList()


Constructor & Destructor Documentation

treebuilder.TypeSafeEnum.TypeSafeEnum String  name,
Class  cls
 

00062 { 00063 mName = name; 00064 enumInfo elem = findInfo( cls, true ); 00065 mValue = elem.count; 00066 elem.count++; 00067 elem.values.add( this ); 00068 } // TypeSafeEnum constructor


Member Function Documentation

Iterator treebuilder.TypeSafeEnum.enumValues Class  cls  )  [static]
 

00072 { 00073 Iterator iter = null; 00074 enumInfo elem = findInfo( cls, false ); 00075 if (elem != null) { 00076 iter = elem.values.iterator(); 00077 } 00078 return iter; 00079 } // enumValues

enumInfo treebuilder.TypeSafeEnum.findInfo Class  cls,
boolean  add
[static, private]
 

Find the entry for the enumeration, if it exists.

If not, add it to the end of the enumInfo. Note that this function has linear time, but the assumption is that there will not a large number of enumeration classes.

00094 { 00095 enumInfo foundElem = null; 00096 int hashCode = cls.hashCode(); 00097 for (Iterator iter = infoVec.iterator(); iter.hasNext(); ) { 00098 enumInfo elem = (enumInfo)iter.next(); 00099 if (elem.hashCode == hashCode) { 00100 foundElem = elem; 00101 break; 00102 } 00103 } 00104 if (foundElem == null && add) { 00105 foundElem = new enumInfo(hashCode); 00106 infoVec.add( foundElem ); 00107 } 00108 return foundElem; 00109 } // findInfo

String treebuilder.TypeSafeEnum.getName  ) 
 

00082 { return mName; }

int treebuilder.TypeSafeEnum.getValue  ) 
 

00083 { return mValue; }

String treebuilder.TypeSafeEnum.toString  ) 
 

00085 { return getName(); }


Member Data Documentation

ArrayList treebuilder.TypeSafeEnum.infoVec = new ArrayList() [static, private]
 

String treebuilder.TypeSafeEnum.mName [private]
 

int treebuilder.TypeSafeEnum.mValue [private]
 


The documentation for this class was generated from the following file:
Generated on Tue Sep 21 22:08:44 2004 for Building an in-memory tree using the XmlPullParser by doxygen 1.3.8