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

mybatis / ibatis-2 / 678

27 Dec 2025 01:13AM UTC coverage: 65.584% (+0.05%) from 65.532%
678

push

github

hazendaz
Merge remote-tracking branch 'upstream/master' into support-javax

1606 of 2810 branches covered (57.15%)

167 of 305 new or added lines in 90 files covered. (54.75%)

6 existing lines in 4 files now uncovered.

5067 of 7726 relevant lines covered (65.58%)

0.66 hits per line

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

41.18
/src/main/java/com/ibatis/common/beans/BaseProbe.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.common.beans;
17

18
import java.util.List;
19

20
/**
21
 * Abstract class used to help development of Probe implementations.
22
 */
23
public abstract class BaseProbe implements Probe {
1✔
24

25
  /**
26
   * Sets the property.
27
   *
28
   * @param object
29
   *          the object
30
   * @param property
31
   *          the property
32
   * @param value
33
   *          the value
34
   */
35
  protected abstract void setProperty(Object object, String property, Object value);
36

37
  /**
38
   * Gets the property.
39
   *
40
   * @param object
41
   *          the object
42
   * @param property
43
   *          the property
44
   *
45
   * @return the property
46
   */
47
  protected abstract Object getProperty(Object object, String property);
48

49
  /**
50
   * Returns an array of the readable properties exposed by an object.
51
   *
52
   * @param object
53
   *          - the object
54
   *
55
   * @return The array of property names
56
   */
57
  public abstract String[] getReadablePropertyNames(Object object);
58

59
  /**
60
   * Returns an array of the writeable properties exposed by an object.
61
   *
62
   * @param object
63
   *          - the object
64
   *
65
   * @return The array of property names
66
   */
67
  public abstract String[] getWriteablePropertyNames(Object object);
68

69
  /**
70
   * Gets the indexed property.
71
   *
72
   * @param object
73
   *          the object
74
   * @param indexedName
75
   *          the indexed name
76
   *
77
   * @return the indexed property
78
   */
79
  protected Object getIndexedProperty(Object object, String indexedName) {
80

81
    Object value = null;
1✔
82

83
    try {
84
      String name = indexedName.substring(0, indexedName.indexOf('['));
1✔
85
      int i = Integer.parseInt(indexedName.substring(indexedName.indexOf('[') + 1, indexedName.indexOf(']')));
1✔
86
      Object list = null;
1✔
87
      if ("".equals(name)) {
1✔
88
        list = object;
1✔
89
      } else {
90
        list = getProperty(object, name);
1✔
91
      }
92

93
      if (list instanceof List) {
1✔
94
        value = ((List) list).get(i);
1✔
95
      } else if (list instanceof Object[]) {
1✔
96
        value = ((Object[]) list)[i];
1✔
97
      } else if (list instanceof char[]) {
1!
98
        value = Character.valueOf(((char[]) list)[i]);
×
99
      } else if (list instanceof boolean[]) {
1!
NEW
100
        value = Boolean.valueOf(((boolean[]) list)[i]);
×
101
      } else if (list instanceof byte[]) {
1!
102
        value = Byte.valueOf(((byte[]) list)[i]);
×
103
      } else if (list instanceof double[]) {
1!
104
        value = Double.valueOf(((double[]) list)[i]);
×
105
      } else if (list instanceof float[]) {
1✔
106
        value = Float.valueOf(((float[]) list)[i]);
1✔
107
      } else if (list instanceof int[]) {
1!
108
        value = Integer.valueOf(((int[]) list)[i]);
1✔
109
      } else if (list instanceof long[]) {
×
110
        value = Long.valueOf(((long[]) list)[i]);
×
111
      } else if (list instanceof short[]) {
×
112
        value = Short.valueOf(((short[]) list)[i]);
×
113
      } else {
114
        throw new ProbeException(
×
115
            "The '" + name + "' property of the " + object.getClass().getName() + " class is not a List or Array.");
×
116
      }
117

118
    } catch (ProbeException e) {
×
119
      throw e;
×
120
    } catch (Exception e) {
×
121
      throw new ProbeException("Error getting ordinal list from JavaBean. Cause " + e, e);
×
122
    }
1✔
123

124
    return value;
1✔
125
  }
126

127
  /**
128
   * Gets the indexed type.
129
   *
130
   * @param object
131
   *          the object
132
   * @param indexedName
133
   *          the indexed name
134
   *
135
   * @return the indexed type
136
   */
137
  protected Class getIndexedType(Object object, String indexedName) {
138

139
    Class value = null;
1✔
140

141
    try {
142
      String name = indexedName.substring(0, indexedName.indexOf('['));
1✔
143
      int i = Integer.parseInt(indexedName.substring(indexedName.indexOf('[') + 1, indexedName.indexOf(']')));
1✔
144
      Object list = null;
1✔
145
      if (!"".equals(name)) {
1✔
146
        list = getProperty(object, name);
1✔
147
      } else {
148
        list = object;
1✔
149
      }
150

151
      if (list instanceof List) {
1✔
152
        value = ((List) list).get(i).getClass();
1✔
153
      } else if (list instanceof Object[]) {
1✔
154
        value = ((Object[]) list)[i].getClass();
1✔
155
      } else if (list instanceof char[]) {
1!
156
        value = Character.class;
×
157
      } else if (list instanceof boolean[]) {
1!
158
        value = Boolean.class;
×
159
      } else if (list instanceof byte[]) {
1!
160
        value = Byte.class;
×
161
      } else if (list instanceof double[]) {
1!
162
        value = Double.class;
×
163
      } else if (list instanceof float[]) {
1!
164
        value = Float.class;
×
165
      } else if (list instanceof int[]) {
1!
166
        value = Integer.class;
1✔
167
      } else if (list instanceof long[]) {
×
168
        value = Long.class;
×
169
      } else if (list instanceof short[]) {
×
170
        value = Short.class;
×
171
      } else {
172
        throw new ProbeException(
×
173
            "The '" + name + "' property of the " + object.getClass().getName() + " class is not a List or Array.");
×
174
      }
175

176
    } catch (ProbeException e) {
×
177
      throw e;
×
178
    } catch (Exception e) {
×
179
      throw new ProbeException("Error getting ordinal list from JavaBean. Cause " + e, e);
×
180
    }
1✔
181

182
    return value;
1✔
183
  }
184

185
  /**
186
   * Sets the indexed property.
187
   *
188
   * @param object
189
   *          the object
190
   * @param indexedName
191
   *          the indexed name
192
   * @param value
193
   *          the value
194
   */
195
  protected void setIndexedProperty(Object object, String indexedName, Object value) {
196

197
    try {
198
      String name = indexedName.substring(0, indexedName.indexOf('['));
×
199
      int i = Integer.parseInt(indexedName.substring(indexedName.indexOf('[') + 1, indexedName.indexOf(']')));
×
200
      Object list = getProperty(object, name);
×
201
      if (list instanceof List) {
×
202
        ((List) list).set(i, value);
×
203
      } else if (list instanceof Object[]) {
×
204
        ((Object[]) list)[i] = value;
×
205
      } else if (list instanceof char[]) {
×
206
        ((char[]) list)[i] = ((Character) value).charValue();
×
207
      } else if (list instanceof boolean[]) {
×
208
        ((boolean[]) list)[i] = ((Boolean) value).booleanValue();
×
209
      } else if (list instanceof byte[]) {
×
210
        ((byte[]) list)[i] = ((Byte) value).byteValue();
×
211
      } else if (list instanceof double[]) {
×
212
        ((double[]) list)[i] = ((Double) value).doubleValue();
×
213
      } else if (list instanceof float[]) {
×
214
        ((float[]) list)[i] = ((Float) value).floatValue();
×
215
      } else if (list instanceof int[]) {
×
216
        ((int[]) list)[i] = ((Integer) value).intValue();
×
217
      } else if (list instanceof long[]) {
×
218
        ((long[]) list)[i] = ((Long) value).longValue();
×
219
      } else if (list instanceof short[]) {
×
220
        ((short[]) list)[i] = ((Short) value).shortValue();
×
221
      } else {
222
        throw new ProbeException(
×
223
            "The '" + name + "' property of the " + object.getClass().getName() + " class is not a List or Array.");
×
224
      }
225
    } catch (ProbeException e) {
×
226
      throw e;
×
227
    } catch (Exception e) {
×
228
      throw new ProbeException("Error getting ordinal value from JavaBean. Cause " + e, e);
×
229
    }
×
230
  }
×
231
}
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

© 2026 Coveralls, Inc