planetj.dataengine
Class RowClassGenerator

java.lang.Object
  |
  +--planetj.dataengine.RowClassGenerator

public class RowClassGenerator
extends Object

Contains methods for generating a subclass of planetj.database.Row


Method Summary
static void formatNames(String pName, StringBuffer pMethodName, StringBuffer pConstantName)
          Formats a name into "Java method" format and "Java constant" format.
static StringBuffer generateConstant(String sqlName, String constantName, StringBuffer sb)
          Generates a Java code for defining a constant.
static StringBuffer generateConstantComments(FieldDescriptorRow pFd, StringBuffer pSB)
          Generates a Java constant comment
static StringBuffer generateConstantTableProperties(RowClassProperties pProps, StringBuffer sb)
          This method will generate the TABLE_NAME and LIBRARY_NAME constants Creation date: (4/9/2002 1:27:51 PM)
static StringBuffer generateGetter(String columnName, String constant, Class fieldType, boolean usePrimitive, StringBuffer sb)
          Appends to a StringBuffer a String defining a Java method which gets the value of a field
static String generateRowClass(Iterator pFieldDescriptors, RowClassProperties pProps)
          Generates a subclass of the Row class.
static String generateRowClass(RowCollection pRC, RowClassProperties pProps)
          Generates a subclass of the Row class.
static String generateRowClass(Table pTable, RowClassProperties pProps)
          Generates a subclass of the Row class.
static String generateRowInterface(Iterator pFieldDescriptors, RowInterfaceProperties pProps)
          Generates an interface based on a Database Row.
static String generateRowInterface(RowCollection pRC, RowInterfaceProperties pProps)
          Generates an interface based on a Database Row.
static String generateRowInterface(Table pTable, RowInterfaceProperties pProps)
          Generates an interface based on a Database Row.
static StringBuffer generateSetter(String columnName, String constant, Class fieldType, boolean usePrimitive, String className, StringBuffer sb)
          Appends to a StringBuffer a String defining a Java method which sets the value of a field
static String write(String pClassDef, RowClassProperties pProps)
          Write the generate class/interface file to the fileLocation Creation date: (4/1/2002 6:22:55 PM)
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

formatNames

public static void formatNames(String pName,
                               StringBuffer pMethodName,
                               StringBuffer pConstantName)
Formats a name into "Java method" format and "Java constant" format. The String "billy is MY name" is formatted to "BillyIsMyName" for the method format and "BILLY_IS_MY_NAME" for constant format.

Parameters:
pName - The name to format
pMethodName - A StringBuffer which will contain the method fomatted name
pConstantName - A StringBuffer which will contain the constant formatted name

generateConstant

public static StringBuffer generateConstant(String sqlName,
                                            String constantName,
                                            StringBuffer sb)
Generates a Java code for defining a constant.

Parameters:
sqlName - The SQL name of the field
constantName - The name of the constant
sb - The StringBuffer to append the Java code to
Returns:
The StringBuffer

generateConstantComments

public static StringBuffer generateConstantComments(FieldDescriptorRow pFd,
                                                    StringBuffer pSB)
                                             throws CMException
Generates a Java constant comment

Parameters:
pSB - A StringBuffer to which the comment will be appended
pFd - FieldDescriptorRow describing the field.
Returns:
The StringBuffer
CMException

generateConstantTableProperties

public static StringBuffer generateConstantTableProperties(RowClassProperties pProps,
                                                           StringBuffer sb)
This method will generate the TABLE_NAME and LIBRARY_NAME constants Creation date: (4/9/2002 1:27:51 PM)


generateGetter

public static StringBuffer generateGetter(String columnName,
                                          String constant,
                                          Class fieldType,
                                          boolean usePrimitive,
                                          StringBuffer sb)
Appends to a StringBuffer a String defining a Java method which gets the value of a field

