• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mybatis / ibatis-2 / 730

28 Dec 2025 10:16PM UTC coverage: 65.615% (+0.5%) from 65.146%
730

push

github

web-flow
Update README.md

1602 of 2802 branches covered (57.17%)

5053 of 7701 relevant lines covered (65.61%)

0.66 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

83.02
/src/main/java/com/ibatis/sqlmap/engine/mapping/parameter/ParameterMapping.java
1
/*
2
 * Copyright 2004-2025 the original author or authors.
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
 *    https://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.parameter;
17

18
import com.ibatis.common.resources.Resources;
19
import com.ibatis.sqlmap.client.SqlMapException;
20
import com.ibatis.sqlmap.engine.type.JdbcTypeRegistry;
21
import com.ibatis.sqlmap.engine.type.TypeHandler;
22

23
/**
24
 * The Class ParameterMapping.
25
 */
26
public class ParameterMapping {
27

28
  /** The Constant MODE_INOUT. */
29
  private static final String MODE_INOUT = "INOUT";
30

31
  /** The Constant MODE_OUT. */
32
  private static final String MODE_OUT = "OUT";
33

34
  /** The Constant MODE_IN. */
35
  private static final String MODE_IN = "IN";
36

37
  /** The property name. */
38
  private String propertyName;
39

40
  /** The type handler. */
41
  private TypeHandler typeHandler;
42

43
  /** The type name. */
44
  private String typeName; // this is used for REF types or user-defined types
45

46
  /** The jdbc type. */
47
  private int jdbcType;
48

49
  /** The jdbc type name. */
50
  private String jdbcTypeName;
51

52
  /** The null value. */
53
  private String nullValue;
54

55
  /** The mode. */
56
  private String mode;
57

58
  /** The input allowed. */
59
  private boolean inputAllowed;
60

61
  /** The output allowed. */
62
  private boolean outputAllowed;
63

64
  /** The java type. */
65
  private Class javaType;
66

67
  /** The result map name. */
68
  private String resultMapName;
69

70
  /** The numeric scale. */
71
  private Integer numericScale;
72

73
  /** The error string. */
74
  private String errorString;
75

76
  /**
77
   * Instantiates a new parameter mapping.
78
   */
79
  public ParameterMapping() {
1✔
80
    mode = "IN";
1✔
81
    inputAllowed = true;
1✔
82
    outputAllowed = false;
1✔
83
    // Default JDBC type if UNKNOWN_TYPE
84
    jdbcType = JdbcTypeRegistry.UNKNOWN_TYPE;
1✔
85
  }
1✔
86

87
  /**
88
   * Gets the null value.
89
   *
90
   * @return the null value
91
   */
92
  public String getNullValue() {
93
    return nullValue;
1✔
94
  }
95

96
  /**
97
   * Sets the null value.
98
   *
99
   * @param nullValue
100
   *          the new null value
101
   */
102
  public void setNullValue(String nullValue) {
103
    this.nullValue = nullValue;
1✔
104
  }
1✔
105

106
  /**
107
   * Gets the property name.
108
   *
109
   * @return the property name
110
   */
111
  public String getPropertyName() {
112
    return propertyName;
1✔
113
  }
114

115
  /**
116
   * Sets the property name.
117
   *
118
   * @param propertyName
119
   *          the new property name
120
   */
121
  public void setPropertyName(String propertyName) {
122
    this.errorString = "Check the parameter mapping for the '" + propertyName + "' property.";
1✔
123
    this.propertyName = propertyName;
1✔
124
  }
1✔
125

126
  /**
127
   * Gets the error string.
128
   *
129
   * @return the error string
130
   */
131
  public String getErrorString() {
132
    return errorString;
1✔
133
  }
134

135
  /**
136
   * Gets the type handler.
137
   *
138
   * @return the type handler
139
   */
140
  public TypeHandler getTypeHandler() {
141
    return typeHandler;
1✔
142
  }
143

144
  /**
145
   * Sets the type handler.
146
   *
147
   * @param typeHandler
148
   *          the new type handler
149
   */
150
  public void setTypeHandler(TypeHandler typeHandler) {
151
    this.typeHandler = typeHandler;
1✔
152
  }
1✔
153

154
  /**
155
   * Gets the java type.
156
   *
157
   * @return the java type
158
   */
159
  public Class getJavaType() {
160
    return javaType;
×
161
  }
162

163
  /**
164
   * Sets the java type.
165
   *
166
   * @param javaType
167
   *          the new java type
168
   */
169
  public void setJavaType(Class javaType) {
170
    this.javaType = javaType;
1✔
171
  }
1✔
172

173
  /**
174
   * Gets the java type name.
175
   *
176
   * @return the java type name
177
   */
178
  public String getJavaTypeName() {
179
    if (javaType == null) {
1✔
180
      return null;
1✔
181
    }
182
    return javaType.getName();
1✔
183
  }
184

185
  /**
186
   * Sets the java type name.
187
   *
188
   * @param javaTypeName
189
   *          the new java type name
190
   */
191
  public void setJavaTypeName(String javaTypeName) {
192
    try {
193
      if (javaTypeName == null) {
1!
194
        this.javaType = null;
×
195
      } else {
196
        this.javaType = Resources.classForName(javaTypeName);
1✔
197
      }
198
    } catch (ClassNotFoundException e) {
×
199
      throw new SqlMapException("Error setting javaType property of ParameterMap.  Cause: " + e, e);
×
200
    }
1✔
201
  }
1✔
202

203
  /**
204
   * Gets the jdbc type.
205
   *
206
   * @return the jdbc type
207
   */
208
  public int getJdbcType() {
209
    return jdbcType;
1✔
210
  }
211

212
  /**
213
   * Gets the jdbc type name.
214
   *
215
   * @return the jdbc type name
216
   */
217
  public String getJdbcTypeName() {
218
    return jdbcTypeName;
1✔
219
  }
220

221
  /**
222
   * Sets the jdbc type name.
223
   *
224
   * @param jdbcTypeName
225
   *          the new jdbc type name
226
   */
227
  public void setJdbcTypeName(String jdbcTypeName) {
228
    this.jdbcTypeName = jdbcTypeName;
1✔
229
    this.jdbcType = JdbcTypeRegistry.getType(jdbcTypeName);
1✔
230
  }
1✔
231

232
  /**
233
   * Gets the mode.
234
   *
235
   * @return the mode
236
   */
237
  public String getMode() {
238
    return mode;
×
239
  }
240

241
  /**
242
   * Sets the mode.
243
   *
244
   * @param mode
245
   *          the new mode
246
   */
247
  public void setMode(String mode) {
248
    this.mode = mode;
1✔
249
    inputAllowed = MODE_IN.equals(mode) || MODE_INOUT.equals(mode);
1!
250
    outputAllowed = MODE_OUT.equals(mode) || MODE_INOUT.equals(mode);
1!
251
  }
1✔
252

253
  /**
254
   * Checks if is input allowed.
255
   *
256
   * @return true, if is input allowed
257
   */
258
  public boolean isInputAllowed() {
259
    return inputAllowed;
1✔
260
  }
261

262
  /**
263
   * Checks if is output allowed.
264
   *
265
   * @return true, if is output allowed
266
   */
267
  public boolean isOutputAllowed() {
268
    return outputAllowed;
1✔
269
  }
270

271
  /**
272
   * user-defined or REF types.
273
   *
274
   * @return typeName
275
   */
276
  public String getTypeName() {
277
    return typeName;
×
278
  }
279

280
  /**
281
   * for user-defined or REF types.
282
   *
283
   * @param typeName
284
   *          the new type name
285
   */
286
  public void setTypeName(String typeName) {
287
    this.typeName = typeName;
1✔
288
  }
1✔
289

290
  /**
291
   * Gets the result map name.
292
   *
293
   * @return the result map name
294
   */
295
  public String getResultMapName() {
296
    return resultMapName;
×
297
  }
298

299
  /**
300
   * Sets the result map name.
301
   *
302
   * @param resultMapName
303
   *          the new result map name
304
   */
305
  public void setResultMapName(String resultMapName) {
306
    this.resultMapName = resultMapName;
1✔
307
  }
1✔
308

309
  /**
310
   * Gets the numeric scale.
311
   *
312
   * @return the numeric scale
313
   */
314
  public Integer getNumericScale() {
315
    return numericScale;
×
316
  }
317

318
  /**
319
   * Sets the numeric scale.
320
   *
321
   * @param numericScale
322
   *          the new numeric scale
323
   */
324
  public void setNumericScale(Integer numericScale) {
325
    if (numericScale != null && numericScale.intValue() < 0) {
1!
326
      throw new RuntimeException(
×
327
          "Error setting numericScale on parameter mapping.  Cause: scale must be greater than or equal to zero");
328
    }
329
    this.numericScale = numericScale;
1✔
330
  }
1✔
331

332
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc