public static T getObject()

in src/main/java/org/apache/commons/dbcp2/Jdbc41Bridge.java [166:244]


    public static <T> T getObject(final ResultSet resultSet, final int columnIndex, final Class<T> type)
            throws SQLException {
        try {
            return resultSet.getObject(columnIndex, type);
        } catch (final AbstractMethodError e) {
            if (type == String.class) {
                return (T) resultSet.getString(columnIndex);
            }
            // Numbers
            if (type == Integer.class) {
                return (T) Integer.valueOf(resultSet.getInt(columnIndex));
            }
            if (type == Long.class) {
                return (T) Long.valueOf(resultSet.getLong(columnIndex));
            }
            if (type == Double.class) {
                return (T) Double.valueOf(resultSet.getDouble(columnIndex));
            }
            if (type == Float.class) {
                return (T) Float.valueOf(resultSet.getFloat(columnIndex));
            }
            if (type == Short.class) {
                return (T) Short.valueOf(resultSet.getShort(columnIndex));
            }
            if (type == BigDecimal.class) {
                return (T) resultSet.getBigDecimal(columnIndex);
            }
            if (type == Byte.class) {
                return (T) Byte.valueOf(resultSet.getByte(columnIndex));
            }
            // Dates
            if (type == Date.class) {
                return (T) resultSet.getDate(columnIndex);
            }
            if (type == Time.class) {
                return (T) resultSet.getTime(columnIndex);
            }
            if (type == Timestamp.class) {
                return (T) resultSet.getTimestamp(columnIndex);
            }
            // Streams
            if (type == InputStream.class) {
                return (T) resultSet.getBinaryStream(columnIndex);
            }
            if (type == Reader.class) {
                return (T) resultSet.getCharacterStream(columnIndex);
            }
            // Other
            if (type == Object.class) {
                return (T) resultSet.getObject(columnIndex);
            }
            if (type == Boolean.class) {
                return (T) Boolean.valueOf(resultSet.getBoolean(columnIndex));
            }
            if (type == Array.class) {
                return (T) resultSet.getArray(columnIndex);
            }
            if (type == Blob.class) {
                return (T) resultSet.getBlob(columnIndex);
            }
            if (type == Clob.class) {
                return (T) resultSet.getClob(columnIndex);
            }
            if (type == Ref.class) {
                return (T) resultSet.getRef(columnIndex);
            }
            if (type == RowId.class) {
                return (T) resultSet.getRowId(columnIndex);
            }
            if (type == SQLXML.class) {
                return (T) resultSet.getSQLXML(columnIndex);
            }
            if (type == URL.class) {
                return (T) resultSet.getURL(columnIndex);
            }
            throw new SQLFeatureNotSupportedException(
                    String.format("resultSet=%s, columnIndex=%,d, type=%s", resultSet, columnIndex, type));
        }
    }