org.apache.ibatis.abator.internal.java
Class JavaModelGeneratorDefaultImpl

java.lang.Object
  extended byorg.apache.ibatis.abator.internal.java.BaseJavaCodeGenerator
      extended byorg.apache.ibatis.abator.internal.java.JavaModelGeneratorDefaultImpl
All Implemented Interfaces:
JavaModelGenerator

public class JavaModelGeneratorDefaultImpl
extends BaseJavaCodeGenerator
implements JavaModelGenerator

This class supports the following properties:

trimStrings
If true, the setters will trim all Strings. Default is false.
enableSubPackages
If true, the classes will be generated in sub-packaged based on the database catalg and schema - else the will be generated in the specified package (the targetPackage attribute). Default is false.
rootClass
If specified, then the root class of all objects generated by the generator will be used as specified. No checking is done to see if the specified class exists, or if the generated classes hide any attributes or methods in the specified class. Note that the root class is not the base class of all objects - just the root class. For example, if there is a primary key then the primary key will extend the root class and the record class will still extend the primary key.

Author:
Jeff Butler

Field Summary
protected  java.util.Map properties
          The properties from the JavaModelGenerator congiguration element
protected  java.lang.String targetPackage
          The target package from the JavaModelGenerator congiguration element
protected  java.lang.String targetProject
          The target project from the JavaModelGenerator congiguration element
protected  java.util.List warnings
           
 
Fields inherited from class org.apache.ibatis.abator.internal.java.BaseJavaCodeGenerator
lineSeparator
 
Constructor Summary
JavaModelGeneratorDefaultImpl()
           
 
Method Summary
protected  void generateClassParts(FullyQualifiedTable table, java.util.Collection columnDefinitions, GeneratedJavaFile answer)
          Adds fields and getter/setter methods for each ColumnDefinition passed into the method.
protected  GeneratedJavaFile getExample(ColumnDefinitions columnDefinitions, TableConfiguration tableConfiguration)
           
 FullyQualifiedJavaType getExampleType(FullyQualifiedTable table)
           
 java.util.List getGeneratedJavaFiles(ColumnDefinitions columnDefinitions, TableConfiguration tableConfiguration, ProgressCallback callback)
          This method returns a list of GenerateJavaFile objects.
protected  java.lang.String getJavaModelPackage(FullyQualifiedTable table)
          Calculates the package for generated domain objects.
protected  GeneratedJavaFile getPrimaryKey(ColumnDefinitions columnDefinitions, TableConfiguration tableConfiguration)
           
 FullyQualifiedJavaType getPrimaryKeyType(FullyQualifiedTable table)
           
protected  GeneratedJavaFile getRecord(ColumnDefinitions columnDefinitions, TableConfiguration tableConfiguration)
           
 FullyQualifiedJavaType getRecordType(FullyQualifiedTable table)
           
protected  GeneratedJavaFile getRecordWithBLOBs(ColumnDefinitions columnDefinitions, TableConfiguration tableConfiguration)
           
 FullyQualifiedJavaType getRecordWithBLOBsType(FullyQualifiedTable table)
           
 void setProperties(java.util.Map properties)
          Sets the properties of the generator taken from the JavaModelGeneratorConfiguration element.
 void setTargetPackage(java.lang.String targetPackage)
          Sets the target package of the generator taken from the JavaModelGeneratorConfiguration element.
 void setTargetProject(java.lang.String targetProject)
          Sets the target project of the generator taken from the JavaModelGeneratorConfiguration element.
 void setWarnings(java.util.List warnings)
          Abator will supply a list to this method.
 
Methods inherited from class org.apache.ibatis.abator.internal.java.BaseJavaCodeGenerator
getFieldComment, getFieldComment, getGetterMethodComment, getMethodComment, getMethodComment, getSetterMethodComment, indent, newLine
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

warnings

protected java.util.List warnings

properties

protected java.util.Map properties
The properties from the JavaModelGenerator congiguration element


targetPackage

protected java.lang.String targetPackage
The target package from the JavaModelGenerator congiguration element


targetProject

protected java.lang.String targetProject
The target project from the JavaModelGenerator congiguration element

Constructor Detail

JavaModelGeneratorDefaultImpl

public JavaModelGeneratorDefaultImpl()
Method Detail

setProperties

