org.apache.ibatis.abator.internal.rules
Class AbatorRules

java.lang.Object
  extended byorg.apache.ibatis.abator.internal.rules.AbatorRules

public class AbatorRules
extends java.lang.Object

This class centralizes all the rules related to code generation - including the methods and objects to create, and certain attributes related to those objects. See package JavaDoc for more information.

Author:
Jeff Butler

Method Summary
static boolean generateBaseRecordExtendingPrimaryKey(ColumnDefinitions columnDefinitions)
          Implements the rule for generating a base record that extends the primary key.
static boolean generateBaseRecordWithNoSuperclass(ColumnDefinitions columnDefinitions)
          Implements the rule for generating a base record with no super class.
static boolean generateDeleteByExample(TableConfiguration tc)
          Implements the rule for generating the delete by example SQL Map element and DAO method.
static boolean generateDeleteByPrimaryKey(ColumnDefinitions columnDefinitions, TableConfiguration tc)
          Implements the rule for generating the delete by primary key SQL Map element and DAO method.
static boolean generateExampleExtendingBaseRecord(ColumnDefinitions columnDefinitions, TableConfiguration tc)
          Implements the rule for generating an example class extending the base record.
static boolean generateExampleExtendingPrimaryKey(ColumnDefinitions columnDefinitions, TableConfiguration tc)
          Implements the rule for generating an example class extending the primary key.
static boolean generateInsert(TableConfiguration tc)
          Implements the rule for generating the insert SQL Map element and DAO method.
static boolean generatePrimaryKey(ColumnDefinitions columnDefinitions)
          Implements the rule for determining whether to generate a primary key class.
static boolean generateRecordWithBLOBsExtendingBaseRecord(ColumnDefinitions columnDefinitions)
          Implements the rule for generating a record with BLOBs class extending the base record class.
static boolean generateRecordWithBLOBsExtendingPrimaryKey(ColumnDefinitions columnDefinitions)
          Implements the rule for generating a record with BLOBs class extending the primary key class.
static boolean generateResultMapWithBLOBs(ColumnDefinitions columnDefinitions, TableConfiguration tc)
          Implements the rule for generating the result map with BLOBs.
static boolean generateResultMapWithoutBLOBs(TableConfiguration tc)
          Implements the rule for generating the result map without BLOBs.
static boolean generateSelectByExampleWithBLOBs(ColumnDefinitions columnDefinitions, TableConfiguration tc)
          Implements the rule for generating the select by example with BLOBs SQL Map element and DAO method.
static boolean generateSelectByExampleWithoutBLOBs(TableConfiguration tc)
          Implements the rule for generating the select by example without BLOBs SQL Map element and DAO method.
static boolean generateSelectByPrimaryKey(ColumnDefinitions columnDefinitions, TableConfiguration tc)
          Implements the rule for generating the select by primary key SQL Map element and DAO method.
static boolean generateSQLExampleWhereClause(TableConfiguration tc)
          Implements the rule for generating the SQL example where clause element.
static boolean generateUpdateByPrimaryKeyWithBLOBs(ColumnDefinitions columnDefinitions, TableConfiguration tc)
          Implements the rule for generating the update by primary key with BLOBs SQL Map element and DAO method.
static boolean generateUpdateByPrimaryKeyWithoutBLOBs(ColumnDefinitions columnDefinitions, TableConfiguration tc)
          Implements the rule for generating the update by primary key without BLOBs SQL Map element and DAO method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

generatePrimaryKey

public static boolean generatePrimaryKey(ColumnDefinitions columnDefinitions)
Implements the rule for determining whether to generate a primary key class. If the physical table has a primary key, then we generate the class.

Parameters:
columnDefinitions - the introspected table columns
Returns:
true if the primary key should be generated

generateBaseRecordExtendingPrimaryKey

public static boolean generateBaseRecordExtendingPrimaryKey(ColumnDefinitions columnDefinitions)
Implements the rule for generating a base record that extends the primary key. If the table has a primary key, and has non-BLOB non-Primary Key fields, then generate the class.

Parameters:
columnDefinitions - the introspected table columns
Returns:
true if the base record class should be generated

generateBaseRecordWithNoSuperclass

public static boolean generateBaseRecordWithNoSuperclass(ColumnDefinitions columnDefinitions)
Implements the rule for generating a base record with no super class. If the table does not have a primary key, then generate the class.

Parameters:
columnDefinitions - the introspected table columns
Returns:
true if the base record class should be generated

generateRecordWithBLOBsExtendingPrimaryKey

public static boolean generateRecordWithBLOBsExtendingPrimaryKey(ColumnDefinitions columnDefinitions)
Implements the rule for generating a record with BLOBs class extending the primary key class. If the table has a primary key, but all other fields are BLOBs, then generate the class.

Parameters:
columnDefinitions - the introspected table columns
Returns:
true if the record with BLOBs class should be generated

generateRecordWithBLOBsExtendingBaseRecord

public static boolean generateRecordWithBLOBsExtendingBaseRecord(ColumnDefinitions columnDefinitions)
Implements the rule for generating a record with BLOBs class extending the base record class. If the table has non-BLOB non-Primary Key fields, then generate the class.

Parameters:
columnDefinitions - the introspected table columns
Returns:
true if the record with BLOBs class should be generated

generateExampleExtendingPrimaryKey

