View Javadoc
1 /* 2 * PairHandler.java 3 * 4 * $Id: PairHandler.java,v 1.2 2004/02/10 08:38:47 baliuka Exp $ 5 */ 6 7 package net.sf.voruta; 8 9 import java.util.*; 10 import java.lang.reflect.*; 11 /*** 12 * 13 * @author baliuka 14 */ 15 public class PairHandler implements ResultSetHandler { 16 17 /*** Creates a new instance of PairHandler */ 18 public PairHandler() { 19 } 20 21 /*** Callback method 22 * @param rs Result set returned by SQL query 23 * @param returnType method result type 24 * @param params method parameters 25 * @throws SQLException on error in query processing 26 * @return transformed value, can be null 27 */ 28 public Object handle(DbResultSet rs, Class type, Object[] params) throws Exception { 29 30 Map result = Modifier.isAbstract(type.getModifiers()) ? 31 new Hashtable() :(Map)type.newInstance(); 32 33 while(rs.next()){ 34 result.put(rs.get(0),rs.get(1)); 35 } 36 return result; 37 } 38 39 }

This page was automatically generated by Maven