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.dynclass;
22
23 import java.sql.ResultSet;
24 import java.sql.SQLException;
25 import java.util.ArrayList;
26 import java.util.List;
27 import java.util.Map;
28
29 import net.mlw.vlh.ValueListInfo;
30 import net.mlw.vlh.adapter.jdbc.AbstractDynaJdbcAdapter;
31 import net.mlw.vlh.adapter.jdbc.util.ResultSetMapGenerator;
32
33 import org.apache.commons.logging.Log;
34 import org.apache.commons.logging.LogFactory;
35
36 import dynclass.BeanCreator;
37
38 /***
39 * @see net.mlw.vlh.adapter.jdbc.AbstractDynaJdbcAdapter
40 * @see net.mlw.vlh.adapter.jdbc.AbstractJdbcAdapter
41 *
42 * @author Matthew L. Wilson, Andrej Zachar
43 * @version $Revision: 1.8 $ $Date: 2005/08/19 16:06:29 $
44 */
45 public class DefaultDynclassAdapter extends AbstractDynaJdbcAdapter
46 {
47
48 private static final Log LOGGER = LogFactory.getLog(DefaultDynclassAdapter.class);
49
50 public List processResultSet(String name, ResultSet result, int numberPerPage, ValueListInfo info) throws SQLException
51 {
52 List list = new ArrayList();
53
54 ResultSetMapGenerator bg = new ResultSetMapGenerator(result, isUseName(), isLowerCase());
55 for (int i = 0; result.next() && i < numberPerPage; i++)
56 {
57 try
58 {
59 Map properties = bg.generateMap();
60 list.add(BeanCreator.createBeanFromMap(properties));
61 }
62 catch (Exception e)
63 {
64 LOGGER.error(e);
65 }
66 }
67 return list;
68 }
69 }