org.apache.ibatis.ibator.api
Class IntrospectedTable

java.lang.Object
  extended by org.apache.ibatis.ibator.api.IntrospectedTable
Direct Known Subclasses:
IntrospectedTableIbatis2Java2Impl

public abstract class IntrospectedTable
extends java.lang.Object

Base class for all code generator implementations. This class provides many of the Ibator housekeeping methods needed to implement a code generator, with only the actual code generation methods left unimplemented.

Author:
Jeff Butler

Field Summary
static java.lang.String ATTR_BASE_RECORD_TYPE
          This attribute must be a class of type org.apache.ibatis.ibator.api.dom.java.FullyQualifiedJavaType
static java.lang.String ATTR_DAO_IMPLEMENTATION_PACKAGE
          This attribute must be a class of type java.lang.String
static java.lang.String ATTR_DAO_IMPLEMENTATION_TYPE
          This attribute must be a class of type org.apache.ibatis.ibator.api.dom.java.FullyQualifiedJavaType
static java.lang.String ATTR_DAO_INTERFACE_PACKAGE
          This attribute must be a class of type java.lang.String
static java.lang.String ATTR_DAO_INTERFACE_TYPE
          This attribute must be a class of type org.apache.ibatis.ibator.api.dom.java.FullyQualifiedJavaType
static java.lang.String ATTR_EXAMPLE_TYPE
          This attribute must be a class of type org.apache.ibatis.ibator.api.dom.java.FullyQualifiedJavaType
static java.lang.String ATTR_JAVA_MODEL_PACKAGE
          This attribute must be a class of type java.lang.String
static java.lang.String ATTR_PRIMARY_KEY_TYPE
          This attribute must be a class of type org.apache.ibatis.ibator.api.dom.java.FullyQualifiedJavaType
static java.lang.String ATTR_RECORD_WITH_BLOBS_TYPE
          This attribute must be a class of type org.apache.ibatis.ibator.api.dom.java.FullyQualifiedJavaType
static java.lang.String ATTR_SQL_MAP_FILE_NAME
          This attribute must be a class of type java.lang.String
static java.lang.String ATTR_SQL_MAP_PACKAGE
          This attribute must be a class of type java.lang.String
protected  java.util.Map<java.lang.String,java.lang.Object> attributes
          Attributes may be used by plugins to capture table related state between the different plugin calls.
protected  java.util.List<IntrospectedColumn> baseColumns
           
protected  java.util.List<IntrospectedColumn> blobColumns
           
protected  FullyQualifiedTable fullyQualifiedTable
           
protected  IbatorContext ibatorContext
           
protected  java.util.List<IntrospectedColumn> primaryKeyColumns
           
protected  IbatorRules rules
           
protected  TableConfiguration tableConfiguration
           
 
Constructor Summary
IntrospectedTable()
           
 
Method Summary
 void addColumn(IntrospectedColumn introspectedColumn)
           
 void addPrimaryKeyColumn(java.lang.String columnName)
           
abstract  void calculateGenerators(java.util.List<java.lang.String> warnings, ProgressCallback progressCallback)
          This method can be used to initialize the generators before they will be called.
 java.util.List<IntrospectedColumn> getAllColumns()
          Returns all columns in the table (for use by the select by primary key and select by example with BLOBs methods)
 java.lang.Object getAttribute(java.lang.String name)
           
 java.util.List<IntrospectedColumn> getBaseColumns()
           
 FullyQualifiedJavaType getBaseRecordType()
           
 java.util.List<IntrospectedColumn> getBLOBColumns()
           
 IntrospectedColumn getColumn(java.lang.String columnName)
           
 java.lang.String getDAOImplementationPackage()
           
 FullyQualifiedJavaType getDAOImplementationType()
           
 java.lang.String getDAOInterfacePackage()
           
 FullyQualifiedJavaType getDAOInterfaceType()
           
 FullyQualifiedJavaType getExampleType()
           
 FullyQualifiedTable getFullyQualifiedTable()
           
