net.sf.farrago.catalog.codegen
Class CppEnumGen

java.lang.Object
  extended by net.sf.farrago.catalog.codegen.CppEnumGen

public class CppEnumGen
extends Object

CppEnumGen is a tool for generating a C++ enumeration based on the public static final data members of a Java class.

Version:
$Id: //open/dev/farrago/src/net/sf/farrago/catalog/codegen/CppEnumGen.java#15 $
Author:
John V. Sichi

Field Summary
private  PrintWriter pw
           
 
Constructor Summary
CppEnumGen(PrintWriter pw)
          Creates a new CppEnumGen.
 
Method Summary
 void generateEnumForClass(String enumName, Class enumClass, Class enumSymbolType)
          Generates a single enumeration.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

pw

private PrintWriter pw
Constructor Detail

CppEnumGen

public CppEnumGen(PrintWriter pw)
Creates a new CppEnumGen.

Parameters:
pw - PrintWriter to which enumeration definitions should be written
Method Detail

generateEnumForClass

public void generateEnumForClass(String enumName,
                                 Class enumClass,
                                 Class enumSymbolType)
                          throws Exception
Generates a single enumeration. Enumeration values (and their names) is based on the subset of non-inherited public static final data members contained by enumClass and having exact type enumSymbolType. Enumeration order (and hence implied ordinals) is on the current locale's collation order for the enum field names. This ordering may not hold in the future, so no C++ code should be written which depends on the current deterministic ordering.

TODO: Support integer ordinals. Also, we'd prefer to preserve the original metamodel ordering in order to relax the ordering condition above.

Parameters:
enumName - name to give C++ enum
enumClass - Java class to be interpreted as an enumeration; this class's name is used as the enumeration name
enumSymbolType - Java class used to determine enumeration membership
Throws:
Exception