Class ColumnListHandler<T>

  • Type Parameters:
    T - The type of the column.
    All Implemented Interfaces:
    ResultSetHandler<java.util.List<T>>

    public class ColumnListHandler<T>
    extends AbstractListHandler<T>
    ResultSetHandler implementation that converts one ResultSet column into a List of Objects. This class is thread safe.
    Since:
    DbUtils 1.1
    See Also:
    ResultSetHandler
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private int columnIndex
      The column number to retrieve.
      private java.lang.String columnName
      The column name to retrieve.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
        ColumnListHandler()
      Creates a new instance of ColumnListHandler.
        ColumnListHandler​(int columnIndex)
      Creates a new instance of ColumnListHandler.
      private ColumnListHandler​(int columnIndex, java.lang.String columnName)
      Private Helper
        ColumnListHandler​(java.lang.String columnName)
      Creates a new instance of ColumnListHandler.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected T handleRow​(java.sql.ResultSet rs)
      Returns one ResultSet column value as Object.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • columnIndex

        private final int columnIndex
        The column number to retrieve.
      • columnName

        private final java.lang.String columnName
        The column name to retrieve. Either columnName or columnIndex will be used but never both.
    • Constructor Detail

      • ColumnListHandler

        public ColumnListHandler()
        Creates a new instance of ColumnListHandler. The first column of each row will be returned from handle().
      • ColumnListHandler

        public ColumnListHandler​(int columnIndex)
        Creates a new instance of ColumnListHandler.
        Parameters:
        columnIndex - The index of the column to retrieve from the ResultSet.
      • ColumnListHandler

        public ColumnListHandler​(java.lang.String columnName)
        Creates a new instance of ColumnListHandler.
        Parameters:
        columnName - The name of the column to retrieve from the ResultSet.
      • ColumnListHandler

        private ColumnListHandler​(int columnIndex,
                                  java.lang.String columnName)
        Private Helper
        Parameters:
        columnIndex - The index of the column to retrieve from the ResultSet.
        columnName - The name of the column to retrieve from the ResultSet.
    • Method Detail

      • handleRow

        protected T handleRow​(java.sql.ResultSet rs)
                       throws java.sql.SQLException
        Returns one ResultSet column value as Object.
        Specified by:
        handleRow in class AbstractListHandler<T>
        Parameters:
        rs - ResultSet to process.
        Returns:
        Object, never null.
        Throws:
        java.sql.SQLException - if a database access error occurs
        java.lang.ClassCastException - if the class datatype does not match the column type
        See Also:
        AbstractListHandler.handle(ResultSet)