planetj.dataengine
Class RowClassGenerator

java.lang.Object
  extended byplanetj.dataengine.RowClassGenerator

public class RowClassGenerator
extends java.lang.Object

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


Field Summary
protected static java.lang.String CLASS_COMMENT
           
protected static java.lang.String COMMA
           
protected static java.lang.String CURLY_BRACE_OPEN
           
protected static java.lang.String CURLY_BRANCE_CLOSE
           
protected static java.lang.String DATAENGINE_COPYRIGHT
           
protected static java.lang.String EQUALS_SIGN
           
protected static java.lang.String EXTENDS
           
protected static java.lang.String GET
           
protected static java.lang.String GET_FIELD_VALUE
           
protected static java.lang.String GETTER_COMMENT_BEGIN
           
protected static java.lang.String INTERFACE_COMMENT
           
protected static java.lang.String LIBRARY_NAME
           
protected static java.lang.String METHOD_COMMENT_END
           
protected static java.lang.String NEW
           
protected static java.lang.String NEW_VALUE
           
protected static java.lang.String NUMBER
           
protected static java.lang.String OPEN_CLOSE_PAREN
           
protected static java.lang.String PACKAGE
           
protected static java.lang.String PUBLIC
           
protected static java.lang.String PUBLIC_CLASS
           
protected static java.lang.String PUBLIC_INTERFACE
           
protected static java.lang.String RETURN
           
protected static java.lang.String RETURN_THIS
           
protected static java.lang.String SEMICOLON
           
protected static java.lang.String SET
           
protected static java.lang.String SET_FIELD_VALUE
           
protected static java.lang.String SETTER_COMMENT_BEGIN
           
protected static java.lang.String STATIC_FINAL_STRING
           
protected static java.lang.String TABLE_NAME
           
protected static java.lang.String THROWS_CMEXCEPTION
           
protected static java.lang.String VALUE
           
protected static java.lang.String VOID
           
 
Constructor Summary
protected RowClassGenerator()
          RowClassGenerator constructor comment.
 
Method Summary
static void formatNames(java.lang.String pName, java.lang.StringBuffer pMethodName, java.lang.StringBuffer pConstantName)
          Formats a name into "Java method" format and "Java constant" format.
protected static java.lang.StringBuffer generateClassDefinitionBeginning(java.lang.String pPackageAndClassName, java.lang.StringBuffer pSB, boolean pIsInterface)
          Appends the beginning of a Java class or interface definition to a StringBuffer.
protected static java.lang.StringBuffer generateComment(java.lang.StringBuffer pSB, boolean pIsInterface)
          Generates a Java class or interface comment.
static java.lang.StringBuffer generateConstant(java.lang.String sqlName, java.lang.String constantName, java.lang.StringBuffer sb)
          Generates a Java code for defining a constant.
static java.lang.StringBuffer generateConstantComments(FieldDescriptorRow pFd, java.lang.StringBuffer pSB)
          Generates a Java constant comment
static java.lang.StringBuffer generateConstantTableProperties(RowClassProperties pProps, java.lang.StringBuffer sb)
          This method will generate the TABLE_NAME and LIBRARY_NAME constants Creation date: (4/9/2002 1:27:51 PM)
static java.lang.StringBuffer generateGetter(java.lang.String columnName, java.lang.String constant, java.lang.Class fieldType, boolean usePrimitive, java.lang.StringBuffer sb)
          Appends to a StringBuffer a String defining a Java method which gets the value of a field
protected static java.lang.StringBuffer generateNewNumberObject(java.lang.Class fieldClass, java.lang.String primitiveName, java.lang.StringBuffer sb)
          Appends a String of Java code for creating a new instance of a Java wrapper class (like Integer) to a StringBuffer.
protected static java.lang.StringBuffer generateObjectGetter(java.lang.String columnName, java.lang.String constant, java.lang.Class returnType, java.lang.StringBuffer method)
          Appends to a StringBuffer a String defining a Java method which gets the value of a field
protected static java.lang.StringBuffer generateObjectSetter(java.lang.String columnName, java.lang.String constant, java.lang.Class fieldType, java.lang.String thisClassName, java.lang.StringBuffer method)
          Appends to a StringBuffer a String defining a Java method which sets the value of a field
protected static java.lang.StringBuffer generatePrimitiveNumberGetter(java.lang.String columnName, java.lang.String constant, java.lang.Class returnType, java.lang.StringBuffer method)
          Appends to a StringBuffer a String defining a Java method which gets the value of a field as a primitive number.
protected static java.lang.StringBuffer generatePrimitiveNumberSetter(java.lang.String columnName, java.lang.String constant, java.lang.Class fieldType, java.lang.String thisClassName, java.lang.StringBuffer method)
          Appends to a StringBuffer a String defining a Java method which sets the value of a field, based on a primitive
