com.is.jrf
Interface ColumnSpec

All Superinterfaces:
JRFConstants
All Known Implementing Classes:
AbstractColumnSpec, CompoundPrimaryKeyColumnSpec

public interface ColumnSpec
extends JRFConstants

Implementors of this interface represent columns in the table represented by the domain subclass.


Fields inherited from interface com.is.jrf.JRFConstants
CURRENT_DATE, CURRENT_TIMESTAMP, DEFAULT_TO_EMPTY_STRING, DEFAULT_TO_FALSE, DEFAULT_TO_NOW, DEFAULT_TO_NULL, DEFAULT_TO_ONE, DEFAULT_TO_TODAY, DEFAULT_TO_TRUE, DEFAULT_TO_ZERO, EQUALS, NATURAL_PRIMARY_KEY, NO_POST_FIND, NOT_EQUALS, OPTIMISTIC_LOCK, REQUIRED, SEQUENCED_PRIMARY_KEY, SUBTYPE_IDENTIFIER, UNIQUE
 
Method Summary
 java.lang.String buildNameValuePair(java.lang.Object pkOrPersistentObject, java.lang.String separator, java.lang.String tableName, DatabasePolicy dbPolicy)
          This method is used to build an equals (or not-equals) String for WHERE clauses and UPDATE statements.
 java.lang.String buildWhereClause(java.lang.Object pkOrPersistentObject, java.lang.String separator, java.lang.String tableName, DatabasePolicy dbPolicy)
          Note: This method is overridden by CompoundPrimaryKeyColumnSpec to include " AND " between each name-value pair.
 java.lang.String columnDefinitionString(DatabasePolicy dbPolicy)
           
 void copyAttribute(PersistentObject aPO1, PersistentObject aPO2)
          Copy the attribute I represent from one persistent object to another.
 void copyColumnValueToPersistentObject(JDBCHelper helper, PersistentObject aPO)
          Copy the value of my column to the appropriate attribute for this persistent object.
 void decodeToPersistentObject(java.lang.String aString, PersistentObject aPO)
          This method does the reverse of encodeFromPersistentObject(aPO)
 java.lang.String encodeFromPersistentObject(PersistentObject aPO)
          Convert the attribute(s) in the given PersistentObject to a String that can be decoded later.
 java.lang.String formatForSql(java.lang.Object obj, DatabasePolicy dbPolicy)
          Returns a string representing the given attribute value.
 java.lang.Class getColumnClass()
          See IntegerColumnSpec for how to implement.
 java.lang.String getColumnName()
           
 java.lang.Object getColumnValueFrom(JDBCHelper helper)
          See IntegerColumnSpec for how to implement:
 java.lang.Object getDefault()
           
 java.lang.String getFullyQualifiedColumnName(java.lang.String tableAlias)
           
 java.lang.String getGetter()
           
 java.lang.String getSetter()
           
 java.lang.String getSqlValueFrom(PersistentObject aPO, DatabasePolicy dbPolicy)
          Get a string representation of the value of this attribute from aPO.
 java.lang.Object getValueFrom(PersistentObject aPO)
          Get the value of this attribute from aPO.
 boolean isNaturalPrimaryKey()
           
 boolean isOptimisticLock()
           
 boolean isPrimaryKey()
           
 boolean isRequired()
           
 boolean isSequencedPrimaryKey()
           
 boolean isSubtypeIdentifier()
           
 boolean isUnique()
           
 void setRequired(boolean b)
          CompoundPrimaryKeyColumnSpec uses this to force it's children to "REQUIRED".
 void setValueTo(java.lang.Object aValue, PersistentObject aPO)
          This is a pass-through method that passes along my setter and column class.
 java.lang.Object validateRequired(PersistentObject aPO)
          Make sure the PersistentObject object has this attribute (if required).
 void validateUnique(PersistentObject aPO, JDBCHelper helper, ColumnSpec pkColumnSpec, DatabasePolicy dbPolicy, java.lang.String tableName)
          If Column is declared UNIQUE, make sure it doesn't already exist in the table.
 

Method Detail

formatForSql

public java.lang.String formatForSql(java.lang.Object obj,
                                     DatabasePolicy dbPolicy)
Returns a string representing the given attribute value. The string will be used in an SQL expression.
Parameters:
obj - a value of type 'Object'
Returns:
a value of type 'String'

getColumnClass

public java.lang.Class getColumnClass()
See IntegerColumnSpec for how to implement.

getColumnValueFrom

public java.lang.Object getColumnValueFrom(JDBCHelper helper)
                                    throws java.sql.SQLException
See IntegerColumnSpec for how to implement:

copyColumnValueToPersistentObject

public void copyColumnValueToPersistentObject(JDBCHelper helper,
                                              PersistentObject aPO)
                                       throws java.sql.SQLException
Copy the value of my column to the appropriate attribute for this persistent object.
Parameters:
helper - a value of type 'JDBCHelper'
aPO - a value of type 'PersistentObject'
Throws:
java.sql.SQLException - if an error occurs

