SolarMetric Kodo JDO 2.5.0 Reverse Schema Tool

com.solarmetric.rd.kodo.impl.jdbc.meta.map
Class TransformationMapping

java.lang.Object
  |
  +--com.solarmetric.rd.kodo.impl.jdbc.meta.Mapping
        |
        +--com.solarmetric.rd.kodo.impl.jdbc.meta.ExtensionsMapping
              |
              +--com.solarmetric.rd.kodo.impl.jdbc.meta.FieldMapping
                    |
                    +--com.solarmetric.rd.kodo.impl.jdbc.meta.map.ReferenceMapping
                          |
                          +--com.solarmetric.rd.kodo.impl.jdbc.meta.map.ColumnMapping
                                |
                                +--com.solarmetric.rd.kodo.impl.jdbc.meta.map.TransformationMapping
All Implemented Interfaces:
java.lang.Comparable, Extensions, FieldMetaData, PrimaryKeyMapping, VersionableMapping

public abstract class TransformationMapping
extends ColumnMapping
implements PrimaryKeyMapping, VersionableMapping

Easily-extendable mapping for transforming a field value from one simple type to another. For example, an female field in the Java class might store a boolean, but it is mapped to a SEX column that stores a M or F character.

To create a concrete subclass of this mapping, define the following methods:


Field Summary
 
Fields inherited from class com.solarmetric.rd.kodo.impl.jdbc.meta.FieldMapping
CONTAINER_META, DELETE_ACTION, ELEMENT_DELETE_ACTION, ELEMENT_INDEXED, ELEMENT_SIZE, EMPTY_COLUMNS, INDEXED, KEY_DELETE_ACTION, KEY_INDEXED, KEY_SIZE, ORDERED, REF_DELETE_ACTION, REF_INDEXED, SIZE, TYPE_ASCII_STREAM, TYPE_BINARY_STREAM, TYPE_BLOB, TYPE_BYTES, TYPE_CHAR_STREAM, TYPE_CLOB, TYPE_JDBC_DEFAULT, TYPE_REF, TYPE_SQL_ARRAY, TYPE_SQL_DATE, TYPE_SQL_OBJECT, TYPE_TIME, TYPE_TIMESTAMP, USE_FIELD_MAP, USE_NULL_IND, VALUE_DELETE_ACTION, VALUE_INDEXED, VALUE_SIZE
 
Fields inherited from class com.solarmetric.rd.kodo.impl.jdbc.meta.Mapping
DEFAULT, FALSE, LOB, TRUE, UNIQUE
 
Fields inherited from interface com.solarmetric.rd.kodo.meta.FieldMetaData
DEPENDENT, ELEMENT_DEPENDENT, ELEMENT_PC_CLASS, INVERSE_OWNER, KEY_DEPENDENT, KEY_PC_CLASS, MANAGE_NONE, MANAGE_PERSISTENT, MANAGE_TRANSACTIONAL, NULL_DEFAULT, NULL_EXCEPTION, NULL_NONE, PC_CLASS, TYPE_ARRAY, TYPE_BIGDECIMAL, TYPE_BIGINTEGER, TYPE_BOOLEAN, TYPE_BOOLEAN_OBJ, TYPE_BYTE, TYPE_BYTE_OBJ, TYPE_CHAR, TYPE_CHAR_OBJ, TYPE_COLLECTION, TYPE_DATE, TYPE_DOUBLE, TYPE_DOUBLE_OBJ, TYPE_FCO, TYPE_FLOAT, TYPE_FLOAT_OBJ, TYPE_INT, TYPE_INT_OBJ, TYPE_LOCALE, TYPE_LONG, TYPE_LONG_OBJ, TYPE_MAP, TYPE_NUMBER, TYPE_OBJECT, TYPE_PC_OBJECT, TYPE_SHORT, TYPE_SHORT_OBJ, TYPE_STRING, VALUE_DEPENDENT, VALUE_PC_CLASS
 