public static boolean generateExampleExtendingPrimaryKey(ColumnDefinitions columnDefinitions,
                                                         TableConfiguration tc)
Implements the rule for generating an example class extending the primary key. If there is a primary key, and there are no non-Primary Key non-Blob fields, then generate the class. Also, the class should only be generated if the selectByExample or deleteByExample methods are allowed.

Parameters:
columnDefinitions - the introspected table columns
tc - the table configuration object
Returns:
true if the example class should be generated

generateExampleExtendingBaseRecord

public static boolean generateExampleExtendingBaseRecord(ColumnDefinitions columnDefinitions,
                                                         TableConfiguration tc)
Implements the rule for generating an example class extending the base record. If there are non non-Primary Key non-Blob fields, then generate the class. Also, the class should only be generated if the selectByExample or deleteByExample methods are allowed.

Parameters:
columnDefinitions - the introspected table columns
tc - the table configuration object
Returns:
true if the example class should be generated

generateResultMapWithoutBLOBs

public static boolean generateResultMapWithoutBLOBs(TableConfiguration tc)
Implements the rule for generating the result map without BLOBs. If either select method is allowed, then generate the result map.

Parameters:
tc - the table configuration object
Returns:
true if the result map should be generated

generateResultMapWithBLOBs

public static boolean generateResultMapWithBLOBs(ColumnDefinitions columnDefinitions,
                                                 TableConfiguration tc)
Implements the rule for generating the result map with BLOBs. If the table has BLOB columns, and either select method is allowed, then generate the result map.

Parameters:
columnDefinitions - the introspected table columns
tc - the table configuration object
Returns:
true if the result map should be generated

generateSQLExampleWhereClause

public static boolean generateSQLExampleWhereClause(TableConfiguration tc)
Implements the rule for generating the SQL example where clause element. Generate the element if either the selectByExample or deleteByExample statement is allowed.

Parameters:
tc - the table configuration object
Returns:
true if the SQL where clause element should be generated

generateSelectByExampleWithoutBLOBs

public static boolean generateSelectByExampleWithoutBLOBs(TableConfiguration tc)
Implements the rule for generating the select by example without BLOBs SQL Map element and DAO method. If the selectByExample statement is allowed, then generate the element and method.

Parameters:
tc - the table configuration object
Returns:
true if the element and method should be generated

generateSelectByExampleWithBLOBs

public static boolean generateSelectByExampleWithBLOBs(ColumnDefinitions columnDefinitions,
                                                       TableConfiguration tc)
Implements the rule for generating the select by example with BLOBs SQL Map element and DAO method. If the table has BLOB fields and the selectByExample statement is allowed, then generate the element and method.

Parameters:
columnDefinitions - the introspected table columns
tc - the table configuration object
Returns:
true if the element and method should be generated

generateSelectByPrimaryKey

public static boolean generateSelectByPrimaryKey(ColumnDefinitions columnDefinitions,
                                                 TableConfiguration tc)
Implements the rule for generating the select by primary key SQL Map element and DAO method. If the table has a primary key as well as other fields, and the selectByPrimaryKey statement is allowed, then generate the element and method.

Parameters:
columnDefinitions - the introspected table columns
tc - the table configuration object
Returns:
true if the element and method should be generated

generateInsert

public static boolean generateInsert(TableConfiguration tc)
Implements the rule for generating the insert SQL Map element and DAO method. If the insert statement is allowed, then generate the element and method.

Parameters:
tc - the table configuration object
Returns:
true if the element and method should be generated

generateUpdateByPrimaryKeyWithoutBLOBs

public static boolean generateUpdateByPrimaryKeyWithoutBLOBs(ColumnDefinitions columnDefinitions,
                                                             TableConfiguration tc)
Implements the rule for generating the update by primary key without BLOBs SQL Map element and DAO method. If the table has a primary key as well as other non-BLOB fields, and the updateByPrimaryKey statement is allowed, then generate the element and method.

Parameters:
columnDefinitions - the introspected table columns
tc - the table configuration object
Returns:
true if the element and method should be generated

generateUpdateByPrimaryKeyWithBLOBs

public static boolean generateUpdateByPrimaryKeyWithBLOBs(ColumnDefinitions columnDefinitions,
                                                          TableConfiguration tc)
Implements the rule for generating the update by primary key with BLOBs SQL Map element and DAO method. If the table has a primary key as well as other BLOB fields, and the updateByPrimaryKey statement is allowed, then generate the element and method.

Parameters:
columnDefinitions - the introspected table columns
tc - the table configuration object
Returns:
true if the element and method should be generated

generateDeleteByPrimaryKey

public static boolean generateDeleteByPrimaryKey(ColumnDefinitions columnDefinitions,
                                                 TableConfiguration tc)
Implements the rule for generating the delete by primary key SQL Map element and DAO method. If the table has a primary key, and the deleteByPrimaryKey statement is allowed, then generate the element and method.

Parameters:
columnDefinitions - the introspected table columns
tc - the table configuration object
Returns:
true if the element and method should be generated

generateDeleteByExample

public static boolean generateDeleteByExample(TableConfiguration tc)
Implements the rule for generating the delete by example SQL Map element and DAO method. If the deleteByExample statement is allowed, then generate the element and method.

Parameters:
tc - the table configuration object
Returns:
true if the element and method should be generated