1 16 17 package org.springframework.jdbc.core; 18 19 import java.sql.ResultSet ; 20 import java.sql.SQLException ; 21 import java.util.ArrayList ; 22 import java.util.LinkedList ; 23 import java.util.List ; 24 25 58 public class RowMapperResultReader implements ResultReader { 59 60 61 private final List results; 62 63 64 private final RowMapper rowMapper; 65 66 67 private int rowNum = 0; 68 69 73 public RowMapperResultReader(RowMapper rowMapper) { 74 this(rowMapper, 0); 75 } 76 77 83 public RowMapperResultReader(RowMapper rowMapper, int rowsExpected) { 84 this.results = (rowsExpected > 0) ? (List ) new ArrayList (rowsExpected) : (List ) new LinkedList (); 87 this.rowMapper = rowMapper; 88 } 89 90 public void processRow(ResultSet rs) throws SQLException { 91 this.results.add(this.rowMapper.mapRow(rs, this.rowNum++)); 92 } 93 94 public List getResults() { 95 return this.results; 96 } 97 98 } 99 | Popular Tags |