1 60 61 package org.apache.commons.dbutils.handlers; 62 63 import java.sql.ResultSet ; 64 import java.sql.SQLException ; 65 66 import org.apache.commons.dbutils.BasicRowProcessor; 67 import org.apache.commons.dbutils.ResultSetHandler; 68 import org.apache.commons.dbutils.RowProcessor; 69 70 79 public class BeanHandler implements ResultSetHandler { 80 81 84 private Class type = null; 85 86 90 private RowProcessor convert = BasicRowProcessor.instance(); 91 92 98 public BeanHandler(Class type) { 99 this.type = type; 100 } 101 102 110 public BeanHandler(Class type, RowProcessor convert) { 111 this.type = type; 112 this.convert = convert; 113 } 114 115 125 public Object handle(ResultSet rs) throws SQLException { 126 return rs.next() ? this.convert.toBean(rs, this.type) : null; 127 } 128 129 } 130 | Popular Tags |