Constructor Summary
TransformationMapping(com.solarmetric.rd.kodo.meta.FieldMetaData meta)
          Constructor.
 
Method Summary
protected abstract  java.lang.Object getJavaValue(java.lang.Object val)
          Transform the given database value to the value that should be stored in the Java field for this mapping.
 java.lang.Object getPrimaryKeyValue(com.solarmetric.rd.kodo.impl.jdbc.runtime.Result res, com.solarmetric.rd.kodo.impl.jdbc.schema.Column[] cols, int colIndex)
          Load the primary key value for this field from the given result.
 void load(com.solarmetric.rd.kodo.runtime.StateManagerImpl sm, com.solarmetric.rd.kodo.impl.jdbc.runtime.JDBCStoreManager store, java.sql.Connection conn)
          Load secondary data.
 void load(com.solarmetric.rd.kodo.runtime.StateManagerImpl sm, com.solarmetric.rd.kodo.impl.jdbc.runtime.JDBCStoreManager store, com.solarmetric.rd.kodo.impl.jdbc.runtime.Result res)
          Load virtual row data; the given result is not guaranteed to contain data for this field, so the field mapping should make sure the result contains its needed column data before loading.
 void select(com.solarmetric.rd.kodo.impl.jdbc.runtime.Select sel, boolean multiple)
          Select the virtual row columns of this mapping.
 java.lang.Boolean selectVRowData(com.solarmetric.rd.kodo.runtime.StateManagerImpl sm)
          Return Boolean.TRUE if 'virtual row' data needs to be selected, Boolean.FALSE if it does not need to be, and null if it would be desirable to select it, but is not necessary.
 void setPrimaryKeyValue(com.solarmetric.rd.kodo.impl.jdbc.runtime.Row row, com.solarmetric.rd.kodo.impl.jdbc.schema.Column[] cols, int colIndex, java.lang.Object val, boolean set)
          Set the primary key value of this mapping into the given row.
protected  void update(com.solarmetric.rd.kodo.runtime.StateManagerImpl sm, com.solarmetric.rd.kodo.impl.jdbc.runtime.Row row)
          Update this column with the current value into the given row.
 void where(com.solarmetric.rd.kodo.runtime.StateManagerImpl sm, com.solarmetric.rd.kodo.impl.jdbc.runtime.RowManager rm, java.lang.Object prevValue)
          Add a WHERE condition to the row for this field such that the field's current DB value must equal the given previous value.
 
Methods inherited from class com.solarmetric.rd.kodo.impl.jdbc.meta.map.ColumnMapping
appendIsEmpty, appendIsNotNull, appendIsNull, checkNull, delete, deleteEmbedded, fromMappingInfo, getColumn, getColumns, getDataStoreTypeCode, getJDBCType, getKeyColumns, getVRowTable, insert, join, joinKey, joinKeyRelation, joinRelation, map, nullEmbedded, refSchemaComponents, setColumn, toMappingInfo, update
 
Methods inherited from class com.solarmetric.rd.kodo.impl.jdbc.meta.map.ReferenceMapping
createRefForeignKey, fromMappingInfo, getRefForeignKey, getSelectJoins, getTable, join, setRefForeignKey, wherePrimaryKey
 
