public class JdbcFloatAttributeMediator extends JdbcAttributeMediatorBase
JdbcAttributeMediatorInterface
and extends the class JdbcAttributeMediatorBase
. It is used to
mediate between a real attribute implementing the interface FloatAttributeInterface
and a numeric database field.
The mediator exchanges the attribute value between the attribute and a ResultSet
field or a PreparedStatement
parameter. When a result set
is passed to a method, the current row is used to update or retrieve the
attribute value. The method ResultSet.getFloat(int)
is called to
retrieve the attribute value and the static utility method JdbcUtilityFunctions.updateResultSetWithFloat(Float,ResultSet,int)
is
called to update the result set field. This method checks if the field value
has been changed and if the field is updatable before the field value is
updated. The method PreparedStatement.setFloat(int,float)
is called
to set the parameter of the prepared statement.
Note, that the column name passed to the constructor is not used to access
the result set column or prepared statement parameter. Instead the first
index in the index list passed to the methods is used, which improves
performance. The column name is used by the framework to determine the column
of a result set, the mediator is related to (see description of interface
JdbcAttributeMediatorInterface
). The mediator uses the column name
furthermore to insert the field name in error messages of exceptions like
JdbcAttributeWriteError
or JdbcFieldReadError
.
attributeKeyword, columnNames
Constructor and Description |
---|
JdbcFloatAttributeMediator(java.lang.String attributeKeyword)
This constructor can be used when the attribute keyword and the database
column name are equal.
|
JdbcFloatAttributeMediator(java.lang.String attributeKeyword,
java.lang.String columnName)
This constructor can be used when the attribute keyword and the database
column name are different.
|
Modifier and Type | Method and Description |
---|---|
void |
fillStatement(java.util.List<java.lang.Integer> parameterIndices,
java.sql.PreparedStatement statement,
ComponentInterface<?> component,
AttributeInterface<?> attribute)
This method implements the interface
JdbcAttributeMediatorInterface and sets the parameter with the first
index in the passed index list of the passed statement with the value of
the passed attribute. |
void |
updateAttribute(java.sql.ResultSet resultSet,
java.util.List<java.lang.Integer> fieldIndices,
ComponentInterface<?> component,
AttributeInterface<?> attribute)
This method implements the interface
JdbcAttributeMediatorInterface and sets the attribute value with the
value of the field in the result set at the current cursor position and
in the column with the first index of the passed index list. |
void |
updateResultSet(java.util.List<java.lang.Integer> fieldIndices,
java.sql.ResultSet resultSet,
ComponentInterface<?> component,
AttributeInterface<?> attribute)
This method implements the interface
JdbcAttributeMediatorInterface and updates the field of the passed
result set at the current cursor position and the first index of the
passed index list with the attribute value. |
getAttributeKeyword, getColumnIndices, getColumnNames
public JdbcFloatAttributeMediator(java.lang.String attributeKeyword)
attributeKeyword
- The keyword of the attribute processed by the
mediator. The attribute keyword is also used as database column name.public JdbcFloatAttributeMediator(java.lang.String attributeKeyword, java.lang.String columnName)
attributeKeyword
- The keyword of the attribute processed by the
mediator.columnName
- The database column name.public void fillStatement(java.util.List<java.lang.Integer> parameterIndices, java.sql.PreparedStatement statement, ComponentInterface<?> component, AttributeInterface<?> attribute) throws JdbcAttributeWriteError, java.lang.ClassCastException
JdbcAttributeMediatorInterface
and sets the parameter with the first
index in the passed index list of the passed statement with the value of
the passed attribute.parameterIndices
- The index list specifying the parameters to be
set with the attribute value. When the list is empty, no parameter is
set. This method uses only the first index in the list.statement
- The prepared statement containing the parameter to be
set.component
- The (parent) component containing the attribute. The
component is only used to retrieve information for the exception JdbcAttributeWriteError
.attribute
- The attribute used to retrieve the value for the
statement parameter. This attribute must implement the interface FloatAttributeInterface
.JdbcAttributeWriteError
- Thrown, when setting the parameter of the
prepared statement fails.java.lang.ClassCastException
- Thrown, when the attribute doesn't implement
the interface FloatAttributeInterface
.public void updateAttribute(java.sql.ResultSet resultSet, java.util.List<java.lang.Integer> fieldIndices, ComponentInterface<?> component, AttributeInterface<?> attribute) throws AttributeException, JdbcAttributeReadError, java.lang.ClassCastException
JdbcAttributeMediatorInterface
and sets the attribute value with the
value of the field in the result set at the current cursor position and
in the column with the first index of the passed index list.resultSet
- The result set containing the field for the attribute
value.fieldIndices
- The index list specifying the columns in the result
set with the attribute value. When the list is empty, the attribute value
is not set. This method uses only the first index in the list.component
- The (parent) component containing the attribute. The
component is only used to retrieve information for the exception JdbcAttributeReadError
.attribute
- The attribute, of which the value is set with the value
retrieved from the result set. This attribute must implement the
interface FloatAttributeInterface
.AttributeException
- Thrown, when setting the attribute value
fails.JdbcAttributeReadError
- Thrown, when accessing the result set
field fails.java.lang.ClassCastException
- Thrown, when the attribute doesn't implement
the interface FloatAttributeInterface
.public void updateResultSet(java.util.List<java.lang.Integer> fieldIndices, java.sql.ResultSet resultSet, ComponentInterface<?> component, AttributeInterface<?> attribute) throws JdbcAttributeWriteError, java.lang.ClassCastException
JdbcAttributeMediatorInterface
and updates the field of the passed
result set at the current cursor position and the first index of the
passed index list with the attribute value. The method JdbcUtilityFunctions.updateResultSetWithFloat(Float,ResultSet,int)
is
called to update the result set field. This method updates the field only
if it is writable and if the value is different.fieldIndices
- The index list specifying the columns in the result
set for the attribute value. When the list is empty, the result set is
not updated. This method uses only the first index in the list.resultSet
- The result set containing the field for the attribute
value.component
- The (parent) component containing the attribute. The
component is only used to retrieve information for the exception JdbcAttributeWriteError
.attribute
- The attribute delivering the value for the result set.
This attribute must implement the interface FloatAttributeInterface
.JdbcAttributeWriteError
- Thrown, when updating the result set
field fails.java.lang.ClassCastException
- Thrown, when the attribute doesn't implement
the interface FloatAttributeInterface
.