R
- class of row to translatepublic class ColumnsTranslator<R>
extends java.lang.Object
Constructor and Description |
---|
ColumnsTranslator(java.lang.Class<R> rowClass)
Constructs for a row class.
|
Modifier and Type | Method and Description |
---|---|
void |
addColumnTranslator(ColumnTranslator<R> c)
Adds a column translator to use in
read(ResultSet, int, Object) and
write(PreparedStatement, int, Object) . |
java.lang.String |
createColumnParameterPhrase()
Creates sql phrase of column names with parameters .
|
java.lang.String |
createColumnPhrase()
Gets sql phrase as list of columns.
|
java.lang.String |
createParameterPhrase()
Creates parameter placeholders for all columns.
|
ColumnTranslator<R> |
getColumnTranslator(java.lang.String fieldName)
Gets a column translator associated with a field.
|
java.util.List<ColumnTranslator<R>> |
getColumnTranslatorList()
Gets list of all column translators used by this translator.
|
java.lang.Class<R> |
getRowClass()
Gets Java class type for row.
|
protected void |
initColumnTranslatorList(int columns)
Initializes objects to hold all column information.
|
protected boolean |
isIncluded(ColumnTranslator<R> columnTranslator)
Tests if a column should be used.
|
boolean |
isIncludeIdentityColumns()
Tests if identity columns are used by this translator.
|
boolean |
isIncludeReadOnlyColumns()
Tests if readonly columns are used by this translator.
|
int |
read(java.sql.ResultSet resultSet,
int columnIndex,
R row)
Reads a record from a result set.
|
void |
setIncludeIdentityColumns(boolean includeIdentityColumns)
Sets when to use identity columns.
|
void |
setIncludeReadOnlyColumns(boolean includeReadOnlyColumns)
Sets when to use readonly columns.
|
int |
write(java.sql.PreparedStatement preparedStatement,
int parameterIndex,
R row)
Sets parameters in a prepared statement.
|
public ColumnsTranslator(java.lang.Class<R> rowClass) throws TranslatorException
rowClass
- class of row to translateTranslatorException
- if errorpublic boolean isIncludeIdentityColumns()
public void setIncludeIdentityColumns(boolean includeIdentityColumns)
includeIdentityColumns
- true to include all columns; false to include only non identity columnspublic boolean isIncludeReadOnlyColumns()
public void setIncludeReadOnlyColumns(boolean includeReadOnlyColumns)
includeReadOnlyColumns
- true to include all columns; false to include only non readonly columnsprotected void initColumnTranslatorList(int columns)
columns
- approximate number of columns that will be in translator (used as initial capacity)public int read(java.sql.ResultSet resultSet, int columnIndex, R row) throws TranslatorException
resultSet
- JDBC result setcolumnIndex
- starting column indexrow
- write values into this objectTranslatorException
- if errorpublic int write(java.sql.PreparedStatement preparedStatement, int parameterIndex, R row) throws TranslatorException
preparedStatement
- set parameters for this prepared statementparameterIndex
- starting parameter indexrow
- read parameters from this row objectTranslatorException
- if errorpublic void addColumnTranslator(ColumnTranslator<R> c)
read(ResultSet, int, Object)
and
write(PreparedStatement, int, Object)
.c
- column translatorpublic ColumnTranslator<R> getColumnTranslator(java.lang.String fieldName)
fieldName
- row class field namepublic java.lang.Class<R> getRowClass()
public java.lang.String createColumnPhrase()
public java.lang.String createColumnParameterPhrase()
public java.lang.String createParameterPhrase()
public java.util.List<ColumnTranslator<R>> getColumnTranslatorList()
protected boolean isIncluded(ColumnTranslator<R> columnTranslator)
isIncludeIdentityColumns()
, ColumnTranslator.isIdentity()
,
isIncludeReadOnlyColumns()
, ColumnTranslator.isReadOnly()
columnTranslator
- column to test