R
- row classT
- Java field typepublic abstract class AbstractColumnTranslator<R,T> extends java.lang.Object implements ColumnTranslator<R>
Constructor and Description |
---|
AbstractColumnTranslator(RowField<R,T> rowfield,
java.lang.String columnName)
Constructs for a column.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getColumnName()
Gets the SQL column name.
|
java.lang.reflect.Field |
getField()
Gets the Java field that participates in translation.
|
RowField<R,T> |
getRowField()
Gets the
RowField for field in this translator. |
TypeTranslator<T> |
getTypeTranslator() |
boolean |
isIdentity()
Gets the identity status.
|
boolean |
isReadOnly()
Gets the readonly status.
|
static ColumnTranslator<?> |
newInstance(java.lang.Class<? extends ColumnTranslator> columnTranslatorClass,
RowField<?,?> rowField,
java.lang.String columnName)
Factory method for creating a new instance of a column translator for a row field.
|
void |
read(java.sql.ResultSet resultSet,
int columnIndex,
R row)
Reads column value from result set and sets in row object.
|
void |
setIdentity(boolean identity) |
void |
setReadOnly(boolean readOnly) |
void |
setTypeTranslator(TypeTranslator<T> typeTranslator)
Sets the translator to read result sets and write to prepared statements.
|
void |
write(java.sql.PreparedStatement preparedStatement,
int parameterIndex,
R row)
Gets column value from row and sets as parameter in prepared statement.
|
public AbstractColumnTranslator(RowField<R,T> rowfield, java.lang.String columnName) throws TranslatorException
ObjectTranslator
for default.rowfield
- field within row that corresponds to columncolumnName
- name of table column associated with rowFieldTranslatorException
- if errorpublic static ColumnTranslator<?> newInstance(java.lang.Class<? extends ColumnTranslator> columnTranslatorClass, RowField<?,?> rowField, java.lang.String columnName) throws TranslatorException
Class.newInstance()
. RowField
is needed instead of Field
so
that appropriate field access is used.columnTranslatorClass
- translatorrowField
- row field of row class to use in translatorcolumnName
- name of column associated with rowfield parameterTranslatorException
- if errorpublic java.lang.reflect.Field getField()
getField
in interface ColumnTranslator<R>
public java.lang.String getColumnName()
getColumnName
in interface ColumnTranslator<R>
public TypeTranslator<T> getTypeTranslator()
public void setTypeTranslator(TypeTranslator<T> typeTranslator)
typeTranslator
- type translator to use for this columnpublic boolean isIdentity()
isIdentity
in interface ColumnTranslator<R>
public void setIdentity(boolean identity)
public boolean isReadOnly()
isReadOnly
in interface ColumnTranslator<R>
public void setReadOnly(boolean readOnly)
public RowField<R,T> getRowField()
RowField
for field in this translator.RowField
for field supplied in constructorpublic void write(java.sql.PreparedStatement preparedStatement, int parameterIndex, R row) throws java.lang.Exception
write
in interface ColumnTranslator<R>
preparedStatement
- set column value as parameter in this statementparameterIndex
- set parameter at this indexrow
- get value from this rowjava.lang.Exception
- if errorpublic void read(java.sql.ResultSet resultSet, int columnIndex, R row) throws java.lang.Exception
read
in interface ColumnTranslator<R>
resultSet
- read column from this result setcolumnIndex
- read value at this column index from result setrow
- set value in this rowjava.lang.Exception
- if error