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 rs)
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 rs)
This factory method is called by
handle() to store the
current ResultSet row in some object. |
Map<K,V> |
handle(ResultSet rs)
Convert each row's columns into a Map and store then
in a
Map under ResultSet.getObject(key) key. |
public Map<K,V> handle(ResultSet rs) throws SQLException
Map under ResultSet.getObject(key) key.handle in interface ResultSetHandler<Map<K,V>>rs - ResultSet to process.Map, never null.SQLException - if a database access error occursResultSetHandler.handle(java.sql.ResultSet)protected Map<K,V> createMap()
handle() to create the Map
to store records in. This implementation returns a HashMap
instance.protected abstract K createKey(ResultSet rs) throws SQLException
handle() to retrieve the
key value from the current ResultSet row.rs - ResultSet to create a key fromSQLException - if a database access error occursprotected abstract V createRow(ResultSet rs) throws SQLException
handle() to store the
current ResultSet row in some object.rs - ResultSet to create a row fromSQLException - if a database access error occursCopyright © 2002–2017 The Apache Software Foundation. All rights reserved.