1 56 package org.objectstyle.cayenne.access.types; 57 58 import java.sql.CallableStatement ; 59 import java.sql.PreparedStatement ; 60 import java.sql.ResultSet ; 61 62 import org.apache.commons.lang.builder.ToStringBuilder; 63 import org.objectstyle.cayenne.map.DbAttribute; 64 import org.objectstyle.cayenne.validation.ValidationResult; 65 66 74 public abstract class AbstractType implements ExtendedType { 75 76 81 public void setJdbcObject( 82 PreparedStatement st, 83 Object val, 84 int pos, 85 int type, 86 int precision) throws Exception { 87 88 if (precision != -1) { 89 st.setObject(pos, val, type, precision); 90 } 91 else { 92 st.setObject(pos, val, type); 93 } 94 } 95 96 public abstract String getClassName(); 97 98 public abstract Object materializeObject(CallableStatement rs, int index, int type) 99 throws Exception ; 100 101 public abstract Object materializeObject(ResultSet rs, int index, int type) 102 throws Exception ; 103 104 108 public boolean validateProperty( 109 Object source, 110 String property, 111 Object value, 112 DbAttribute dbAttribute, 113 ValidationResult validationResult) { 114 return true; 115 } 116 117 public String toString() { 118 return new ToStringBuilder(this).append("className", getClassName()).toString(); 119 } 120 } 121 | Popular Tags |