org.pojava.persistence.sql
Class FieldMap<POJO,PROP,COL>

java.lang.Object
  extended by org.pojava.persistence.sql.FieldMap<POJO,PROP,COL>

public class FieldMap<POJO,PROP,COL>
extends Object

A FieldMap maps an individual field of a database table to an individual bean property. It specifies whether the field is regarded as a key field, the drill-down pattern should the mapped property be nested in more complex objects, and specifies an adaptor that can perform transformations of the data on import and export.

Author:
John Pile

Constructor Summary
FieldMap()
          Construct an empty FieldMap.
FieldMap(String property, String fieldName, boolean isKeyField, org.pojava.transformation.BindingAdaptor<PROP,COL> adaptor, TableMap<POJO> tableMap)
          Construct a FieldMap, specifying whether this is a key field.
FieldMap(String property, String fieldName, boolean isKeyField, Class<COL> columnClass, TableMap<POJO> tableMap)
          Construct a FieldMap, specifying whether this is a key field.
FieldMap(String property, String fieldName, boolean isKeyField, TableMap<POJO> tableMap, Class<COL> columnClass, AdaptorMap<PROP,COL> adaptorMap)
          Construct a FieldMap, specifying whether this is a key field.
 
Method Summary
 org.pojava.transformation.BindingAdaptor<PROP,COL> getAdaptor()
          Get the adaptor responsible for transforming the data between the database field and the bean property.
 Class<COL> getColumnClass()
          The columnClass specifies the class of the JDBC field representing the database field value.
 String getColumnName()
          The columnName is a reference to the database field name.
 Method[] getGetters()
          Get the array of getters that drill down to the property.
 String getProperty()
          The "property" is a reference to a field in a Java bean (POJO), that will typically match your private property name.
 Class<PROP> getPropertyClass()
          The property class represents the Class of the property stored in the Java bean.
 Method[] getSetters()
          Get the array of setters that drill down to the property.
 TableMap<POJO> getTableMap()
          Get the TableMap that contains this FieldMap.
 boolean isKeyField()
          True if field represents a key field in the table.
 void setAdaptor(org.pojava.transformation.BindingAdaptor<PROP,COL> adaptor)
          Set the adaptor responsible for transforming the data between the database field and the bean property.
 void setColumnClass(Class<COL> columnClass)
          The columnClass specifies the class of the JDBC field representing the database field value.
 void setColumnName(String columnName)
          Specify the database field name.
 void setGetters(Method[] getters)
          Set the array of getters that drill down to this FieldMap's referenced property.
 void setKeyField(boolean keyField)
          Specify whether the field is regarded as a key field.
 void setProperty(String property)
          The "property" is a reference to a field in a Java bean (POJO), that will typically match your private property name.
 void setPropertyClass(Class<PROP> propertyClass)
          The property class represents the Class of the property stored in the Java bean.
 void setPropertyValue(ResultSet rs, int column, Object obj)
          Set the property value to the converted mapped column of the row.
 void setSetters(Method[] setters)
          Set the array of setters drilling down to the specified class
 void setTableMap(TableMap<POJO> map)
          Specify the TableMap that contains this FieldMap.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FieldMap

public FieldMap()
Construct an empty FieldMap.


FieldMap

public FieldMap(String property,
                String fieldName,
                boolean isKeyField,
                Class<COL> columnClass,
                TableMap<POJO> tableMap)
         throws NoSuchMethodException
Construct a FieldMap, specifying whether this is a key field.

Parameters:
property -
fieldName -
isKeyField -
columnClass -
tableMap -
Throws:
NoSuchMethodException

FieldMap

public FieldMap(String property,
                String fieldName,
                boolean isKeyField,
                TableMap<POJO> tableMap,
                Class<COL> columnClass,
                AdaptorMap<PROP,COL> adaptorMap)
         throws NoSuchMethodException
Construct a FieldMap, specifying whether this is a key field.

