| 
 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectatg.cortex.CortexGenerator
public class CortexGenerator
This class is a utility that will generate a set of Cortex bean definitions from a schema definition properties file. The property file defines the names of tables, columns, column types, etc. This class will read this property file and generate a bean corresponding to each table, with a property corresponding to each column. The resulting beans will also implement CortexFactory, and will contain a static "createTableDeclaration" method that returns the table declaration that can be used to create the table in the database.
The schema definition properties file has the following definition:
| sqlType | java property type | 
|---|---|
| BIT | boolean | 
| TINYINT | byte | 
| SMALLINT | short | 
| INTEGER | int | 
| BIGINT | long | 
| FLOAT | double | 
| REAL | float | 
| DOUBLE | double | 
| NUMERIC | java.math.BigDecimal | 
| DECIMAL | java.math.BigDecimal | 
| CHAR | String | 
| VARCHAR | String | 
| LONGVARCHAR | String | 
| DATE | java.sql.Date | 
| TIME | java.sql.Time | 
| TIMESTAMP | java.sql.Timestamp | 
| BINARY | byte[] | 
| VARBINARY | byte[] | 
| LONGVARBINARY | byte[] | 
The following is an example of properties file used to generate a schema:
 packageName=atg.cortex.test
 schemaManipulator=Schema
 
 #####################################
 # Person table
 
 tables.Person.comment=\
        Represents a single person
 
 # Person.name
 
 tables.Person.columns.name.comment=\
        The person's name
 tables.Person.columns.name.sqlType=VARCHAR(40)
 tables.Person.columns.name.constraints=NOT NULL PRIMARY KEY
 tables.Person.columns.name.primaryKey=true
 
 # Person.age
 
 tables.Person.columns.age.comment=\
        The person's age
 tables.Person.columns.age.sqlType=INTEGER
 
 # Person.birthmonth
 
 tables.Person.columns.birthmonth.comment=\
        The month in which the person was born
 tables.Person.columns.birthmonth.sqlType=VARCHAR(40)
 
 
 #####################################
 # Birthstone table
 
 tables.Birthstone.comment=\
        Represents a mapping from a month to a birthstone
 
 # Birthstone.month
 
 tables.Birthstone.columns.month.comment=\
        The month to which a stone is mapped
 tables.Birthstone.columns.month.sqlType=VARCHAR(40)
 tables.Birthstone.columns.month.constraints=NOT NULL PRIMARY KEY
 tables.Birthstone.columns.month.primaryKey=true
 
 # Birthstone.stone
 
 tables.Birthstone.columns.stone.comment=\
        The birthstone stone corresponding to the month
 tables.Birthstone.columns.stone.sqlType=VARCHAR(40)
 
 
| Field Summary | |
|---|---|
| static java.lang.String | CLASS_VERSION | 
| Method Summary | |
|---|---|
| static void | main(java.lang.String[] pArgs)Usage: CortexGenerator {propertiesFile} {outputDirectory} | 
|  void | writeClassComment(java.io.PrintStream pOut,
                  java.lang.String pComment)Writes the initial class comments | 
| Methods inherited from class java.lang.Object | 
|---|
| clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait | 
| Field Detail | 
|---|
public static java.lang.String CLASS_VERSION
| Method Detail | 
|---|
public void writeClassComment(java.io.PrintStream pOut,
                              java.lang.String pComment)
public static void main(java.lang.String[] pArgs)
                 throws java.io.IOException
java.io.IOException| 
 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||