K
- the type of keys maintained by the returned mapV
- the type of mapped valuespublic abstract class AbstractKeyedHandler<K,V> extends Object implements ResultSetHandler<Map<K,V>>
ResultSetHandler
implementation that returns a Map.
ResultSet
rows are converted into objects (Vs) which are then stored
in a Map under the given keys (Ks).
ResultSetHandler
Constructor and Description |
---|
AbstractKeyedHandler() |
Modifier and Type | Method and Description |
---|---|
protected abstract K |
createKey(ResultSet resultSet)
This factory method is called by
handle() to retrieve the
key value from the current ResultSet row. |
protected Map<K,V> |
createMap()
This factory method is called by
handle() to create the Map
to store records in. |
protected abstract V |
createRow(ResultSet resultSet)
This factory method is called by
handle() to store the
current ResultSet row in some object. |
Map<K,V> |
handle(ResultSet resultSet)
Convert each row's columns into a Map and store then
in a
Map under ResultSet.getObject(key) key. |
public AbstractKeyedHandler()
protected abstract K createKey(ResultSet resultSet) throws SQLException
handle()
to retrieve the
key value from the current ResultSet
row.resultSet
- ResultSet to create a key fromSQLException
- if a database access error occursprotected Map<K,V> createMap()
handle()
to create the Map
to store records in. This implementation returns a HashMap
instance.protected abstract V createRow(ResultSet resultSet) throws SQLException
handle()
to store the
current ResultSet
row in some object.resultSet
- ResultSet to create a row fromSQLException
- if a database access error occurspublic Map<K,V> handle(ResultSet resultSet) throws SQLException
Map
under ResultSet.getObject(key)
key.handle
in interface ResultSetHandler<Map<K,V>>
resultSet
- ResultSet
to process.Map
, never null
.SQLException
- if a database access error occursResultSetHandler.handle(java.sql.ResultSet)
Copyright © 2002–2023 The Apache Software Foundation. All rights reserved.