public void setProperties(java.util.Map properties)
Description copied from interface: JavaModelGenerator
Sets the properties of the generator taken from the JavaModelGeneratorConfiguration element. This method is called before any getXXX method.

Specified by:
setProperties in interface JavaModelGenerator
Parameters:
properties - the configuration element's properties

setTargetPackage

public void setTargetPackage(java.lang.String targetPackage)
Description copied from interface: JavaModelGenerator
Sets the target package of the generator taken from the JavaModelGeneratorConfiguration element. This method is called before any getXXX method.

Specified by:
setTargetPackage in interface JavaModelGenerator
Parameters:
targetPackage - the configuration element's target package

generateClassParts

protected void generateClassParts(FullyQualifiedTable table,
                                  java.util.Collection columnDefinitions,
                                  GeneratedJavaFile answer)
Adds fields and getter/setter methods for each ColumnDefinition passed into the method.

Parameters:
table - the table from which the ColumnDefinitions are derived. This is used to generate appropriate JavaDoc comments for the generated fields and methods.
columnDefinitions - the collection of ColumnDefinitions used to generate fields and getter/setter methods.
answer - the generated fields and methods will be added to this object

getJavaModelPackage

protected java.lang.String getJavaModelPackage(FullyQualifiedTable table)
Calculates the package for generated domain objects.

Parameters:
table - the current table
Returns:
the calculated package

getExample

protected GeneratedJavaFile getExample(ColumnDefinitions columnDefinitions,
                                       TableConfiguration tableConfiguration)

getPrimaryKey

protected GeneratedJavaFile getPrimaryKey(ColumnDefinitions columnDefinitions,
                                          TableConfiguration tableConfiguration)

getRecord

protected GeneratedJavaFile getRecord(ColumnDefinitions columnDefinitions,
                                      TableConfiguration tableConfiguration)

getRecordWithBLOBs

protected GeneratedJavaFile getRecordWithBLOBs(ColumnDefinitions columnDefinitions,
                                               TableConfiguration tableConfiguration)

setTargetProject

public void setTargetProject(java.lang.String targetProject)
Description copied from interface: JavaModelGenerator
Sets the target project of the generator taken from the JavaModelGeneratorConfiguration element. This method is called before any getXXX method.

Specified by:
setTargetProject in interface JavaModelGenerator
Parameters:
targetProject - the configuration element's target project

getExampleType

public FullyQualifiedJavaType getExampleType(FullyQualifiedTable table)
Specified by:
getExampleType in interface JavaModelGenerator
Parameters:
table - the table for which the name should be generated
Returns:
the type for the example class.

getGeneratedJavaFiles

public java.util.List getGeneratedJavaFiles(ColumnDefinitions columnDefinitions,
                                            TableConfiguration tableConfiguration,
                                            ProgressCallback callback)
Description copied from interface: JavaModelGenerator
This method returns a list of GenerateJavaFile objects. The list may include any, or all, of the following types of generated java classes:

Specified by:
getGeneratedJavaFiles in interface JavaModelGenerator
Parameters:
columnDefinitions -
tableConfiguration -
callback -
Returns:
a list of GeneratedJavaFile objects

getPrimaryKeyType

public FullyQualifiedJavaType getPrimaryKeyType(FullyQualifiedTable table)
Specified by:
getPrimaryKeyType in interface JavaModelGenerator

getRecordType

public FullyQualifiedJavaType getRecordType(FullyQualifiedTable table)
Specified by:
getRecordType in interface JavaModelGenerator
Parameters:
table - the table for which the name should be generated
Returns:
the type for the record (the class that holds non-primary key and non-BLOB fields). Note that the value will be calculated regardless of whether the table has these columns or not.

getRecordWithBLOBsType

public FullyQualifiedJavaType getRecordWithBLOBsType(FullyQualifiedTable table)
Specified by:
getRecordWithBLOBsType in interface JavaModelGenerator
Parameters:
table - the table for which the name should be generated
Returns:
the type for the record with BLOBs class. Note that the value will be calculated regardless of whether the table has BLOB columns or not.

setWarnings

public void setWarnings(java.util.List warnings)
Description copied from interface: JavaModelGenerator
Abator will supply a list to this method. The implementation class may add strings to the list that will be treated as warning messages and displayed to the user. The concept of a warning is that code generation can continue, but that the results may not be what is expected.

Specified by:
setWarnings in interface JavaModelGenerator
Parameters:
warnings -