Class AbstractKeyedHandler<K,V>
- java.lang.Object
-
- org.apache.commons.dbutils.handlers.AbstractKeyedHandler<K,V>
-
- Type Parameters:
K- the type of keys maintained by the returned mapV- the type of mapped values
- All Implemented Interfaces:
ResultSetHandler<Map<K,V>>
- Direct Known Subclasses:
BeanMapHandler,KeyedHandler
public abstract class AbstractKeyedHandler<K,V> extends Object implements ResultSetHandler<Map<K,V>>
ResultSetHandlerimplementation that returns a Map.ResultSetrows are converted into objects (Vs) which are then stored in a Map under the given keys (Ks).- Since:
- 1.3
- See Also:
ResultSetHandler
-
-
Constructor Summary
Constructors Constructor Description AbstractKeyedHandler()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract KcreateKey(ResultSet resultSet)This factory method is called byhandle()to retrieve the key value from the currentResultSetrow.protected Map<K,V>createMap()This factory method is called byhandle()to create the Map to store records in.protected abstract VcreateRow(ResultSet resultSet)This factory method is called byhandle()to store the currentResultSetrow in some object.Map<K,V>handle(ResultSet resultSet)Convert each row's columns into a Map and store then in aMapunderResultSet.getObject(key)key.
-
-
-
Constructor Detail
-
AbstractKeyedHandler
public AbstractKeyedHandler()
-
-
Method Detail
-
createKey
protected abstract K createKey(ResultSet resultSet) throws SQLException
This factory method is called byhandle()to retrieve the key value from the currentResultSetrow.- Parameters:
resultSet- ResultSet to create a key from- Returns:
- K from the configured key column name/index
- Throws:
SQLException- if a database access error occurs
-
createMap
protected Map<K,V> createMap()
This factory method is called byhandle()to create the Map to store records in. This implementation returns aHashMapinstance.- Returns:
- Map to store records in
-
createRow
protected abstract V createRow(ResultSet resultSet) throws SQLException
This factory method is called byhandle()to store the currentResultSetrow in some object.- Parameters:
resultSet- ResultSet to create a row from- Returns:
- V object created from the current row
- Throws:
SQLException- if a database access error occurs
-
handle
public Map<K,V> handle(ResultSet resultSet) throws SQLException
Convert each row's columns into a Map and store then in aMapunderResultSet.getObject(key)key.- Specified by:
handlein interfaceResultSetHandler<K>- Parameters:
resultSet-ResultSetto process.- Returns:
- A
Map, nevernull. - Throws:
SQLException- if a database access error occurs- See Also:
ResultSetHandler.handle(java.sql.ResultSet)
-
-