View Javadoc

1   /***
2    * Copyright (c) 2003 held jointly by the individual authors.            
3    *                                                                          
4    * This library is free software; you can redistribute it and/or modify it    
5    * under the terms of the GNU Lesser General Public License as published      
6    * by the Free Software Foundation; either version 2.1 of the License, or 
7    * (at your option) any later version.                                            
8    *                                                                            
9    * This library is distributed in the hope that it will be useful, but 
10   * WITHOUT ANY WARRANTY; with out even the implied warranty of 
11   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
12   * GNU Lesser General Public License for more details.                                                  
13   *                                                                           
14   * You should have received a copy of the GNU Lesser General Public License   
15   * along with this library;  if not, write to the Free Software Foundation,   
16   * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA.              
17   *                                                                            
18   * > http://www.gnu.org/copyleft/lesser.html                                  
19   * > http://www.opensource.org/licenses/lgpl-license.php
20   */
21  package net.mlw.vlh.adapter.jdbc.spring;
22  
23  import java.sql.ResultSet;
24  import java.sql.SQLException;
25  import java.util.ArrayList;
26  import java.util.List;
27  
28  import net.mlw.vlh.ValueListInfo;
29  import net.mlw.vlh.adapter.jdbc.AbstractJdbcAdapter;
30  import net.mlw.vlh.adapter.jdbc.spring.util.SpringConnectionCreator;
31  
32  import org.springframework.jdbc.core.RowMapper;
33  
34  /***
35   * net.mlw.vlh.adapter.jdbc.spring.SpringDaoValueListAdapter
36   * 
37   * @author Matthew L. Wilson
38   * @version $Revision: 1.2 $ $Date: 2005/10/17 11:42:36 $
39   */
40  public class SpringDaoValueListAdapter extends AbstractJdbcAdapter
41  {
42     private RowMapper rowMapper;
43  
44     public SpringDaoValueListAdapter()
45     {
46        setConnectionCreator(new SpringConnectionCreator());
47     }
48  
49     /***
50      * @see net.mlw.vlh.adapter.jdbc.AbstractJdbcAdapter#processResultSet(java.lang.String, java.sql.ResultSet, int, net.mlw.vlh.ValueListInfo)
51      */
52     public List processResultSet(String name, ResultSet result, int numberPerPage, ValueListInfo info) throws SQLException
53     {
54        List list = new ArrayList();
55  
56        for (int rowIndex = 0; result.next() && rowIndex < numberPerPage; rowIndex++)
57        {
58           list.add(rowMapper.mapRow(result, rowIndex));
59        }
60  
61        return list;
62     }
63  
64     /***
65      * @return Returns the rowMapper.
66      */
67     public RowMapper getRowMapper()
68     {
69        return rowMapper;
70     }
71  
72     /***
73      * @param rowMapper The rowMapper to set.
74      */
75     public void setRowMapper(RowMapper rowMapper)
76     {
77        this.rowMapper = rowMapper;
78     }
79  }