001: /*
002: * Copyright 2004 Clinton Begin
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016: package com.ibatis.sqlmap.engine.mapping.result;
017:
018: import com.ibatis.sqlmap.engine.type.JdbcTypeRegistry;
019: import com.ibatis.sqlmap.engine.type.TypeHandler;
020:
021: /**
022: * Basic implementation of ResultMapping
023: */
024: public class BasicResultMapping implements ResultMapping {
025:
026: private String propertyName;
027: private String columnName;
028: private int columnIndex;
029: private TypeHandler typeHandler;
030: private int jdbcType;
031: private String jdbcTypeName;
032: private String nullValue;
033: private String statementName;
034: private Class javaType;
035:
036: private String nestedResultMapName;
037:
038: private String errorString;
039:
040: public String getPropertyName() {
041: return propertyName;
042: }
043:
044: /**
045: * Setter for the object property name (used by the automap, and the builder)
046: *
047: * @param propertyName - the property name
048: */
049: public void setPropertyName(String propertyName) {
050: this .errorString = "Check the result mapping for the '"
051: + propertyName + "' property.";
052: this .propertyName = propertyName;
053: }
054:
055: /**
056: * Getter for the error message when something goes wrong mapping this property
057: *
058: * @return - the error message
059: */
060: public String getErrorString() {
061: return errorString;
062: }
063:
064: /**
065: * Getter for the column name that we are mapping
066: *
067: * @return - the column name
068: */
069: public String getColumnName() {
070: return columnName;
071: }
072:
073: /**
074: * Setter for the column name we are mapping (used by the automap or builder)
075: *
076: * @param columnName - the column name
077: */
078: public void setColumnName(String columnName) {
079: this .columnName = columnName;
080: }
081:
082: /**
083: * Getter for the column index that we are mapping
084: *
085: * @return - the column index
086: */
087: public int getColumnIndex() {
088: return columnIndex;
089: }
090:
091: /**
092: * Setter for the column index we are mapping (used by the automap or builder)
093: *
094: * @param columnIndex - the column index
095: */
096: public void setColumnIndex(int columnIndex) {
097: this .columnIndex = columnIndex;
098: }
099:
100: /**
101: * Getter for the type handler for the column
102: *
103: * @return - the type handler
104: */
105: public TypeHandler getTypeHandler() {
106: return typeHandler;
107: }
108:
109: /**
110: * Setter for the type handler for the column
111: * @param typeHandler - the type handler
112: */
113: public void setTypeHandler(TypeHandler typeHandler) {
114: this .typeHandler = typeHandler;
115: }
116:
117: /**
118: * Setter for the Java type of the column
119: *
120: * @return - the Java type
121: */
122: public Class getJavaType() {
123: return javaType;
124: }
125:
126: /**
127: * Setter for the Java type of the column
128: *
129: * @param javaType - the Java type
130: */
131: public void setJavaType(Class javaType) {
132: this .javaType = javaType;
133: }
134:
135: /**
136: * Getter for the JDBC type of the column
137: *
138: * @return - the JDBC type
139: */
140: public int getJdbcType() {
141: return jdbcType;
142: }
143:
144: /**
145: * Getter for the JDBC type name of the column
146: *
147: * @return - the JDBC type name
148: */
149: public String getJdbcTypeName() {
150: return jdbcTypeName;
151: }
152:
153: /**
154: * Setter for the JDBC type name of the column
155: *
156: * @param jdbcTypeName - the JDBC type name
157: */
158: public void setJdbcTypeName(String jdbcTypeName) {
159: this .jdbcTypeName = jdbcTypeName;
160: this .jdbcType = JdbcTypeRegistry.getType(jdbcTypeName);
161: }
162:
163: /**
164: * Getter for what to return if the column is null
165: *
166: * @return - the null substitution
167: */
168: public String getNullValue() {
169: return nullValue;
170: }
171:
172: /**
173: * Setter for what to return if the column is null
174: *
175: * @param nullValue - the null substitution
176: */
177: public void setNullValue(String nullValue) {
178: this .nullValue = nullValue;
179: }
180:
181: /**
182: * Getter for the name of the statement
183: *
184: * @return - the name
185: */
186: public String getStatementName() {
187: return statementName;
188: }
189:
190: /**
191: * Setter for the name of the statement
192: *
193: * @param statementName - the name
194: */
195: public void setStatementName(String statementName) {
196: this .statementName = statementName;
197: }
198:
199: public String getNestedResultMapName() {
200: return nestedResultMapName;
201: }
202:
203: public void setNestedResultMapName(String nestedResultMapName) {
204: this.nestedResultMapName = nestedResultMapName;
205: }
206:
207: }
|