de.mathema.pride.util
Class CreateTableTemplate

java.lang.Object
  extended by de.mathema.pride.util.CreateTableTemplate

public class CreateTableTemplate
extends java.lang.Object


Field Summary
protected  java.lang.String baseClassName
           
static java.lang.String BEAN
           
protected  java.lang.ClassLoader classLoader
           
protected  java.lang.String className
           
protected  java.lang.String dbDriver
           
protected  java.lang.String dbName
           
protected  java.lang.String generationType
           
static java.lang.String HYBRID
           
protected  java.lang.String passwd
           
protected  java.lang.String[] tableNames
           
protected  java.lang.String user
           
 
Constructor Summary
CreateTableTemplate(java.lang.String dbDriver, java.lang.String dbName, java.lang.String user, java.lang.String passwd, java.lang.String[] tableNames, java.lang.String className, java.lang.String generationType, java.lang.String baseClassName)
           
CreateTableTemplate(java.lang.String dbDriver, java.lang.String dbName, java.lang.String user, java.lang.String passwd, java.lang.String[] tableNames, java.lang.String className, java.lang.String generationType, java.lang.String baseClassName, java.lang.ClassLoader classLoader)
           
 
Method Summary
 java.lang.String create()
          Creates the entity type by successivly calling the write... functions
 java.lang.String extractBeanClass(java.lang.String className)
          Retrieve the value type mapped by a specified class.
 java.util.Set extractMappedFields(java.lang.String className)
          Retrieve the fields being mapped by a specified class.
 RecordDescriptor extractRecordDescriptor(java.lang.String className)
           
protected  java.util.HashMap getAllTableColums(TableDescription[] desc)
          Method to Extract all TableColumns from the TableDescriptions
protected  java.lang.String getBaseClassName(java.lang.String baseClassName, java.lang.String generationType)
          Determine the base class for the class to generate.
protected  java.lang.String getClassName(java.lang.String className)
           
 java.sql.Connection getDBConnection()
          Opens up a database connection accoring to the specified database driver, database name, user, and password
protected  java.lang.String getPackage(java.lang.String className)
           
 TableDescription[] getTableDescription(java.sql.Connection con)
          Generates a table description
protected  java.lang.String getTableIdType(TableDescription tabCols)
           
protected  java.lang.String getTableName(java.lang.String[] tables)
           
static void main(java.lang.String[] args)
          put your documentation comment here
 void writeAttributes(TableDescription[] desc, java.lang.String className, java.lang.String baseClassName, java.lang.String generationType, java.lang.StringBuffer buffer)
          Prints the data members to standard out
 void writeAuthor(TableDescription[] desc, java.lang.String className, java.lang.String baseClassName, java.lang.String generationType, java.lang.StringBuffer buffer)
          Prints the author tag to standard out, using the current database user and database name as an identificatio
 void writeClone(TableDescription[] desc, java.lang.String className, java.lang.String baseClassName, java.lang.String generationType, java.lang.StringBuffer buffer)
           
 void writeEntityReference(TableDescription[] desc, java.lang.String className, java.lang.String baseClassName, java.lang.String generationType, java.lang.StringBuffer buffer)
           
 void writeFooter(TableDescription[] desc, java.lang.String className, java.lang.String baseClassName, java.lang.String generationType, java.lang.StringBuffer buffer)
          Prints the footer to standard out, i.e. a reconstructor, a default constructor, a toString method, a clone method, and the closing bracket
 void writeGetMethods(TableDescription[] desc, java.lang.String className, java.lang.String baseClassName, java.lang.String generationType, java.lang.StringBuffer buffer)
          Prints the geter methods for all members to standard out
 void writeHeader(TableDescription[] desc, java.lang.String className, java.lang.String baseClassName, java.lang.String generationType, java.lang.StringBuffer buffer)
          Prints the class header to standard out
 void writePackage(TableDescription[] desc, java.lang.String className, java.lang.String baseClassName, java.lang.String generationType, java.lang.StringBuffer buffer)
          Prints the package name to standard out
 void writePrimaryKey(TableDescription[] desc, java.lang.String className, java.lang.String baseClassName, java.lang.String generationType, java.lang.StringBuffer buffer)
          Prints the primary key definition and its access function to standard out
 void writeReconstructor(TableDescription desc, java.lang.String className, java.lang.String baseClassName, java.lang.StringBuffer buffer)
          Prints a reconstructor to restore an existing records from its primary key fields
 void writeRecordDescriptor(TableDescription[] desc, java.lang.String className, java.lang.String baseClassName, java.lang.String generationType, java.lang.StringBuffer buffer)
          Prints the record descriptor and its access function to standard out
 void writeSetMethods(TableDescription[] desc, java.lang.String className, java.lang.String baseClassName, java.lang.String generationType, java.lang.StringBuffer buffer)
          Prints the seter methods for all members to standard out
 void writeToString(TableDescription[] desc, java.lang.String className, java.lang.String generationType, java.lang.StringBuffer buffer)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HYBRID

