-
- Type Parameters:
T
- the type of object resulting from the packing
public interface ResultPacker<T>
A ResultPacker packs the contents of a ResultSet into a List.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description T
fetch(ResultSet resultSet)
Fetches a single instance from the given result set, assumesResultSet.next()
has been calleddefault List<T>
pack(ResultSet resultSet)
Iterates through the given ResultSet, packing its contents into a List usingfetch(ResultSet)
in the order they appear.default List<T>
pack(ResultSet resultSet, int fetchLimit)
Iterates through the given ResultSet, packing its contents into a List usingfetch(ResultSet)
in the order they appear.
-
-
-
Method Detail
-
pack
default List<T> pack(ResultSet resultSet) throws SQLException
Iterates through the given ResultSet, packing its contents into a List usingfetch(ResultSet)
in the order they appear. Items are skipped iffetch(ResultSet)
returns null. This method does not close or modify the ResultSet in any way.- Parameters:
resultSet
- the ResultSet instance containing the query result to process- Returns:
- a List containing the data from the query result
- Throws:
SQLException
- thrown if anything goes wrong during the packingNullPointerException
- in case resultSet is null
-
pack
default List<T> pack(ResultSet resultSet, int fetchLimit) throws SQLException
Iterates through the given ResultSet, packing its contents into a List usingfetch(ResultSet)
in the order they appear. Items are skipped iffetch(ResultSet)
returns null. This method does not close or modify the ResultSet in any way.- Parameters:
resultSet
- the ResultSet instance containing the query result to processfetchLimit
- the maximum number of records to fetch from the result set, a negative value means all should be fetched.- Returns:
- a List containing the data from the query result
- Throws:
SQLException
- thrown if anything goes wrong during the packingNullPointerException
- in case resultSet is null
-
fetch
T fetch(ResultSet resultSet) throws SQLException
Fetches a single instance from the given result set, assumesResultSet.next()
has been called- Parameters:
resultSet
- the result set- Returns:
- the instance fetched from the ResultSet, null if the item should not be fetched for some reason
- Throws:
SQLException
- in case of failure
-
-