abstract  java.util.List<GeneratedJavaFile> getGeneratedJavaFiles()
          This method should return a list of generated Java files related to this table.
 GeneratedKey getGeneratedKey()
           
abstract  java.util.List<GeneratedXmlFile> getGeneratedXmlFiles()
          This method should return a list of generated XML files related to this table.
abstract  int getGenerationSteps()
          This method should return the number of progress messages that will be send during the generation phase.
 java.lang.String getJavaModelPackage()
           
 int getNonBLOBColumnCount()
           
 java.util.List<IntrospectedColumn> getNonBLOBColumns()
          Returns all columns except BLOBs (for use by the select by example without BLOBs method)
 java.util.List<IntrospectedColumn> getNonPrimaryKeyColumns()
           
 java.util.List<IntrospectedColumn> getPrimaryKeyColumns()
          Returns the columns in the primary key.
 FullyQualifiedJavaType getPrimaryKeyType()
           
 FullyQualifiedJavaType getRecordWithBLOBsType()
           
 IbatorRules getRules()
           
 java.lang.String getSelectByExampleQueryId()
           
 java.lang.String getSelectByPrimaryKeyQueryId()
           
 java.lang.String getSqlMapFileName()
          Calculates an SQL Map file name for the table.
 java.lang.String getSqlMapPackage()
          Calculates the package for the current table.
 java.lang.String getTableConfigurationProperty(java.lang.String property)
           
 boolean hasAnyColumns()
           
 boolean hasBaseColumns()
           
 boolean hasBLOBColumns()
           
 boolean hasJDBCDateColumns()
          Returns true if any of the columns in the table are JDBC Dates (as opposed to timestamps).
 boolean hasJDBCTimeColumns()
          Returns true if any of the columns in the table are JDBC Times (as opposed to timestamps).
 boolean hasPrimaryKeyColumns()
           
 void initialize()
           
abstract  boolean isJava5Targeted()
          Denotes whether generated code is targeted for Java version 5.0 or higher.
 void removeAttribute(java.lang.String name)
           
 void setAttribute(java.lang.String name, java.lang.Object value)
           
 void setFullyQualifiedTable(FullyQualifiedTable fullyQualifiedTable)
           
 void setIbatorContext(IbatorContext ibatorContext)
           
 void setRules(IbatorRules rules)
          This method exists to give plugins the opportunity to replace the calculated rules if necessary.
 void setTableConfiguration(TableConfiguration tableConfiguration)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ATTR_DAO_IMPLEMENTATION_PACKAGE

public static final java.lang.String ATTR_DAO_IMPLEMENTATION_PACKAGE
This attribute must be a class of type java.lang.String

See Also:
Constant Field Values

ATTR_DAO_INTERFACE_PACKAGE

public static final java.lang.String ATTR_DAO_INTERFACE_PACKAGE
This attribute must be a class of type java.lang.String

See Also:
Constant Field Values

ATTR_DAO_IMPLEMENTATION_TYPE

public static final java.lang.String ATTR_DAO_IMPLEMENTATION_TYPE
This attribute must be a class of type org.apache.ibatis.ibator.api.dom.java.FullyQualifiedJavaType

See Also:
Constant Field Values

ATTR_DAO_INTERFACE_TYPE

public static final java.lang.String ATTR_DAO_INTERFACE_TYPE
This attribute must be a class of type org.apache.ibatis.ibator.api.dom.java.FullyQualifiedJavaType

See Also:
Constant Field Values

ATTR_JAVA_MODEL_PACKAGE

public static final java.lang.String ATTR_JAVA_MODEL_PACKAGE
This attribute must be a class of type java.lang.String

See Also:
Constant Field Values

ATTR_PRIMARY_KEY_TYPE

public static final java.lang.String ATTR_PRIMARY_KEY_TYPE
This attribute must be a class of type org.apache.ibatis.ibator.api.dom.java.FullyQualifiedJavaType

