org.javaWebGen.util
Class CodeGenerator

java.lang.Object
  extended by org.javaWebGen.data.DAO
      extended by org.javaWebGen.util.CodeGenerator
Direct Known Subclasses:
GenerateController, GenerateDAO, GenerateDataBean, GenerateLookup, GenerateModel, GenerateTestCase, GenerateView

public abstract class CodeGenerator
extends DAO

Base Code generator class that handles common functions among the code generators

Author:
Kevin Scott

Field Summary
static java.lang.String TS
          TAB spacer (IE 4 spaces
 
Fields inherited from class org.javaWebGen.data.DAO
TOO_MANY_ROWS, TOO_MANY_ROWS_WARNING
 
Constructor Summary
CodeGenerator()
           
 
Method Summary
protected abstract  void execute()
           
protected  java.lang.String getClassText(java.lang.String templateText, java.lang.String[] parms)
          Gets the code that has tags replaced in it
protected  java.lang.String[] getColNames()
           
protected  int[] getColTypes()
           
protected  java.lang.String getFileName()
           
protected  java.lang.String getFilePath()
          return file path ie where to write the output java source
protected  java.util.ArrayList<java.lang.String> getPrimaryKeys()
           
protected  int[] getPrimaryKeyTypes()
           
protected  java.lang.String getPrimayParmCast(java.lang.String key, int type)
          generate a string to convert from a string to correct Object type
protected  java.lang.String getTableName()
          get current table name
protected  java.lang.String getTemplate(java.lang.String defaultTemplate)
          Get the template from a file if it exists if not return the default template
protected  java.lang.String getVars(java.util.List<java.lang.String> keys, int[] types)
          Return the type of variable.
abstract  void init()
          run init code ie stuff to setup templates
protected  void mapData()
          map data types from current table
protected  void processFile(java.lang.String fileName)
          process table list
protected  boolean setCmdParms(java.lang.String[] args)
          get the parms that where passed in on the command line and set the correct vars
protected  void setTableName(java.lang.String table)
          sets the current table name
abstract  void useage()
          print instruction on how to object from the command line to sysout
 
Methods inherited from class org.javaWebGen.data.DAO
close, getColumnClass, getConnection, getDataManager, getNextValue, getNextValue, getResultSet, query, query, query, query, runQuery, runQuery, runQuery, runQuery, setColumn, update, update, update, update, updateDataBean, updateDataBean
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TS

public static final java.lang.String TS
TAB spacer (IE 4 spaces

See Also:
Constant Field Values
Constructor Detail

CodeGenerator

public CodeGenerator()
Method Detail

mapData

protected void mapData()
                throws java.sql.SQLException
map data types from current table

Throws:
java.sql.SQLException

processFile

protected void processFile(java.lang.String fileName)
                    throws java.io.IOException,
                           UtilException
process table list

Parameters:
fileName - input file name id table list
Throws:
java.io.IOException - error reading the file
UtilException

setCmdParms

protected boolean setCmdParms(java.lang.String[] args)
                       throws java.lang.Exception
get the parms that where passed in on the command line and set the correct vars

Parameters:
args - cmd line parms
Returns:
true if right number of parms passed
Throws:
java.lang.Exception

getTemplate

protected java.lang.String getTemplate(java.lang.String defaultTemplate)
Get the template from a file if it exists if not return the default template

Parameters:
defaultTemplate - text
Returns:
class template text

getClassText

protected java.lang.String getClassText(java.lang.String templateText,
                                        java.lang.String[] parms)
Gets the code that has tags replaced in it

Parameters:
templateText -
parms -
Returns:
class text

getVars

protected java.lang.String getVars(java.util.List<java.lang.String> keys,
                                   int[] types)
Return the type of variable. In other words, a Integer SQL TYPE would return a int

Parameters:
keys - column names
types - sql type
Returns:
java object that matches sql type

getPrimayParmCast

protected java.lang.String getPrimayParmCast(java.lang.String key,
                                             int type)
generate a string to convert from a string to correct Object type

Parameters:
key - primary key
type - SQL type
Returns:
text for generated class

getFileName

protected java.lang.String getFileName()
Returns:
file name

getFilePath

protected java.lang.String getFilePath()
return file path ie where to write the output java source

Returns:
file path

getTableName

protected java.lang.String getTableName()
get current table name

Returns:
table name

setTableName

protected void setTableName(java.lang.String table)
sets the current table name

Parameters:
table -

getColNames

protected java.lang.String[] getColNames()
Returns:
col names

getColTypes

protected int[] getColTypes()
Returns:
col SQL types

getPrimaryKeys

protected java.util.ArrayList<java.lang.String> getPrimaryKeys()
Returns:
list of primary keys col names

getPrimaryKeyTypes

protected int[] getPrimaryKeyTypes()
Returns:
primary key SQL types

execute

protected abstract void execute()
                         throws UtilException
Throws:
UtilException

useage

public abstract void useage()
print instruction on how to object from the command line to sysout


init

public abstract void init()
                   throws UtilException
run init code ie stuff to setup templates

Throws:
UtilException


Copyright(C) 2003-2006 Kevin Scott - All Rights Reserved.