Parameters:
property -
fieldName -
isKeyField -
tableMap -
columnClass -
adaptorMap - custom rules engine for determining a BindingAdaptor
Throws:
NoSuchMethodException

FieldMap

public FieldMap(String property,
                String fieldName,
                boolean isKeyField,
                org.pojava.transformation.BindingAdaptor<PROP,COL> adaptor,
                TableMap<POJO> tableMap)
         throws NoSuchMethodException
Construct a FieldMap, specifying whether this is a key field.

Parameters:
property -
fieldName -
isKeyField -
adaptor -
tableMap -
Throws:
NoSuchMethodException
Method Detail

getProperty

public String getProperty()
The "property" is a reference to a field in a Java bean (POJO), that will typically match your private property name. It is derived from the getter by deleting the word "get" (or "is") and lower-casing the first letter. Nested references are supported. For example, if your object contains a billing zip code as obj.getBillingAddress().getZip() then the property would be specified as billingAddress.zip.

Returns:
Property associated with this FieldMap

setProperty

public void setProperty(String property)
The "property" is a reference to a field in a Java bean (POJO), that will typically match your private property name. It is derived from the getter by deleting the word "get" (or "is") and lower-casing the first letter. Nested references are supported. For example, if your object contains a billing zip code as obj.getBillingAddress().getZip() then the property would be specified as billingAddress.zip.

Parameters:
property -

getColumnName

public String getColumnName()
The columnName is a reference to the database field name.

Returns:
Database field name.

setColumnName

public void setColumnName(String columnName)
Specify the database field name.

Parameters:
columnName -

getColumnClass

public Class<COL> getColumnClass()
The columnClass specifies the class of the JDBC field representing the database field value.

Returns:
type of JDBC column.

setColumnClass

public void setColumnClass(Class<COL> columnClass)
The columnClass specifies the class of the JDBC field representing the database field value.

Parameters:
columnClass - data type returned by JDBC for this field

isKeyField

public boolean isKeyField()
True if field represents a key field in the table.

Returns:
True if key field.

setKeyField

public void setKeyField(boolean keyField)
Specify whether the field is regarded as a key field.

Parameters:
keyField -

getPropertyClass

public Class<PROP> getPropertyClass()
The property class represents the Class of the property stored in the Java bean.

Returns:
Java Class of property value.

setPropertyClass

public void setPropertyClass(Class<PROP> propertyClass)
The property class represents the Class of the property stored in the Java bean.

Parameters:
propertyClass -

setPropertyValue

public void setPropertyValue(ResultSet rs,
                             int column,
                             Object obj)
                      throws SQLException
Set the property value to the converted mapped column of the row.

Parameters:
rs -
column -
obj -
Throws:
SQLException

getGetters

public Method[] getGetters()
Get the array of getters that drill down to the property.

Returns:
Array of (often only one) getters drilling down to a property.

setGetters

public void setGetters(Method[] getters)
Set the array of getters that drill down to this FieldMap's referenced property.

Parameters:
getters -

getSetters

public Method[] getSetters()
Get the array of setters that drill down to the property.

Returns:
Array of (often only one) setters drilling down to a property.

setSetters

public void setSetters(Method[] setters)
Set the array of setters drilling down to the specified class

Parameters:
setters -

getAdaptor

public org.pojava.transformation.BindingAdaptor<PROP,COL> getAdaptor()
Get the adaptor responsible for transforming the data between the database field and the bean property.

Returns:
BindingAdaptor

setAdaptor

public void setAdaptor(org.pojava.transformation.BindingAdaptor<PROP,COL> adaptor)
Set the adaptor responsible for transforming the data between the database field and the bean property.


setTableMap

public void setTableMap(TableMap<POJO> map)
Specify the TableMap that contains this FieldMap.

Parameters:
map -

getTableMap

public TableMap<POJO> getTableMap()
Get the TableMap that contains this FieldMap.

Returns:
containing TableMap


Copyright © 2011. All Rights Reserved.