See Also:
Constant Field Values

ATTR_BASE_RECORD_TYPE

public static final java.lang.String ATTR_BASE_RECORD_TYPE
This attribute must be a class of type org.apache.ibatis.ibator.api.dom.java.FullyQualifiedJavaType

See Also:
Constant Field Values

ATTR_RECORD_WITH_BLOBS_TYPE

public static final java.lang.String ATTR_RECORD_WITH_BLOBS_TYPE
This attribute must be a class of type org.apache.ibatis.ibator.api.dom.java.FullyQualifiedJavaType

See Also:
Constant Field Values

ATTR_EXAMPLE_TYPE

public static final java.lang.String ATTR_EXAMPLE_TYPE
This attribute must be a class of type org.apache.ibatis.ibator.api.dom.java.FullyQualifiedJavaType

See Also:
Constant Field Values

ATTR_SQL_MAP_PACKAGE

public static final java.lang.String ATTR_SQL_MAP_PACKAGE
This attribute must be a class of type java.lang.String

See Also:
Constant Field Values

ATTR_SQL_MAP_FILE_NAME

public static final java.lang.String ATTR_SQL_MAP_FILE_NAME
This attribute must be a class of type java.lang.String

See Also:
Constant Field Values

tableConfiguration

protected TableConfiguration tableConfiguration

fullyQualifiedTable

protected FullyQualifiedTable fullyQualifiedTable

ibatorContext

protected IbatorContext ibatorContext

rules

protected IbatorRules rules

primaryKeyColumns

protected java.util.List<IntrospectedColumn> primaryKeyColumns

baseColumns

protected java.util.List<IntrospectedColumn> baseColumns

blobColumns

protected java.util.List<IntrospectedColumn> blobColumns

attributes

protected java.util.Map<java.lang.String,java.lang.Object> attributes
Attributes may be used by plugins to capture table related state between the different plugin calls. Attributes also are used to store commonly accessed items by all code generators

Constructor Detail

IntrospectedTable

public IntrospectedTable()
Method Detail

getFullyQualifiedTable

public FullyQualifiedTable getFullyQualifiedTable()

getSelectByExampleQueryId

public java.lang.String getSelectByExampleQueryId()

getSelectByPrimaryKeyQueryId

public java.lang.String getSelectByPrimaryKeyQueryId()

getGeneratedKey

public GeneratedKey getGeneratedKey()

getColumn

public IntrospectedColumn getColumn(java.lang.String columnName)

hasJDBCDateColumns

public boolean hasJDBCDateColumns()
Returns true if any of the columns in the table are JDBC Dates (as opposed to timestamps).

Returns:
true if the table contains DATE columns

hasJDBCTimeColumns

public boolean hasJDBCTimeColumns()
Returns true if any of the columns in the table are JDBC Times (as opposed to timestamps).

Returns:
true if the table contains TIME columns

getPrimaryKeyColumns

public java.util.List<IntrospectedColumn> getPrimaryKeyColumns()
Returns the columns in the primary key. If the generatePrimaryKeyClass() method returns false, then these columns will be iterated as the parameters of the selectByPrimaryKay and deleteByPrimaryKey methods

Returns:
a List of ColumnDefinition objects for columns in the primary key

hasPrimaryKeyColumns

public boolean hasPrimaryKeyColumns()

getBaseColumns

public java.util.List<IntrospectedColumn> getBaseColumns()

getAllColumns

public java.util.List<IntrospectedColumn> getAllColumns()
Returns all columns in the table (for use by the select by primary key and select by example with BLOBs methods)

Returns:
a List of ColumnDefinition objects for all columns in the table

getNonBLOBColumns

public java.util.List<IntrospectedColumn> getNonBLOBColumns()
Returns all columns except BLOBs (for use by the select by example without BLOBs method)

Returns:
a List of ColumnDefinition objects for columns in the table that are non BLOBs

