1 package net.sf.voruta;
2
3 import java.util.*;
4 import java.sql.*;
5 import java.lang.reflect.*;
6 /***
7 * transforms row to map
8 * @author baliuka
9 */
10 public class MapHandler implements ResultSetHandler {
11
12 /*** Creates a new instance of MapHandler */
13 public MapHandler() {
14 }
15
16 public Object handle(DbResultSet rs,Class type, Object[] params) throws Exception{
17
18 if (rs.next()) {
19 Map result = Modifier.isAbstract(type.getModifiers()) ?
20 new Hashtable() :(Map)type.newInstance();
21
22 DbUtils.resultSetToMap(rs,result);
23
24 if(rs.next()){
25 throw new DbException("too many results");
26 }
27 return result;
28 }
29 throw new DbException("no results");
30 }
31
32
33 }
This page was automatically generated by Maven