copyAttribute

public void copyAttribute(PersistentObject aPO1,
                          PersistentObject aPO2)
Copy the attribute I represent from one persistent object to another.
Parameters:
aPO1 - a value of type 'PersistentObject'
aPO2 - a value of type 'PersistentObject'

buildWhereClause

public java.lang.String buildWhereClause(java.lang.Object pkOrPersistentObject,
                                         java.lang.String separator,
                                         java.lang.String tableName,
                                         DatabasePolicy dbPolicy)
Note: This method is overridden by CompoundPrimaryKeyColumnSpec to include " AND " between each name-value pair.
Parameters:
aPO - a value of type 'PersistentObject'
separator - a value of type 'String'
tableName - a value of type 'String'
dbPolicy - a value of type 'DatabasePolicy'
Returns:
a value of type 'String'

buildNameValuePair

public java.lang.String buildNameValuePair(java.lang.Object pkOrPersistentObject,
                                           java.lang.String separator,
                                           java.lang.String tableName,
                                           DatabasePolicy dbPolicy)
This method is used to build an equals (or not-equals) String for WHERE clauses and UPDATE statements. This method should not be used for CompoundPrimaryKeyColumnSpec instances. Use #buildWhereClause() instead.
Parameters:
pkOrPersistentObject - a value of type 'Object'
separator - a value of type 'String' - use EQUALS or NOT_EQUALS static final variables.
tableName - a value of type 'String'
dbPolicy - a value of type 'DatabasePolicy'
Returns:
a value of type 'String'

validateRequired

public java.lang.Object validateRequired(PersistentObject aPO)
                                  throws MissingAttributeException
Make sure the PersistentObject object has this attribute (if required).
Parameters:
aPO - a value of type 'PersistentObject'
Returns:
a value of type 'Object' - This is the value of the attribute. This is so subclasses can call super.validateRequired().
Throws:
MissingAttributeException - if attribute should be populated and it is not.

validateUnique

public void validateUnique(PersistentObject aPO,
                           JDBCHelper helper,
                           ColumnSpec pkColumnSpec,
                           DatabasePolicy dbPolicy,
                           java.lang.String tableName)
                    throws DuplicateRowException
If Column is declared UNIQUE, make sure it doesn't already exist in the table.
Parameters:
aPO - a value of type 'PersistentObject'
helper - a value of type 'JDBCHelper'
pkColumnSpec - a value of type 'ColumnSpec'
Throws:
DuplicateRowException - if a row with this value already exists.

getSqlValueFrom

public java.lang.String getSqlValueFrom(PersistentObject aPO,
                                        DatabasePolicy dbPolicy)
Get a string representation of the value of this attribute from aPO. This string can be inserted into a SQL statement.
Parameters:
aPO - a value of type 'PersistentObject'
Returns:
a value of type 'String'

getValueFrom

public java.lang.Object getValueFrom(PersistentObject aPO)
Get the value of this attribute from aPO. If the value is null, the default value will be returned.
Parameters:
aPO - a value of type 'PersistentObject'
Returns:
a value of type 'Object'

setValueTo

public void setValueTo(java.lang.Object aValue,
                       PersistentObject aPO)
This is a pass-through method that passes along my setter and column class.
Parameters:
aValue - a value of type 'Object'
aPO - a value of type 'PersistentObject'

encodeFromPersistentObject

public java.lang.String encodeFromPersistentObject(PersistentObject aPO)
Convert the attribute(s) in the given PersistentObject to a String that can be decoded later. The result of this method is not for use in SQL.
Parameters:
aPO - a value of type 'PersistentObject'
Returns:
a value of type 'String'

decodeToPersistentObject

public void decodeToPersistentObject(java.lang.String aString,
                                     PersistentObject aPO)
This method does the reverse of encodeFromPersistentObject(aPO)
Parameters:
aString - a value of type 'String'
aPO - a value of type 'PersistentObject'

getFullyQualifiedColumnName

public java.lang.String getFullyQualifiedColumnName(java.lang.String tableAlias)

getColumnName

public java.lang.String getColumnName()

getGetter

public java.lang.String getGetter()

getSetter

public java.lang.String getSetter()

isRequired

public boolean isRequired()

isSequencedPrimaryKey

public boolean isSequencedPrimaryKey()

isNaturalPrimaryKey

public boolean isNaturalPrimaryKey()

isPrimaryKey

public boolean isPrimaryKey()

isUnique

public boolean isUnique()

isSubtypeIdentifier

public boolean isSubtypeIdentifier()

getDefault

public java.lang.Object getDefault()

isOptimisticLock

public boolean isOptimisticLock()

setRequired

public void setRequired(boolean b)
CompoundPrimaryKeyColumnSpec uses this to force it's children to "REQUIRED".

columnDefinitionString

public java.lang.String columnDefinitionString(DatabasePolicy dbPolicy)