xcodegen.generator.sql
Class AbstractSQLCodeGenerator

java.lang.Object
  |
  +--xcodegen.generator.AbstractCodeGenerator
        |
        +--xcodegen.generator.sql.AbstractSQLCodeGenerator
All Implemented Interfaces:
CodeGenerator
Direct Known Subclasses:
DDLCodeGenerator

public abstract class AbstractSQLCodeGenerator
extends AbstractCodeGenerator

Base class of SQL code generators

Version:
$Revision: 1.1.1.1 $
Author:
Herve Tchepannou

Field Summary
 
Fields inherited from interface xcodegen.generator.CodeGenerator
CONFIG_CLASS_OUTPUT_DIR, CONFIG_CLASS_PREFIX, CONFIG_CLASS_SUFFIX, CONFIG_DATABASE, CONFIG_DATABASE_OUTPUT_DIR, CONFIG_DATABASE_OUTPUT_FILE, CONFIG_DATABASE_STRING_SIZE, CONFIG_LANGUAGE, CONFIG_PACKAGE_SUFFIX
 
Constructor Summary
AbstractSQLCodeGenerator(java.lang.String name)
          Create a new SQLCodeGenerator
 
Method Summary
protected  void generate(XClass clazz, org.apache.velocity.VelocityContext context, org.apache.velocity.Template template)
          Generate the code of a class
 void generate(XPackage[] packages)
          Generate to code of a set of packages
protected  void generate(XPackage pkg, org.apache.velocity.VelocityContext context, org.apache.velocity.Template template)
          Generate the code of a package
 java.util.Collection getClasses()
          Return all the classes to generate
 java.util.Collection getClassesReverse()
          Return all the classes to generate in reverse order
 java.lang.String getType(XField field)
          Return the SQL type of a given field
 java.lang.String getVelocityTemplatePath()
          Return the path the the template
 void init(java.util.Properties config)
          Initialize the code generator
 
Methods inherited from class xcodegen.generator.AbstractCodeGenerator
getConfigProperty, getLogger, getName, getVelocityContext, getVelocityTemplate, loadResourceAsProperties
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractSQLCodeGenerator

public AbstractSQLCodeGenerator(java.lang.String name)
Create a new SQLCodeGenerator

Method Detail

getType

public java.lang.String getType(XField field)
Return the SQL type of a given field

Parameters:
field - field for which the type is requester
Returns:
SQL type

getClasses

public java.util.Collection getClasses()
Return all the classes to generate

Returns:
list of classes to generate

getClassesReverse

public java.util.Collection getClassesReverse()
Return all the classes to generate in reverse order

Returns:
list of classes to generate in reverse order

init

public void init(java.util.Properties config)
          throws XCodeGenException
Description copied from interface: CodeGenerator
Initialize the code generator

Specified by:
init in interface CodeGenerator
Overrides:
init in class AbstractCodeGenerator
Parameters:
config - Configuration of the code generator
Throws:
XCodeGenException - if any error occurs during the initialization

generate

public void generate(XPackage[] packages)
              throws XCodeGenException,
                     java.io.IOException
Description copied from interface: CodeGenerator
Generate to code of a set of packages

Specified by:
generate in interface CodeGenerator
Overrides:
generate in class AbstractCodeGenerator
Throws:
java.io.IOException - if any IO error
XCodeGenException

getVelocityTemplatePath

public java.lang.String getVelocityTemplatePath()
Description copied from class: AbstractCodeGenerator
Return the path the the template

Specified by:
getVelocityTemplatePath in class AbstractCodeGenerator
Returns:
path of the template

generate

protected void generate(XPackage pkg,
                        org.apache.velocity.VelocityContext context,
                        org.apache.velocity.Template template)
                 throws XCodeGenException,
                        java.io.IOException
Description copied from class: AbstractCodeGenerator
Generate the code of a package

Specified by:
generate in class AbstractCodeGenerator
Parameters:
pkg - Package to generate
context - Velocity context
template - Template used for generating the code
Throws:
XCodeGenException - If any error occurs during the code generation
java.io.IOException

generate

protected void generate(XClass clazz,
                        org.apache.velocity.VelocityContext context,
                        org.apache.velocity.Template template)
                 throws XCodeGenException,
                        java.io.IOException
Description copied from class: AbstractCodeGenerator
Generate the code of a class

Specified by:
generate in class AbstractCodeGenerator
Parameters:
clazz - Class to generate
context - Velocity context
template - Template used for generating the code
Throws:
XCodeGenException - If any error occurs during the code generation
java.io.IOException