KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > ibatis > sqlmap > engine > mapping > result > BasicResultMapping


1 /*
2  * Copyright 2004 Clinton Begin
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package com.ibatis.sqlmap.engine.mapping.result;
17
18 import com.ibatis.sqlmap.engine.type.JdbcTypeRegistry;
19 import com.ibatis.sqlmap.engine.type.TypeHandler;
20
21 /**
22  * Basic implementation of ResultMapping
23  */

24 public class BasicResultMapping implements ResultMapping {
25
26   private String JavaDoc propertyName;
27   private String JavaDoc columnName;
28   private int columnIndex;
29   private TypeHandler typeHandler;
30   private int jdbcType;
31   private String JavaDoc jdbcTypeName;
32   private String JavaDoc nullValue;
33   private String JavaDoc statementName;
34   private Class JavaDoc javaType;
35
36   private String JavaDoc nestedResultMapName;
37
38   private String JavaDoc errorString;
39
40   public String JavaDoc getPropertyName() {
41     return propertyName;
42   }
43
44   /**
45    * Setter for the object property name (used by the automap, and the builder)
46    *
47    * @param propertyName - the property name
48    */

49   public void setPropertyName(String JavaDoc propertyName) {
50     this.errorString = "Check the result mapping for the '" + propertyName + "' property.";
51     this.propertyName = propertyName;
52   }
53
54   /**
55    * Getter for the error message when something goes wrong mapping this property
56    *
57    * @return - the error message
58    */

59   public String JavaDoc getErrorString() {
60     return errorString;
61   }
62
63   /**
64    * Getter for the column name that we are mapping
65    *
66    * @return - the column name
67    */

68   public String JavaDoc getColumnName() {
69     return columnName;
70   }
71
72   /**
73    * Setter for the column name we are mapping (used by the automap or builder)
74    *
75    * @param columnName - the column name
76    */

77   public void setColumnName(String JavaDoc columnName) {
78     this.columnName = columnName;
79   }
80
81   /**
82    * Getter for the column index that we are mapping
83    *
84    * @return - the column index
85    */

86   public int getColumnIndex() {
87     return columnIndex;
88   }
89
90   /**
91    * Setter for the column index we are mapping (used by the automap or builder)
92    *
93    * @param columnIndex - the column index
94    */

95   public void setColumnIndex(int columnIndex) {
96     this.columnIndex = columnIndex;
97   }
98
99   /**
100    * Getter for the type handler for the column
101    *
102    * @return - the type handler
103    */

104   public TypeHandler getTypeHandler() {
105     return typeHandler;
106   }
107
108   /**
109    * Setter for the type handler for the column
110    * @param typeHandler - the type handler
111    */

112   public void setTypeHandler(TypeHandler typeHandler) {
113     this.typeHandler = typeHandler;
114   }
115
116   /**
117    * Setter for the Java type of the column
118    *
119    * @return - the Java type
120    */

121   public Class JavaDoc getJavaType() {
122     return javaType;
123   }
124
125   /**
126    * Setter for the Java type of the column
127    *
128    * @param javaType - the Java type
129    */

130   public void setJavaType(Class JavaDoc javaType) {
131     this.javaType = javaType;
132   }
133
134   /**
135    * Getter for the JDBC type of the column
136    *
137    * @return - the JDBC type
138    */

139   public int getJdbcType() {
140     return jdbcType;
141   }
142
143   /**
144    * Getter for the JDBC type name of the column
145    *
146    * @return - the JDBC type name
147    */

148   public String JavaDoc getJdbcTypeName() {
149     return jdbcTypeName;
150   }
151
152   /**
153    * Setter for the JDBC type name of the column
154    *
155    * @param jdbcTypeName - the JDBC type name
156    */

157   public void setJdbcTypeName(String JavaDoc jdbcTypeName) {
158     this.jdbcTypeName = jdbcTypeName;
159     this.jdbcType = JdbcTypeRegistry.getType(jdbcTypeName);
160   }
161
162   /**
163    * Getter for what to return if the column is null
164    *
165    * @return - the null substitution
166    */

167   public String JavaDoc getNullValue() {
168     return nullValue;
169   }
170
171   /**
172    * Setter for what to return if the column is null
173    *
174    * @param nullValue - the null substitution
175    */

176   public void setNullValue(String JavaDoc nullValue) {
177     this.nullValue = nullValue;
178   }
179
180   /**
181    * Getter for the name of the statement
182    *
183    * @return - the name
184    */

185   public String JavaDoc getStatementName() {
186     return statementName;
187   }
188
189   /**
190    * Setter for the name of the statement
191    *
192    * @param statementName - the name
193    */

194   public void setStatementName(String JavaDoc statementName) {
195     this.statementName = statementName;
196   }
197
198   public String JavaDoc getNestedResultMapName() {
199     return nestedResultMapName;
200   }
201
202   public void setNestedResultMapName(String JavaDoc nestedResultMapName) {
203     this.nestedResultMapName = nestedResultMapName;
204   }
205
206 }
207
Popular Tags