}
public <T> T handle(ResultSet resultSet, Class<T> resultType)
throws SQLException {
if (resultType == List.class) {
IsoLog log = context.getInstance(IsoLog.class);
IsoReflectionManager reflectionManager = context
.getInstance(IsoReflectionManager.class);
IsoBeanPropertyManager propertyManager = context
.getInstance(IsoBeanPropertyManager.class);
IsoColumnTypeConverter columnTypeConverter = context
.getInstance(IsoColumnTypeConverter.class);
log.debug("Processing: {0}", klass);
List<Object> list = new ArrayList<Object>();
ResultSetMetaData metaData = resultSet.getMetaData();
int columnCount = metaData.getColumnCount();
String[] columnNames = new String[columnCount];
for (int i = 0; i < columnCount; i++) {
String columnName = metaData.getColumnName(i + 1);
columnNames[i] = columnName;
log.trace("Catch of column: {0}", columnName);
}
while (resultSet.next()) {
Object bean = reflectionManager.newInstance(klass);
for (int i = 0; i < columnCount; i++) {
String columnName = columnNames[i];
IsoSQLResultSetProcessorColumnInfo columnInfo = columnsInfo
.get(columnName);
Object value;
Class<?> type;
switch (columnTypeConverter.getColumnType(columnInfo
.getType())) {
case FLOAT:
value = Float.valueOf(resultSet.getFloat(i + 1));
type = Float.class;
break;
case DOUBLE:
value = Double.valueOf(resultSet.getDouble(i + 1));
type = Double.class;
break;
case STRING:
value = resultSet.getString(i + 1);
type = String.class;
break;
case INTEGER:
value = Integer.valueOf(resultSet.getInt(i + 1));
type = Integer.class;
break;
case LONG:
value = Long.valueOf(resultSet.getLong(i + 1));
type = Long.class;
break;
case DATE:
value = resultSet.getDate(i + 1);
type = Date.class;
break;
default:
continue;
}
propertyManager.setProperty(bean, type,
columnInfo.getName(), value);
}
list.add(bean);
}
log.debug("List size: {0}", Integer.valueOf(list.size()));
@SuppressWarnings("unchecked")
T resultList = (T) list;
return resultList;
} else {
throw new IllegalArgumentException(resultType.getName());