Methods inherited from class com.solarmetric.rd.kodo.impl.jdbc.meta.FieldMapping
addExtension, addExtension, checkRepository, compareTo, deleteEmbedded, getBooleanExtension, getBooleanExtension, getContainerMeta, getDataStoreValue, getDeclaredElementType, getDeclaredIndex, getDeclaredKeyType, getDeclaredType, getDefaults, getDeleteAction, getDoubleExtension, getDoubleExtension, getElementDeleteAction, getElementIndexed, getElementPCClass, getElementSize, getElementType, getElementTypeCode, getElementTypeMapping, getElementTypeMetaData, getEmbeddedExtensions, getEmbeddedExtensions, getExtensionKeys, getExtensionKeys, getExtensionVendors, getFieldFlag, getFullName, getIndex, getIndexed, getIntExtension, getIntExtension, getInverseOwner, getInverseOwnerMapping, getInverseOwnerMetaData, getKeyDataStoreValue, getKeyDeleteAction, getKeyIndexed, getKeyPCClass, getKeySize, getKeyType, getKeyTypeCode, getKeyTypeMapping, getKeyTypeMetaData, getManagement, getMappingRepository, getMetaData, getName, getNullValue, getObjectExtension, getObjectExtension, getOrdered, getOwner, getOwnerMapping, getPCClass, getRefDeleteAction, getRefIndexed, getSize, getStringExtension, getStringExtension, getType, getTypeCode, getTypeMapping, getTypeMetaData, getUseFieldMapping, getUseNullIndicator, hasExtension, hasExtension, invalidateResolve, isCustomDeleteEmbedded, isCustomNullEmbedded, isDeleteActionDeferred, isDependent, isEager, isElementDeleteActionDeferred, isElementDependent, isElementEager, isEmbedded, isEmbeddedElement, isEmbeddedKey, isEmpty, isExplicit, isInDefaultFetchGroup, isKeyDeleteActionDeferred, isKeyDependent, isKeyEager, isPrimaryKey, isRefDeleteActionDeferred, isValue, newInstance, newInstance, nullEmbedded, removeEmbeddedExtensions, removeEmbeddedExtensions, removeExtension, removeExtension, resolve, setContainerMeta, setDeclaredIndex, setDeleteAction, setDependent, setElementDeleteAction, setElementDependent, setElementIndexed, setElementPCClass, setElementSize, setElementType, setEmbedded, setEmbeddedElement, setEmbeddedKey, setExplicit, setInDefaultFetchGroup, setIndex, setIndexed, setInverseOwner, setKeyDeleteAction, setKeyDependent, setKeyIndexed, setKeyPCClass, setKeySize, setKeyType, setManagement, setName, setNullValue, setOrdered, setOwner, setPCClass, setPrimaryKey, setRefDeleteAction, setRefIndexed, setSize, setType, setUseFieldMapping, setUseNullIndicator, toString
 
Methods inherited from class com.solarmetric.rd.kodo.impl.jdbc.meta.Mapping
checkIndex, createColumn, delete, getDBDictionary, getForeignKey, getLog, getMappingType, getSchemaGroup, insert, invalidMapping, isCustomDelete, isCustomInsert, isCustomUpdate, reverseMap, setForeignKey, update
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.solarmetric.rd.kodo.meta.Extensions
addExtension, addExtension, getBooleanExtension, getBooleanExtension, getDoubleExtension, getDoubleExtension, getEmbeddedExtensions, getEmbeddedExtensions, getExtensionKeys, getExtensionKeys, getExtensionVendors, getIntExtension, getIntExtension, getObjectExtension, getObjectExtension, getStringExtension, getStringExtension, hasExtension, hasExtension, isEmpty, removeEmbeddedExtensions, removeEmbeddedExtensions, removeExtension, removeExtension
 

Constructor Detail

TransformationMapping

public TransformationMapping(com.solarmetric.rd.kodo.meta.FieldMetaData meta)
Constructor. Supply underlying metadata.

Method Detail

getJavaValue

protected abstract java.lang.Object getJavaValue(java.lang.Object val)
Transform the given database value to the value that should be stored in the Java field for this mapping. If the Java field is a primitive, make sure not to return null.


selectVRowData

public java.lang.Boolean selectVRowData(com.solarmetric.rd.kodo.runtime.StateManagerImpl sm)
Description copied from class: FieldMapping
Return Boolean.TRUE if 'virtual row' data needs to be selected, Boolean.FALSE if it does not need to be, and null if it would be desirable to select it, but is not necessary.

