org.skife.jdbi.v2.util
Class IntegerMapper

java.lang.Object
  extended by org.skife.jdbi.v2.util.IntegerMapper
All Implemented Interfaces:
ResultSetMapper<Integer>

public class IntegerMapper
extends Object

Convenience ResultSetMapper for extracting a single value result from a query.


Field Summary
static IntegerMapper FIRST
          An instance which extracts value from the first field
 
Constructor Summary
IntegerMapper()
          Create a new instance which extracts the value from the first column
IntegerMapper(int index)
          Create a new instance which extracts the value positionally in the result set
IntegerMapper(String name)
          Create a new instance which extracts the value by name or alias from the result set
 
Method Summary
protected  Integer extractByIndex(ResultSet r, int index)
           
protected  Integer extractByName(ResultSet r, String name)
           
 T map(int index, ResultSet r, StatementContext ctx)
          Map the row the result set is at when passed in.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FIRST

public static final IntegerMapper FIRST
An instance which extracts value from the first field

Constructor Detail

IntegerMapper

public IntegerMapper()
Create a new instance which extracts the value from the first column


IntegerMapper

public IntegerMapper(int index)
Create a new instance which extracts the value positionally in the result set

Parameters:
index - 1 based column index into the result set

IntegerMapper

public IntegerMapper(String name)
Create a new instance which extracts the value by name or alias from the result set

Parameters:
name - The name or alias for the field
Method Detail

extractByIndex

protected Integer extractByIndex(ResultSet r,
                                 int index)
                          throws SQLException
Throws:
SQLException

extractByName

protected Integer extractByName(ResultSet r,
                                String name)
                         throws SQLException
Throws:
SQLException

map

public T map(int index,
             ResultSet r,
             StatementContext ctx)
      throws SQLException
Description copied from interface: ResultSetMapper
Map the row the result set is at when passed in. This method should not cause the result set to advance, allow jDBI to do that, please.

Specified by:
map in interface ResultSetMapper<T>
Parameters:
index - which row of the result set we are at, starts at 0
r - the result set being iterated
Returns:
the value to return for this row
Throws:
SQLException - if anythign goes wrong go ahead and let this percolate, jDBI will handle it


Copyright © 2011. All Rights Reserved.