1 16 package com.ibatis.sqlmap.engine.type; 17 18 import java.sql.CallableStatement ; 19 import java.sql.PreparedStatement ; 20 import java.sql.ResultSet ; 21 import java.sql.SQLException ; 22 23 26 public class UnknownTypeHandler extends BaseTypeHandler implements TypeHandler { 27 28 private TypeHandlerFactory factory; 29 30 35 public UnknownTypeHandler(TypeHandlerFactory factory) { 36 this.factory = factory; 37 } 38 39 public void setParameter(PreparedStatement ps, int i, Object parameter, String jdbcType) 40 throws SQLException { 41 TypeHandler handler = factory.getTypeHandler(parameter.getClass(), jdbcType); 42 handler.setParameter(ps, i, parameter, jdbcType); 43 } 44 45 public Object getResult(ResultSet rs, String columnName) 46 throws SQLException { 47 Object object = rs.getObject(columnName); 48 if (rs.wasNull()) { 49 return null; 50 } else { 51 return object; 52 } 53 } 54 55 public Object getResult(ResultSet rs, int columnIndex) 56 throws SQLException { 57 Object object = rs.getObject(columnIndex); 58 if (rs.wasNull()) { 59 return null; 60 } else { 61 return object; 62 } 63 } 64 65 public Object getResult(CallableStatement cs, int columnIndex) 66 throws SQLException { 67 Object object = cs.getObject(columnIndex); 68 if (cs.wasNull()) { 69 return null; 70 } else { 71 return object; 72 } 73 } 74 75 public Object valueOf(String s) { 76 return s; 77 } 78 79 public boolean equals(Object object, String string) { 80 if (object == null || string == null) { 81 return object == string; 82 } else { 83 TypeHandler handler = factory.getTypeHandler(object.getClass()); 84 Object castedObject = handler.valueOf(string); 85 return object.equals(castedObject); 86 } 87 } 88 89 } 90 | Popular Tags |