Specified by:
selectVRowData in class FieldMapping

update

protected void update(com.solarmetric.rd.kodo.runtime.StateManagerImpl sm,
                      com.solarmetric.rd.kodo.impl.jdbc.runtime.Row row)
               throws java.sql.SQLException
Description copied from class: ColumnMapping
Update this column with the current value into the given row.

Specified by:
update in class ColumnMapping
java.sql.SQLException

select

public void select(com.solarmetric.rd.kodo.impl.jdbc.runtime.Select sel,
                   boolean multiple)
Description copied from class: FieldMapping
Select the virtual row columns of this mapping.

Specified by:
select in class FieldMapping
Parameters:
sel - the select to add to
multiple - whether this select is expected to match multiple objects

load

public void load(com.solarmetric.rd.kodo.runtime.StateManagerImpl sm,
                 com.solarmetric.rd.kodo.impl.jdbc.runtime.JDBCStoreManager store,
                 com.solarmetric.rd.kodo.impl.jdbc.runtime.Result res)
          throws java.sql.SQLException
Description copied from class: FieldMapping
Load virtual row data; the given result is not guaranteed to contain data for this field, so the field mapping should make sure the result contains its needed column data before loading.

Specified by:
load in class FieldMapping
java.sql.SQLException

load

public void load(com.solarmetric.rd.kodo.runtime.StateManagerImpl sm,
                 com.solarmetric.rd.kodo.impl.jdbc.runtime.JDBCStoreManager store,
                 java.sql.Connection conn)
          throws java.sql.SQLException
Description copied from class: FieldMapping
Load secondary data.

Specified by:
load in class FieldMapping
java.sql.SQLException

where

public void where(com.solarmetric.rd.kodo.runtime.StateManagerImpl sm,
                  com.solarmetric.rd.kodo.impl.jdbc.runtime.RowManager rm,
                  java.lang.Object prevValue)
           throws java.sql.SQLException
Description copied from interface: VersionableMapping
Add a WHERE condition to the row for this field such that the field's current DB value must equal the given previous value.

Specified by:
where in interface VersionableMapping
java.sql.SQLException

getPrimaryKeyValue

public java.lang.Object getPrimaryKeyValue(com.solarmetric.rd.kodo.impl.jdbc.runtime.Result res,
                                           com.solarmetric.rd.kodo.impl.jdbc.schema.Column[] cols,
                                           int colIndex)
                                    throws java.sql.SQLException
Description copied from interface: PrimaryKeyMapping
Load the primary key value for this field from the given result.

Specified by:
getPrimaryKeyValue in interface PrimaryKeyMapping
Parameters:
res - the result to load from
cols - the columns in the row corresponding to all the primary key columns of the owning class
colIndex - the index in the cols array of the first column that belongs to this primary key mapping; any additional primary key columns will be sequentially after the index
Returns:
the value of this primary key field
java.sql.SQLException

setPrimaryKeyValue

public void setPrimaryKeyValue(com.solarmetric.rd.kodo.impl.jdbc.runtime.Row row,
                               com.solarmetric.rd.kodo.impl.jdbc.schema.Column[] cols,
                               int colIndex,
                               java.lang.Object val,
                               boolean set)
                        throws java.sql.SQLException
Description copied from interface: PrimaryKeyMapping
Set the primary key value of this mapping into the given row.

Specified by:
setPrimaryKeyValue in interface PrimaryKeyMapping
Parameters:
row - the row to set into
cols - the columns in the row corresponding to the primary key columns in the owning class
colIndex - the index in the cols array of the first column that belongs to this primary key mapping; any additional primary key columns will be sequentially after the index
val - the Java value of this field
set - if true, set the value into the row; if false, add a where condition to the row
java.sql.SQLException

SolarMetric Kodo JDO 2.5.0 Reverse Schema Tool

Copyright 2001,2002,2003 SolarMetric, Inc. All Rights Reserved.