View Javadoc
1 /* 2 * PairHandler.java 3 * 4 * $Id: BeanMapHandler.java,v 1.3 2003/08/15 11:02:37 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 BeanMapHandler implements ResultSetHandler { 16 17 private String propertyName; 18 private Class type; 19 20 /*** Creates a new instance of PairHandler */ 21 public BeanMapHandler(Class type,String propertyName) { 22 this.propertyName = propertyName; 23 this.type = type; 24 } 25 26 /*** Callback method 27 * @param rs Result set returned by SQL query 28 * @param returnType method result type 29 * @param params method parameters 30 * @throws SQLException on error in query processing 31 * @return transformed value, can be null 32 */ 33 public Object handle(DbResultSet rs, Class returnType, Object[] params) throws Exception { 34 35 Map result = Modifier.isAbstract(returnType.getModifiers()) ? 36 new Hashtable() :(Map)returnType.newInstance(); 37 38 39 DbUtils.resultSetToBeanMap(rs,type, result,propertyName); 40 41 return result; 42 } 43 44 }

This page was automatically generated by Maven