static java.lang.String generateRowClass(java.util.Iterator pFieldDescriptors, RowClassProperties pProps)
          Generates a subclass of the Row class.
static java.lang.String generateRowClass(RowCollection pRC, RowClassProperties pProps)
          Generates a subclass of the Row class.
static java.lang.String generateRowClass(Table pTable, RowClassProperties pProps)
          Generates a subclass of the Row class.
static java.lang.String generateRowInterface(java.util.Iterator pFieldDescriptors, RowInterfaceProperties pProps)
          Generates an interface based on a Database Row.
static java.lang.String generateRowInterface(RowCollection pRC, RowInterfaceProperties pProps)
          Generates an interface based on a Database Row.
static java.lang.String generateRowInterface(Table pTable, RowInterfaceProperties pProps)
          Generates an interface based on a Database Row.
static java.lang.StringBuffer generateSetter(java.lang.String columnName, java.lang.String constant, java.lang.Class fieldType, boolean usePrimitive, java.lang.String className, java.lang.StringBuffer sb)
          Appends to a StringBuffer a String defining a Java method which sets the value of a field
static java.lang.String write(java.lang.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
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STATIC_FINAL_STRING

protected static final java.lang.String STATIC_FINAL_STRING
See Also:
Constant Field Values

GETTER_COMMENT_BEGIN

protected static final java.lang.String GETTER_COMMENT_BEGIN
See Also:
Constant Field Values

SETTER_COMMENT_BEGIN

protected static final java.lang.String SETTER_COMMENT_BEGIN
See Also:
Constant Field Values

METHOD_COMMENT_END

protected static final java.lang.String METHOD_COMMENT_END
See Also:
Constant Field Values

EQUALS_SIGN

protected static final java.lang.String EQUALS_SIGN
See Also:
Constant Field Values

SEMICOLON

protected static final java.lang.String SEMICOLON
See Also:
Constant Field Values

PUBLIC_CLASS

protected static final java.lang.String PUBLIC_CLASS
See Also:
Constant Field Values

PUBLIC_INTERFACE

protected static final java.lang.String PUBLIC_INTERFACE
See Also:
Constant Field Values

CURLY_BRACE_OPEN

protected static final java.lang.String CURLY_BRACE_OPEN
See Also:
Constant Field Values

CURLY_BRANCE_CLOSE

protected static final java.lang.String CURLY_BRANCE_CLOSE
See Also:
Constant Field Values

OPEN_CLOSE_PAREN

protected static final java.lang.String OPEN_CLOSE_PAREN
See Also:
Constant Field Values

GET

protected static final java.lang.String GET
See Also:
Constant Field Values

SET

protected static final java.lang.String SET
See Also:
Constant Field Values

PUBLIC

protected static final java.lang.String PUBLIC
See Also:
Constant Field Values

VOID

protected static final java.lang.String VOID
See Also:
Constant Field Values

GET_FIELD_VALUE

protected static final java.lang.String GET_FIELD_VALUE
See Also:
Constant Field Values

SET_FIELD_VALUE

protected static final java.lang.String SET_FIELD_VALUE
See Also:
Constant Field Values

THROWS_CMEXCEPTION

protected static final java.lang.String THROWS_CMEXCEPTION
See Also:
Constant Field Values

RETURN

protected static final java.lang.String RETURN
See Also:
Constant Field Values

NUMBER

protected static final java.lang.String NUMBER
See Also:
Constant Field Values

VALUE

protected static final java.lang.String VALUE
See Also:
Constant Field Values

NEW_VALUE

protected static final java.lang.String NEW_VALUE
See Also:
Constant Field Values

RETURN_THIS

protected static final java.lang.String RETURN_THIS
See Also:
Constant Field Values

COMMA

protected static final java.lang.String COMMA
See Also:
Constant Field Values

NEW

protected static final java.lang.String NEW
See Also:
Constant Field Values

PACKAGE

protected static final java.lang.String PACKAGE
See Also:
Constant Field Values

CLASS_COMMENT

protected static final java.lang.String CLASS_COMMENT

INTERFACE_COMMENT

protected static final java.lang.String INTERFACE_COMMENT

EXTENDS

protected static final java.lang.String EXTENDS
See Also:
Constant Field Values

LIBRARY_NAME

protected static final java.lang.String LIBRARY_NAME
See Also:
Constant Field Values

TABLE_NAME

protected static final java.lang.String TABLE_NAME
See Also:
Constant Field Values

DATAENGINE_COPYRIGHT

protected static final java.lang.String DATAENGINE_COPYRIGHT
See Also:
Constant Field Values
Constructor Detail

RowClassGenerator

protected RowClassGenerator()
RowClassGenerator constructor comment.

Method Detail

formatNames

public static void formatNames(java.lang.String pName,
                               java.lang.StringBuffer pMethodName,
                               java.lang.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

generateClassDefinitionBeginning

protected static java.lang.StringBuffer generateClassDefinitionBeginning(java.lang.String pPackageAndClassName,
                                                                         java.lang.StringBuffer pSB,
                                                                         boolean pIsInterface)
Appends the beginning of a Java class or interface definition to a StringBuffer.

Parameters:
pSB - The StringBuffer to append the class definition to
pIsInterface - true if this class to be generated is an interface
Returns:
The StringBuffer

generateComment

protected static java.lang.StringBuffer generateComment(java.lang.StringBuffer pSB,
                                                        boolean pIsInterface)
Generates a Java class or interface comment.

Parameters:
pSB - A StringBuffer to which the comment will be appended
pIsInterface - true if this class to be generated is an interface
Returns:
The StringBuffer

generateConstant

public static java.lang.StringBuffer generateConstant(java.lang.String sqlName,
                                                      java.lang.String constantName,
                                                      java.lang.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 java.lang.StringBuffer generateConstantComments(FieldDescriptorRow pFd,
                                                              java.lang.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
Throws:
CMException

generateConstantTableProperties

public static java.lang.StringBuffer generateConstantTableProperties(RowClassProperties pProps,
                                                                     java.lang.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 java.lang.StringBuffer generateGetter(java.lang.String columnName,
                                                    java.lang.String constant,
                                                    java.lang.Class fieldType,
                                                    boolean usePrimitive,
                                                    java.lang.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

generateNewNumberObject

protected static java.lang.StringBuffer generateNewNumberObject(java.lang.Class fieldClass,
                                                                java.lang.String primitiveName,
                                                                java.lang.StringBuffer sb)
Appends a String of Java code for creating a new instance of a Java wrapper class (like Integer) to a StringBuffer.

Parameters:
fieldClass - The type of object the field holds
primitiveName - The name of the primitive type (like "int")
sb - The StringBuffer to which the Java code will be appended.
Returns:
The StringBuffer

generateObjectGetter

protected static java.lang.StringBuffer generateObjectGetter(java.lang.String columnName,
                                                             java.lang.String constant,
                                                             java.lang.Class returnType,
                                                             java.lang.StringBuffer method)
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.
returnType - The type of object to return (this must not be a primitive type)
method - The StringBuffer to which the method will be appended
Returns:
The StringBuffer

generateObjectSetter

protected static java.lang.StringBuffer generateObjectSetter(java.lang.String columnName,
                                                             java.lang.String constant,
                                                             java.lang.Class fieldType,
                                                             java.lang.String thisClassName,
                                                             java.lang.StringBuffer method)
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.
thisClassName - 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.
method - The StringBuffer to which the method will be appended
Returns:
The StringBuffer

generatePrimitiveNumberGetter

protected static java.lang.StringBuffer generatePrimitiveNumberGetter(java.lang.String columnName,
                                                                      java.lang.String constant,
                                                                      java.lang.Class returnType,
                                                                      java.lang.StringBuffer method)
Appends to a StringBuffer a String defining a Java method which gets the value of a field as a primitive number.

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.
returnType - The type of primitive to return. This should be the int, short, byte, float, double, or long class object.
method - The StringBuffer to which the method will be appended
Returns:
The StringBuffer

generatePrimitiveNumberSetter

protected static java.lang.StringBuffer generatePrimitiveNumberSetter(java.lang.String columnName,
                                                                      java.lang.String constant,
                                                                      java.lang.Class fieldType,
                                                                      java.lang.String thisClassName,
                                                                      java.lang.StringBuffer method)
Appends to a StringBuffer a String defining a Java method which sets the value of a field, based on a primitive

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.
thisClassName - 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.
method - The StringBuffer to which the method will be appended
Returns:
The StringBuffer

generateRowClass

public static java.lang.String generateRowClass(java.util.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.
Throws:
CMException

generateRowClass

public static java.lang.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.
Throws:
CMException

generateRowClass

public static java.lang.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.
Throws:
CMException

generateRowInterface

public static java.lang.String generateRowInterface(java.util.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.
Throws:
CMException

generateRowInterface

public static java.lang.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.
Throws:
CMException

generateRowInterface

public static java.lang.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.
Throws:
CMException

generateSetter

public static java.lang.StringBuffer generateSetter(java.lang.String columnName,
                                                    java.lang.String constant,
                                                    java.lang.Class fieldType,
                                                    boolean usePrimitive,
                                                    java.lang.String className,
                                                    java.lang.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 java.lang.String write(java.lang.String pClassDef,
                                     RowClassProperties pProps)
                              throws CMException
Write the generate class/interface file to the fileLocation Creation date: (4/1/2002 6:22:55 PM)

Throws:
CMException