org.apache.ibatis.abator.internal.java.model
Class JavaModelGeneratorJava2Impl

java.lang.Object
  extended by org.apache.ibatis.abator.internal.java.model.JavaModelGeneratorJava2Impl
All Implemented Interfaces:
JavaModelGenerator
Direct Known Subclasses:
JavaModelGeneratorJava5Impl, JavaModelGeneratorLegacyImpl

public class JavaModelGeneratorJava2Impl
extends java.lang.Object
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
           
 
Constructor Summary
JavaModelGeneratorJava2Impl()
           
 
Method Summary
 void addConfigurationProperties(java.util.Map properties)
          Adds properties for this instance from any properties configured in the JavaModelGeneratorConfiguration.
 void addContextProperties(java.util.Map properties)
          Adds properties for this instance from any properties configured in the current context.
protected  void generateClassParts(FullyQualifiedTable table, java.util.Iterator columnDefinitions, TopLevelClass topLevelClass)
          Adds fields and getter/setter methods for each ColumnDefinition passed into the method.
protected  CompilationUnit getBaseRecord(IntrospectedTable introspectedTable)
           
 FullyQualifiedJavaType getBaseRecordType(FullyQualifiedTable table)
           
protected  InnerClass getCriteriaInnerClass(TopLevelClass topLevelClass, IntrospectedTable introspectedTable)
           
protected  TopLevelClass getExample(IntrospectedTable introspectedTable)
           
 FullyQualifiedJavaType getExampleType(FullyQualifiedTable table)
           
 java.util.List getGeneratedJavaFiles(IntrospectedTable introspectedTable, 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  Method getNoValueMethod(ColumnDefinition cd, java.lang.String nameFragment, java.lang.String operator)
           
protected  CompilationUnit getPrimaryKey(IntrospectedTable introspectedTable)
           
 FullyQualifiedJavaType getPrimaryKeyType(FullyQualifiedTable table)
           
protected  CompilationUnit getRecordWithBLOBs(IntrospectedTable introspectedTable)
           
 FullyQualifiedJavaType getRecordWithBLOBsType(FullyQualifiedTable table)
           
protected  Method getSetBetweenOrNotBetweenMethod(ColumnDefinition cd, boolean betweenMethod)
          Generates methods that set between and not between conditions
protected  Method getSetEqualMethod(ColumnDefinition cd)
           
protected  Method getSetGreaterThanMethod(ColumnDefinition cd)
           
protected  Method getSetGreaterThenOrEqualMethod(ColumnDefinition cd)
           
protected  Method getSetInOrNotInMethod(ColumnDefinition cd, boolean inMethod)
           
protected  Method getSetLessThanMethod(ColumnDefinition cd)
           
protected  Method getSetLessThanOrEqualMethod(ColumnDefinition cd)
           
protected  Method getSetLikeMethod(ColumnDefinition cd)
           
protected  Method getSetNotEqualMethod(ColumnDefinition cd)
           
protected  Method getSetNotLikeMethod(ColumnDefinition cd)
           
protected  Method getSetNotNullMethod(ColumnDefinition cd)
           
protected  Method getSetNullMethod(ColumnDefinition cd)
           
protected  Method getSingleValueMethod(ColumnDefinition cd, java.lang.String nameFragment, java.lang.String operator)
           
 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 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

JavaModelGeneratorJava2Impl

public JavaModelGeneratorJava2Impl()
Method Detail

addConfigurationProperties

public void addConfigurationProperties(java.util.Map properties)
Description copied from interface: JavaModelGenerator
Adds properties for this instance from any properties configured in the JavaModelGeneratorConfiguration. This method will be called before any of the get methods.

Specified by:
addConfigurationProperties in interface JavaModelGenerator
Parameters:
properties - All properties from the configuration

addContextProperties

public void addContextProperties(java.util.Map properties)
Description copied from interface: JavaModelGenerator
Adds properties for this instance from any properties configured in the current context. This method will be called before any of the get methods.

Specified by:
addContextProperties in interface JavaModelGenerator
Parameters:
properties - All properties from the configuration

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.Iterator columnDefinitions,
                                  TopLevelClass topLevelClass)
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.
topLevelClass - 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

getPrimaryKey

protected CompilationUnit getPrimaryKey(IntrospectedTable introspectedTable)

getBaseRecord

protected CompilationUnit getBaseRecord(IntrospectedTable introspectedTable)

getRecordWithBLOBs

protected CompilationUnit getRecordWithBLOBs(IntrospectedTable introspectedTable)

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(IntrospectedTable introspectedTable,
                                            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
Returns:
a list of GeneratedJavaFile objects

getPrimaryKeyType

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

getBaseRecordType

public FullyQualifiedJavaType getBaseRecordType(FullyQualifiedTable table)
Specified by:
getBaseRecordType 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

getSetNullMethod

protected Method getSetNullMethod(ColumnDefinition cd)

getSetNotNullMethod

protected Method getSetNotNullMethod(ColumnDefinition cd)

getSetEqualMethod

protected Method getSetEqualMethod(ColumnDefinition cd)

getSetNotEqualMethod

protected Method getSetNotEqualMethod(ColumnDefinition cd)

getSetGreaterThanMethod

protected Method getSetGreaterThanMethod(ColumnDefinition cd)

getSetGreaterThenOrEqualMethod

protected Method getSetGreaterThenOrEqualMethod(ColumnDefinition cd)

getSetLessThanMethod

protected Method getSetLessThanMethod(ColumnDefinition cd)

getSetLessThanOrEqualMethod

protected Method getSetLessThanOrEqualMethod(ColumnDefinition cd)

getSetLikeMethod

protected Method getSetLikeMethod(ColumnDefinition cd)

getSetNotLikeMethod

protected Method getSetNotLikeMethod(ColumnDefinition cd)

getSingleValueMethod

protected Method getSingleValueMethod(ColumnDefinition cd,
                                      java.lang.String nameFragment,
                                      java.lang.String operator)

getNoValueMethod

protected Method getNoValueMethod(ColumnDefinition cd,
                                  java.lang.String nameFragment,
                                  java.lang.String operator)

getSetBetweenOrNotBetweenMethod

protected Method getSetBetweenOrNotBetweenMethod(ColumnDefinition cd,
                                                 boolean betweenMethod)
Generates methods that set between and not between conditions

Parameters:
cd -
betweenMethod -
Returns:
a generated method for the between or not between method

getExample

protected TopLevelClass getExample(IntrospectedTable introspectedTable)

getCriteriaInnerClass

protected InnerClass getCriteriaInnerClass(TopLevelClass topLevelClass,
                                           IntrospectedTable introspectedTable)

getSetInOrNotInMethod

protected Method getSetInOrNotInMethod(ColumnDefinition cd,
                                       boolean inMethod)
Parameters:
cd -
inMethod - if true generates an "in" method, else generates a "not in" method
Returns:
a generated method for the in or not in method