org.jcoderz.phoenix.cmpgen2
Class CmpGenerator

java.lang.Object
  extended by org.jcoderz.phoenix.cmpgen2.CmpGenerator

public class CmpGenerator
extends Object

This is a velocity based version of the CMP generator.

Author:
Albrecht Messner

Constructor Summary
CmpGenerator(String outputDir, String pkgPrefix, String dataSource, String templateDir, boolean overwrite)
          Construct CMP bean generator.
 
Method Summary
 Set buildBeanImportList(CreateTableStatement statement)
           
 Set buildHelperImportList(CreateTableStatement statement)
           
 String capitalize(String s)
          This method capitalizes the first character of the given string and, assuming that the argument is usually a java type, also takes care of arrays by replacing "[]" with "Array".
 boolean checkIfHelperRequired(CreateTableStatement statement)
          Checks if a helper class is required for this bean a helper class is required as soon as a custom java type is used with a load method and a store method.
 void generateCmpBeans(String inputFile)
          Entry method for CMP bean generator.
 String getQualifiedJavaType(ColumnSpec column)
           
 String getUnqualifiedJavaType(ColumnSpec column)
           
 String getVersion()
           
 boolean isPrimitiveType(String type)
           
static void main(String[] args)
          Main method.
 String sqlNameToJavaName(String sqlName)
           
 String toString()
          
 String unqualifyType(String type)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CmpGenerator

public CmpGenerator(String outputDir,
                    String pkgPrefix,
                    String dataSource,
                    String templateDir,
                    boolean overwrite)
Construct CMP bean generator.

Parameters:
outputDir - the output directory
pkgPrefix - the package prefix
dataSource - the jndi name of the data source
Method Detail

main

public static void main(String[] args)
                 throws Exception
Main method.

Parameters:
args - command line args
Throws:
Exception

generateCmpBeans

public final void generateCmpBeans(String inputFile)
                            throws Exception
Entry method for CMP bean generator.

Parameters:
inputFile - the input file
Throws:
Exception

sqlNameToJavaName

public String sqlNameToJavaName(String sqlName)

capitalize

public String capitalize(String s)
This method capitalizes the first character of the given string and, assuming that the argument is usually a java type, also takes care of arrays by replacing "[]" with "Array".

Parameters:
s - input to be modified.
Returns:
adapted String.

getUnqualifiedJavaType

public String getUnqualifiedJavaType(ColumnSpec column)
                              throws CmpGeneratorException
Throws:
CmpGeneratorException

getQualifiedJavaType

public String getQualifiedJavaType(ColumnSpec column)
                            throws CmpGeneratorException
Throws:
CmpGeneratorException

unqualifyType

public String unqualifyType(String type)

checkIfHelperRequired

public boolean checkIfHelperRequired(CreateTableStatement statement)
Checks if a helper class is required for this bean a helper class is required as soon as a custom java type is used with a load method and a store method.

Parameters:
statement - the parsed SQL create statement
Returns:
true if a helper class is required, false otherwise

getVersion

public String getVersion()

buildBeanImportList

public Set buildBeanImportList(CreateTableStatement statement)
                        throws CmpGeneratorException
Throws:
CmpGeneratorException

buildHelperImportList

public Set buildHelperImportList(CreateTableStatement statement)
                          throws CmpGeneratorException
Throws:
CmpGeneratorException

toString

public String toString()

Overrides:
toString in class Object

isPrimitiveType

public boolean isPrimitiveType(String type)


Copyright 2007 The jCoderZ Project.