Parameters:
columnName - The name of the column. The method's name will be the String "get" with this parameter appended on. If the constant parameter is null, then this value must be the field's SQL name.
constant - The constant which maps a field's SQL name to a human-formatted name.
fieldType - The type of object the field holds
usePrimitive - Whether or not the generated method should return a primitive. This parameter is ignored if there is no primitive type which corresponds to the type of object the field holds.
sb - The StringBuffer to which the method will be appended
Returns:
The StringBuffer

generateRowClass

public static String generateRowClass(Iterator pFieldDescriptors,
                                      RowClassProperties pProps)
                               throws CMException
Generates a subclass of the Row class. The generated class is returned as Java source code in a String, and possibly saved to the file system.

Parameters:
pFieldDescriptors - The field descriptors describing the fields which the generated class should support
pProps - A RowClassProperties object containing properties describing how the class should be genereated.
CMException

generateRowClass

public static String generateRowClass(RowCollection pRC,
                                      RowClassProperties pProps)
                               throws CMException
Generates a subclass of the Row class. The generated class is returned as Java source code in a String, and possibly saved to the file system.

Parameters:
pRC - A RowCollection containg field descriptors which describe the fields the generated class should support
pProps - A RowClassProperties object containing properties describing how the class should be genereated.
CMException

generateRowClass

public static String generateRowClass(Table pTable,
                                      RowClassProperties pProps)
                               throws CMException
Generates a subclass of the Row class. The generated class is returned as Java source code in a String, and possibly saved to the file system.

Parameters:
pTable - A Table containg field descriptors which describe the fields the generated class should support
pProps - A RowClassProperties object containing properties describing how the class should be genereated.
CMException

generateRowInterface

public static String generateRowInterface(Iterator pFieldDescriptors,
                                          RowInterfaceProperties pProps)
                                   throws CMException
Generates an interface based on a Database Row. The generated interface is returned as Java source code in a String, and possibly saved to the file system.

Parameters:
pFieldDescriptors - The field descriptors describing the fields which the generated class should support
pProps - A RowInterfaceProperties object containing properties describing how the class should be genereated.
CMException

generateRowInterface

public static String generateRowInterface(RowCollection pRC,
                                          RowInterfaceProperties pProps)
                                   throws CMException
Generates an interface based on a Database Row. The generated interface is returned as Java source code in a String, and possibly saved to the file system.

Parameters:
pRC - A RowCollection containg field descriptors which describe the fields the generated class should support
pProps - A RowInterfaceProperties object containing properties describing how the class should be genereated.
CMException

generateRowInterface

public static String generateRowInterface(Table pTable,
                                          RowInterfaceProperties pProps)
                                   throws CMException
Generates an interface based on a Database Row. The generated interface is returned as Java source code in a String, and possibly saved to the file system.

Parameters:
pTable - A Table containg field descriptors which describe the fields the generated class should support
pProps - A RowInterfaceProperties object containing properties describing how the class should be genereated.
CMException

generateSetter

public static StringBuffer generateSetter(String columnName,
                                          String constant,
                                          Class fieldType,
                                          boolean usePrimitive,
                                          String className,
                                          StringBuffer sb)
Appends to a StringBuffer a String defining a Java method which sets the value of a field

Parameters:
columnName - The name of the column. The method's name will be the String "get" with this parameter appended on. If the constant parameter is null, then this value must be the field's SQL name.
constant - The constant which maps a field's SQL name to a human-formatted name.
usePrimitive - Whether or not the set method should take in a primitive or an Object. This parameter is ignored if there is no corresponding primitive type for the field type.
className - The name of the class for which this method is generated. The generated method will have this type of return value (so it can return "this") as long as this parameter is not null. If this parameter is null, the generated method will have a return type of void.
sb - The StringBuffer to which the method will be appended
Returns:
The StringBuffer

write

public static String write(String pClassDef,
                           RowClassProperties pProps)
                    throws CMException
Write the generate class/interface file to the fileLocation Creation date: (4/1/2002 6:22:55 PM)

CMException