View Javadoc
1 2 package net.sf.voruta; 3 import java.util.*; 4 import java.lang.reflect.*; 5 /*** transform column to list 6 * @author baliuka 7 */ 8 public class ColumnHandler implements ResultSetHandler { 9 10 /*** Creates a new instance of ColumunHandler */ 11 public ColumnHandler() { 12 } 13 14 public Object handle(DbResultSet rs,Class type, Object[] params) 15 throws Exception { 16 17 18 if(type.isArray()){ 19 20 List list = new ArrayList(); 21 while(rs.next()){ 22 list.add(rs.get(0)); 23 } 24 25 Object array = Array.newInstance(type.getComponentType(),list.size()); 26 int index = 0; 27 for(Iterator i = list.iterator(); i.hasNext();){ 28 Array.set(array,index++,i.next()); 29 } 30 31 return array; 32 33 }else{ 34 35 List list = Modifier.isAbstract(type.getModifiers()) ? new Vector() : (List)type.newInstance(); 36 while(rs.next()){ 37 list.add(rs.get(0)); 38 } 39 return list; 40 } 41 42 } 43 44 }

This page was automatically generated by Maven