public static final java.lang.String HYBRID
See Also:
Constant Field Values

BEAN

public static final java.lang.String BEAN
See Also:
Constant Field Values

dbDriver

protected java.lang.String dbDriver

dbName

protected java.lang.String dbName

user

protected java.lang.String user

passwd

protected java.lang.String passwd

className

protected java.lang.String className

baseClassName

protected java.lang.String baseClassName

generationType

protected java.lang.String generationType

tableNames

protected java.lang.String[] tableNames

classLoader

protected java.lang.ClassLoader classLoader
Constructor Detail

CreateTableTemplate

public CreateTableTemplate(java.lang.String dbDriver,
                           java.lang.String dbName,
                           java.lang.String user,
                           java.lang.String passwd,
                           java.lang.String[] tableNames,
                           java.lang.String className,
                           java.lang.String generationType,
                           java.lang.String baseClassName)
                    throws java.sql.SQLException
Throws:
java.sql.SQLException

CreateTableTemplate

public CreateTableTemplate(java.lang.String dbDriver,
                           java.lang.String dbName,
                           java.lang.String user,
                           java.lang.String passwd,
                           java.lang.String[] tableNames,
                           java.lang.String className,
                           java.lang.String generationType,
                           java.lang.String baseClassName,
                           java.lang.ClassLoader classLoader)
                    throws java.sql.SQLException
Throws:
java.sql.SQLException
Method Detail

extractRecordDescriptor

public RecordDescriptor extractRecordDescriptor(java.lang.String className)
                                         throws java.sql.SQLException
Throws:
java.sql.SQLException

extractMappedFields

public java.util.Set extractMappedFields(java.lang.String className)
                                  throws java.sql.SQLException
Retrieve the fields being mapped by a specified class. Retrieval is performed by reflection, assuming that the class contains a static RecordDescriptor field "red" which the field names can be retrieved from by RecordDescriptor.getFieldNames(java.lang.String[]). If you override the template method writeRecordDescriptor(de.mathema.pride.util.TableDescription[], java.lang.String, java.lang.String, java.lang.String, java.lang.StringBuffer) to create record descriptor definitions differently, make sure to also adapt this function accordingly.
ATTENTION: This function tries to override standard security restrictions to access the protected record descriptor member. This may cause security exceptions.

Parameters:
className - The name of the class to retrieve the mapped fields from
Returns:
The mapped fields
Throws:
java.sql.SQLException

extractBeanClass

public java.lang.String extractBeanClass(java.lang.String className)
                                  throws java.sql.SQLException
Retrieve the value type mapped by a specified class. Retrieval is performed by reflection, assuming that the class contains a static RecordDescriptor field "red" which the value type name can be retrieved from by RecordDescriptor.getObjectType().

Parameters:
className - The name of the class to retrieve the value type from
Returns:
The name of the value type
Throws:
java.sql.SQLException

create

public java.lang.String create()
                        throws java.sql.SQLException
Creates the entity type by successivly calling the write... functions

Throws:
java.sql.SQLException

getDBConnection

public java.sql.Connection getDBConnection()
Opens up a database connection accoring to the specified database driver, database name, user, and password


getTableDescription

public TableDescription[] getTableDescription(java.sql.Connection con)
                                       throws java.sql.SQLException
Generates a table description

Throws:
java.sql.SQLException

writePackage

public void writePackage(TableDescription[] desc,
                         java.lang.String className,
                         java.lang.String baseClassName,
                         java.lang.String generationType,
                         java.lang.StringBuffer buffer)
Prints the package name to standard out


writeAuthor

public void writeAuthor(TableDescription[] desc,
                        java.lang.String className,
                        java.lang.String baseClassName,
                        java.lang.String generationType,
                        java.lang.StringBuffer buffer)
Prints the author tag to standard out, using the current database user and database name as an identificatio


