1 16 package com.ibatis.sqlmap.engine.type; 17 18 import com.ibatis.sqlmap.client.extensions.ParameterSetter; 19 import com.ibatis.sqlmap.client.extensions.ResultGetter; 20 import com.ibatis.sqlmap.client.extensions.TypeHandlerCallback; 21 22 import java.sql.CallableStatement ; 23 import java.sql.PreparedStatement ; 24 import java.sql.ResultSet ; 25 import java.sql.SQLException ; 26 27 30 public class CustomTypeHandler extends BaseTypeHandler implements TypeHandler { 31 32 private TypeHandlerCallback callback; 33 34 39 public CustomTypeHandler(TypeHandlerCallback callback) { 40 this.callback = callback; 41 } 42 43 public void setParameter(PreparedStatement ps, int i, Object parameter, String jdbcType) 44 throws SQLException { 45 ParameterSetter setter = new ParameterSetterImpl(ps, i); 46 callback.setParameter(setter, parameter); 47 } 48 49 public Object getResult(ResultSet rs, String columnName) 50 throws SQLException { 51 ResultGetter getter = new ResultGetterImpl(rs, columnName); 52 return callback.getResult(getter); 53 } 54 55 public Object getResult(ResultSet rs, int columnIndex) 56 throws SQLException { 57 ResultGetter getter = new ResultGetterImpl(rs, columnIndex); 58 return callback.getResult(getter); 59 } 60 61 public Object getResult(CallableStatement cs, int columnIndex) 62 throws SQLException { 63 ResultGetter getter = new ResultGetterImpl(new CallableStatementResultSet(cs), columnIndex); 64 return callback.getResult(getter); 65 } 66 67 public Object valueOf(String s) { 68 return callback.valueOf(s); 69 } 70 71 } 72 | Popular Tags |