Package no.digipost.jdbc
Interface ColumnMapper<R>
- Type Parameters:
R- The type of object thisColumnMapperyields from aResultSet
- All Known Subinterfaces:
BasicColumnMapper<R>,NullableColumnMapper<R>
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
A
ColumnMapper differ from a RowMapper in that it is also given a column label/name
together with the ResultSet, which can be used to process specific column(s).
Typically, a ColumnMapper defines how a extract the value from a certain type of columns,
say INT, VARCHAR, or TIMESTAMP columns. Mappers for these value types and other common basic
mappers can be found in the Mappers class. A ColumnMapper can be specialized to handle one specific column
with forColumn(Attribute), which turns it into a RowMapper.- See Also:
-
Method Summary
-
Method Details
-
map
Extract a value from aResultSetbased on the givenname. Usually the name is the column name, or column label if an SQLASclause was used in the query. The givenResultSetis expected to be positioned at the "current" row, i.e. theColumnMapperis not expected to be required to do any cursor placement before doing any value extraction.- Parameters:
name- the name of the value to extract, usually the column name, or column label if an SQLASclause was used in the query.resultSet- theResultSetto extract from.- Returns:
- The reulting extracted value.
- Throws:
SQLException- if any error happens when processing theResultSet. May be if the name/label is not valid, if a database access error occurs, or this method is called on a closed result set.
-
forColumn
Associate the column mapper with anAttribute. This will create a row mapper for the column named by the givenattribute.- Returns:
- a new
AttributeMapper, which is a row mapper.
-