getBaseClassName

protected java.lang.String getBaseClassName(java.lang.String baseClassName,
                                            java.lang.String generationType)
                                     throws java.sql.SQLException
Determine the base class for the class to generate. When generating a hybrid type, the base class is MappedObject, for adapters it is ObjectAdapter and for beans it is nothing. If a base class is passed, it is takes as is. In case of bean generation, the base class is assumed to specify the base adapter class and the baes bean class is extracted by reflection.

Throws:
java.sql.SQLException

writeHeader

public void writeHeader(TableDescription[] desc,
                        java.lang.String className,
                        java.lang.String baseClassName,
                        java.lang.String generationType,
                        java.lang.StringBuffer buffer)
                 throws java.sql.SQLException
Prints the class header to standard out

Throws:
java.sql.SQLException

writeRecordDescriptor

public void writeRecordDescriptor(TableDescription[] desc,
                                  java.lang.String className,
                                  java.lang.String baseClassName,
                                  java.lang.String generationType,
                                  java.lang.StringBuffer buffer)
                           throws java.sql.SQLException
Prints the record descriptor and its access function to standard out

Throws:
java.sql.SQLException

writeEntityReference

public void writeEntityReference(TableDescription[] desc,
                                 java.lang.String className,
                                 java.lang.String baseClassName,
                                 java.lang.String generationType,
                                 java.lang.StringBuffer buffer)

writePrimaryKey

public void writePrimaryKey(TableDescription[] desc,
                            java.lang.String className,
                            java.lang.String baseClassName,
                            java.lang.String generationType,
                            java.lang.StringBuffer buffer)
Prints the primary key definition and its access function to standard out


writeAttributes

public void writeAttributes(TableDescription[] desc,
                            java.lang.String className,
                            java.lang.String baseClassName,
                            java.lang.String generationType,
                            java.lang.StringBuffer buffer)
                     throws java.sql.SQLException
Prints the data members to standard out

Throws:
java.sql.SQLException

writeGetMethods

public void writeGetMethods(TableDescription[] desc,
                            java.lang.String className,
                            java.lang.String baseClassName,
                            java.lang.String generationType,
                            java.lang.StringBuffer buffer)
                     throws java.sql.SQLException
Prints the geter methods for all members to standard out

Throws:
java.sql.SQLException

writeSetMethods

public void writeSetMethods(TableDescription[] desc,
                            java.lang.String className,
                            java.lang.String baseClassName,
                            java.lang.String generationType,
                            java.lang.StringBuffer buffer)
                     throws java.sql.SQLException
Prints the seter methods for all members to standard out

Throws:
java.sql.SQLException

writeToString

public void writeToString(TableDescription[] desc,
                          java.lang.String className,
                          java.lang.String generationType,
                          java.lang.StringBuffer buffer)

writeClone

public void writeClone(TableDescription[] desc,
                       java.lang.String className,
                       java.lang.String baseClassName,
                       java.lang.String generationType,
                       java.lang.StringBuffer buffer)

writeReconstructor

public void writeReconstructor(TableDescription desc,
                               java.lang.String className,
                               java.lang.String baseClassName,
                               java.lang.StringBuffer buffer)
Prints a reconstructor to restore an existing records from its primary key fields


writeFooter

public void writeFooter(TableDescription[] desc,
                        java.lang.String className,
                        java.lang.String baseClassName,
                        java.lang.String generationType,
                        java.lang.StringBuffer buffer)
Prints the footer to standard out, i.e. a reconstructor, a default constructor, a toString method, a clone method, and the closing bracket


getTableIdType

protected java.lang.String getTableIdType(TableDescription tabCols)
Parameters:
Tabellenbeschreibung -
Returns:
ID-Typ der Tabelle

getPackage

protected java.lang.String getPackage(java.lang.String className)

getClassName

protected java.lang.String getClassName(java.lang.String className)

getTableName

protected java.lang.String getTableName(java.lang.String[] tables)

getAllTableColums

protected java.util.HashMap getAllTableColums(TableDescription[] desc)
Method to Extract all TableColumns from the TableDescriptions

Returns:
HashMap with following Format: Key: TableDescription Value:HashMap with Format: Key: java.lang.String attributName Value: de.mathema.pride.util.TableColumns tableColumn

main

public static void main(java.lang.String[] args)
                 throws java.sql.SQLException
put your documentation comment here

Parameters:
args -
Throws:
java.sql.SQLException