1 16 package com.ibatis.sqlmap.engine.mapping.parameter; 17 18 import com.ibatis.sqlmap.client.SqlMapException; 19 import com.ibatis.sqlmap.engine.type.JdbcTypeRegistry; 20 import com.ibatis.sqlmap.engine.type.TypeHandler; 21 22 public class BasicParameterMapping implements ParameterMapping { 23 24 private static final String MODE_INOUT = "INOUT"; 25 private static final String MODE_OUT = "OUT"; 26 private static final String MODE_IN = "IN"; 27 28 private String propertyName; 29 private TypeHandler typeHandler; 30 private String typeName; private int jdbcType; 32 private String jdbcTypeName; 33 private String nullValue; 34 private String mode; 35 private boolean inputAllowed; 36 private boolean outputAllowed; 37 private Class javaType; 38 39 private String errorString; 40 41 public BasicParameterMapping() { 42 mode = "IN"; 43 inputAllowed = true; 44 outputAllowed = false; 45 } 46 47 public String getNullValue() { 48 return nullValue; 49 } 50 51 public void setNullValue(String nullValue) { 52 this.nullValue = nullValue; 53 } 54 55 public String getPropertyName() { 56 return propertyName; 57 } 58 59 public void setPropertyName(String propertyName) { 60 this.errorString = "Check the parameter mapping for the '" + propertyName + "' property."; 61 this.propertyName = propertyName; 62 } 63 64 public String getErrorString() { 65 return errorString; 66 } 67 68 public TypeHandler getTypeHandler() { 69 return typeHandler; 70 } 71 72 public void setTypeHandler(TypeHandler typeHandler) { 73 this.typeHandler = typeHandler; 74 } 75 76 public Class getJavaType() { 77 return javaType; 78 } 79 80 public void setJavaType(Class javaType) { 81 this.javaType = javaType; 82 } 83 84 public String getJavaTypeName() { 85 if (javaType == null) { 86 return null; 87 } else { 88 return javaType.getName(); 89 } 90 } 91 92 public void setJavaTypeName(String javaTypeName) { 93 try { 94 if (javaTypeName == null) { 95 this.javaType = null; 96 } else { 97 this.javaType = Class.forName(javaTypeName); 98 } 99 } catch (ClassNotFoundException e) { 100 throw new SqlMapException("Error setting javaType property of ParameterMap. Cause: " + e, e); 101 } 102 } 103 104 public int getJdbcType() { 105 return jdbcType; 106 } 107 108 public String getJdbcTypeName() { 109 return jdbcTypeName; 110 } 111 112 public void setJdbcTypeName(String jdbcTypeName) { 113 this.jdbcTypeName = jdbcTypeName; 114 this.jdbcType = JdbcTypeRegistry.getType(jdbcTypeName); 115 } 116 117 public String getMode() { 118 return mode; 119 } 120 121 public void setMode(String mode) { 122 this.mode = mode; 123 inputAllowed = MODE_IN.equals(mode) || MODE_INOUT.equals(mode); 124 outputAllowed = MODE_OUT.equals(mode) || MODE_INOUT.equals(mode); 125 } 126 127 public boolean isInputAllowed() { 128 return inputAllowed; 129 } 130 131 public boolean isOutputAllowed() { 132 return outputAllowed; 133 } 134 135 139 public String getTypeName() { 140 return typeName; 141 } 142 143 147 public void setTypeName(String typeName) { 148 this.typeName = typeName; 149 } 150 151 } 152 | Popular Tags |