getNonBLOBColumnCount

public int getNonBLOBColumnCount()

getNonPrimaryKeyColumns

public java.util.List<IntrospectedColumn> getNonPrimaryKeyColumns()

getBLOBColumns

public java.util.List<IntrospectedColumn> getBLOBColumns()

hasBLOBColumns

public boolean hasBLOBColumns()

hasBaseColumns

public boolean hasBaseColumns()

getRules

public IbatorRules getRules()

getTableConfigurationProperty

public java.lang.String getTableConfigurationProperty(java.lang.String property)

getPrimaryKeyType

public FullyQualifiedJavaType getPrimaryKeyType()

getBaseRecordType

public FullyQualifiedJavaType getBaseRecordType()
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.

getExampleType

public FullyQualifiedJavaType getExampleType()
Returns:
the type for the example class.

getRecordWithBLOBsType

public FullyQualifiedJavaType getRecordWithBLOBsType()
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.

getSqlMapFileName

public java.lang.String getSqlMapFileName()
Calculates an SQL Map file name for the table. Typically the name is "XXXX_SqlMap.xml" where XXXX is the fully qualified table name (delimited with underscores).

Returns:
the name of the SqlMap file

getSqlMapPackage

public java.lang.String getSqlMapPackage()
Calculates the package for the current table.

Returns:
the package for the SqlMap for the current table

getDAOImplementationType

public FullyQualifiedJavaType getDAOImplementationType()

getDAOInterfaceType

public FullyQualifiedJavaType getDAOInterfaceType()

hasAnyColumns

public boolean hasAnyColumns()

getDAOInterfacePackage

public java.lang.String getDAOInterfacePackage()

getDAOImplementationPackage

public java.lang.String getDAOImplementationPackage()

getJavaModelPackage

public java.lang.String getJavaModelPackage()

setTableConfiguration

public void setTableConfiguration(TableConfiguration tableConfiguration)

setFullyQualifiedTable

public void setFullyQualifiedTable(FullyQualifiedTable fullyQualifiedTable)

setIbatorContext

public void setIbatorContext(IbatorContext ibatorContext)

addColumn

public void addColumn(IntrospectedColumn introspectedColumn)

addPrimaryKeyColumn

public void addPrimaryKeyColumn(java.lang.String columnName)

getAttribute

public java.lang.Object getAttribute(java.lang.String name)

removeAttribute

public void removeAttribute(java.lang.String name)

setAttribute

public void setAttribute(java.lang.String name,
                         java.lang.Object value)

initialize

public void initialize()

calculateGenerators

public abstract void calculateGenerators(java.util.List<java.lang.String> warnings,
                                         ProgressCallback progressCallback)
This method can be used to initialize the generators before they will be called. This method is called after all the setX methods, but before getNumberOfSubtasks(), getGeneratedJavaFiles, and getGeneratedXmlFiles.

Parameters:
warnings -
progressCallback -

getGeneratedJavaFiles

public abstract java.util.List<GeneratedJavaFile> getGeneratedJavaFiles()
This method should return a list of generated Java files related to this table. This list could include various types of model classes, as well as DAO classes.

Returns:
the list of generated Java files for this table

getGeneratedXmlFiles

public abstract java.util.List<GeneratedXmlFile> getGeneratedXmlFiles()
This method should return a list of generated XML files related to this table. Most implementations will only return one file - the generated SqlMap file.

Returns:
the list of generated XML files for this table

isJava5Targeted

public abstract boolean isJava5Targeted()
Denotes whether generated code is targeted for Java version 5.0 or higher.

Returns:
true if the generated code makes use of Java5 features

getGenerationSteps

public abstract int getGenerationSteps()
This method should return the number of progress messages that will be send during the generation phase.

Returns:
the number of progress messages

setRules

public void setRules(IbatorRules rules)
This method exists to give plugins the opportunity to replace the calculated rules if necessary.

Parameters:
rules -