1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.extension.version.internal; |
21 |
|
|
22 |
|
import java.io.IOException; |
23 |
|
import java.io.ObjectInputStream; |
24 |
|
import java.io.ObjectOutputStream; |
25 |
|
import java.util.ArrayList; |
26 |
|
import java.util.HashMap; |
27 |
|
import java.util.Iterator; |
28 |
|
import java.util.List; |
29 |
|
import java.util.ListIterator; |
30 |
|
import java.util.Locale; |
31 |
|
import java.util.Map; |
32 |
|
|
33 |
|
import org.apache.commons.lang3.builder.HashCodeBuilder; |
34 |
|
import org.slf4j.Logger; |
35 |
|
import org.slf4j.LoggerFactory; |
36 |
|
import org.xwiki.extension.version.Version; |
37 |
|
|
38 |
|
|
39 |
|
@link |
40 |
|
|
41 |
|
|
42 |
|
|
43 |
|
|
44 |
|
|
45 |
|
@link |
46 |
|
|
47 |
|
@version |
48 |
|
@since |
49 |
|
|
|
|
| 86.9% |
Uncovered Elements: 18 (137) |
Complexity: 41 |
Complexity Density: 0.52 |
|
50 |
|
public class DefaultVersion implements Version |
51 |
|
{ |
52 |
|
|
53 |
|
|
54 |
|
|
55 |
|
private static final long serialVersionUID = 1L; |
56 |
|
|
57 |
|
private static final String MAX_INTEGER_STRING = String.valueOf(Integer.MAX_VALUE); |
58 |
|
|
59 |
|
private static final int MAX_INTEGER_LENGTH = MAX_INTEGER_STRING.length(); |
60 |
|
|
61 |
|
private static final Logger LOGGER = LoggerFactory.getLogger(DefaultVersion.class); |
62 |
|
|
63 |
|
|
64 |
|
|
65 |
|
|
66 |
|
private String rawVersion; |
67 |
|
|
68 |
|
|
69 |
|
|
70 |
|
|
71 |
|
private List<Element> elements; |
72 |
|
|
73 |
|
|
74 |
|
@see |
75 |
|
|
76 |
|
private Type type = Type.STABLE; |
77 |
|
|
78 |
|
private int hashCode = -1; |
79 |
|
|
80 |
|
|
81 |
|
|
82 |
|
|
83 |
|
@version |
84 |
|
|
|
|
| 89.8% |
Uncovered Elements: 6 (59) |
Complexity: 17 |
Complexity Density: 0.5 |
|
85 |
|
static final class Tokenizer |
86 |
|
{ |
87 |
|
|
88 |
|
|
89 |
|
|
90 |
|
private final String rawVersion; |
91 |
|
|
92 |
|
|
93 |
|
|
94 |
|
|
95 |
|
private int index; |
96 |
|
|
97 |
|
|
98 |
|
@see |
99 |
|
|
100 |
|
private boolean number; |
101 |
|
|
102 |
|
|
103 |
|
@see |
104 |
|
|
105 |
|
private String token; |
106 |
|
|
107 |
|
|
108 |
|
@param |
109 |
|
|
|
|
| 66.7% |
Uncovered Elements: 1 (3) |
Complexity: 2 |
Complexity Density: 2 |
|
110 |
737025 |
public Tokenizer(String rawVersion)... |
111 |
|
{ |
112 |
737025 |
this.rawVersion = (rawVersion.length() > 0) ? rawVersion : "0"; |
113 |
|
} |
114 |
|
|
115 |
|
|
116 |
|
@return |
117 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
118 |
2045671 |
public String getToken()... |
119 |
|
{ |
120 |
2045671 |
return this.token; |
121 |
|
} |
122 |
|
|
123 |
|
|
124 |
|
@return |
125 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
126 |
2045671 |
public boolean isNumber()... |
127 |
|
{ |
128 |
2045671 |
return this.number; |
129 |
|
} |
130 |
|
|
131 |
|
|
132 |
|
@return |
133 |
|
|
|
|
| 93.8% |
Uncovered Elements: 3 (48) |
Complexity: 12 |
Complexity Density: 0.4 |
|
134 |
2782696 |
public boolean next()... |
135 |
|
{ |
136 |
2782696 |
final int n = this.rawVersion.length(); |
137 |
2782696 |
if (this.index >= n) { |
138 |
737025 |
return false; |
139 |
|
} |
140 |
|
|
141 |
2045671 |
int state = -2; |
142 |
|
|
143 |
2045671 |
int start = this.index; |
144 |
2045671 |
int end = n; |
145 |
|
|
146 |
4856701 |
for (; this.index < n; this.index++) { |
147 |
4119676 |
char c = this.rawVersion.charAt(this.index); |
148 |
|
|
149 |
4119676 |
if (c == '.' || c == '-') { |
150 |
1289942 |
end = this.index; |
151 |
1289942 |
this.index++; |
152 |
1289942 |
break; |
153 |
|
} else { |
154 |
2829734 |
int digit = Character.digit(c, 10); |
155 |
2829734 |
if (digit >= 0) { |
156 |
2206173 |
if (state == -1) { |
157 |
8103 |
end = this.index; |
158 |
8103 |
break; |
159 |
|
} |
160 |
2198070 |
if (state == 0) { |
161 |
|
|
162 |
6138 |
start++; |
163 |
|
} |
164 |
2198070 |
state = (state > 0 || digit > 0) ? 1 : 0; |
165 |
|
} else { |
166 |
623561 |
if (state >= 0) { |
167 |
10601 |
end = this.index; |
168 |
10601 |
break; |
169 |
|
} |
170 |
612960 |
state = -1; |
171 |
|
} |
172 |
|
} |
173 |
|
} |
174 |
|
|
175 |
2045671 |
if (start < end) { |
176 |
2045671 |
this.token = this.rawVersion.substring(start, end); |
177 |
2045671 |
this.number = state >= 0; |
178 |
|
} else { |
179 |
0 |
this.token = "0"; |
180 |
0 |
this.number = true; |
181 |
|
} |
182 |
|
|
183 |
2045671 |
return true; |
184 |
|
} |
185 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
186 |
0 |
@Override... |
187 |
|
public String toString() |
188 |
|
{ |
189 |
0 |
return this.token; |
190 |
|
} |
191 |
|
} |
192 |
|
|
193 |
|
|
194 |
|
|
195 |
|
|
196 |
|
@version |
197 |
|
|
|
|
| 87.1% |
Uncovered Elements: 12 (93) |
Complexity: 24 |
Complexity Density: 0.35 |
|
198 |
|
static final class Element implements Comparable<Element> |
199 |
|
{ |
200 |
|
|
201 |
|
@link |
202 |
|
|
203 |
|
private static final String ERROR_UNKNOWNKIND = "Unknown version element kind "; |
204 |
|
|
205 |
|
|
206 |
|
|
207 |
|
|
208 |
|
@version |
209 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 0 |
Complexity Density: - |
|
210 |
|
enum ElementType |
211 |
|
{ |
212 |
|
|
213 |
|
|
214 |
|
|
215 |
|
QUALIFIER, |
216 |
|
|
217 |
|
|
218 |
|
|
219 |
|
|
220 |
|
INT, |
221 |
|
|
222 |
|
|
223 |
|
|
224 |
|
|
225 |
|
STRING |
226 |
|
} |
227 |
|
|
228 |
|
|
229 |
|
|
230 |
|
|
231 |
|
private static final Map<String, Integer> QUALIFIERS; |
232 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (13) |
Complexity: 1 |
Complexity Density: 0.08 |
|
233 |
57 |
static {... |
234 |
57 |
QUALIFIERS = new HashMap<String, Integer>(); |
235 |
57 |
QUALIFIERS.put("alpha", Integer.valueOf(-5)); |
236 |
57 |
QUALIFIERS.put("a", Integer.valueOf(-5)); |
237 |
57 |
QUALIFIERS.put("beta", Integer.valueOf(-4)); |
238 |
57 |
QUALIFIERS.put("b", Integer.valueOf(-4)); |
239 |
57 |
QUALIFIERS.put("milestone", Integer.valueOf(-3)); |
240 |
57 |
QUALIFIERS.put("cr", Integer.valueOf(-2)); |
241 |
57 |
QUALIFIERS.put("rc", Integer.valueOf(-2)); |
242 |
57 |
QUALIFIERS.put("snapshot", Integer.valueOf(-1)); |
243 |
57 |
QUALIFIERS.put("ga", Integer.valueOf(0)); |
244 |
57 |
QUALIFIERS.put("final", Integer.valueOf(0)); |
245 |
57 |
QUALIFIERS.put("", Integer.valueOf(0)); |
246 |
57 |
QUALIFIERS.put("sp", Integer.valueOf(1)); |
247 |
|
} |
248 |
|
|
249 |
|
|
250 |
|
|
251 |
|
|
252 |
|
private final ElementType elementType; |
253 |
|
|
254 |
|
|
255 |
|
|
256 |
|
|
257 |
|
private final Object value; |
258 |
|
|
259 |
|
|
260 |
|
@see |
261 |
|
|
262 |
|
private Type versionType = Type.STABLE; |
263 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
264 |
1935408 |
private boolean isInteger(String number)... |
265 |
|
{ |
266 |
1935408 |
return number.length() < MAX_INTEGER_LENGTH |
267 |
|
|| (number.length() == MAX_INTEGER_LENGTH && MAX_INTEGER_STRING.compareTo(number) >= 0); |
268 |
|
} |
269 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
270 |
0 |
public Element(String token)... |
271 |
|
{ |
272 |
0 |
this.elementType = ElementType.STRING; |
273 |
0 |
this.value = token; |
274 |
|
} |
275 |
|
|
276 |
|
|
277 |
|
@param |
278 |
|
|
|
|
| 96.7% |
Uncovered Elements: 1 (30) |
Complexity: 7 |
Complexity Density: 0.35 |
|
279 |
2045671 |
public Element(Tokenizer tokenizer)... |
280 |
|
{ |
281 |
2045671 |
String token = tokenizer.getToken(); |
282 |
2045671 |
if (tokenizer.isNumber()) { |
283 |
1935408 |
if (isInteger(token)) { |
284 |
1935355 |
try { |
285 |
1935355 |
this.elementType = ElementType.INT; |
286 |
1935355 |
this.value = Integer.valueOf(token); |
287 |
|
} catch (NumberFormatException e) { |
288 |
0 |
throw new IllegalStateException(e); |
289 |
|
} |
290 |
|
} else { |
291 |
53 |
this.elementType = ElementType.STRING; |
292 |
53 |
this.value = token; |
293 |
|
} |
294 |
|
} else { |
295 |
110263 |
String lowerCaseToken = token.toLowerCase(Locale.ENGLISH); |
296 |
110263 |
Integer qualifier = QUALIFIERS.get(lowerCaseToken); |
297 |
110263 |
if (qualifier != null) { |
298 |
63824 |
this.elementType = ElementType.QUALIFIER; |
299 |
63824 |
this.value = qualifier; |
300 |
63824 |
if (qualifier.intValue() == -1) { |
301 |
29374 |
this.versionType = Type.SNAPSHOT; |
302 |
34450 |
} else if (qualifier < 0) { |
303 |
3147 |
this.versionType = Type.BETA; |
304 |
|
} |
305 |
|
} else { |
306 |
46439 |
this.elementType = ElementType.STRING; |
307 |
46439 |
this.value = lowerCaseToken; |
308 |
|
} |
309 |
|
} |
310 |
|
} |
311 |
|
|
312 |
|
|
313 |
|
@return |
314 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
315 |
10823 |
public boolean isNumber()... |
316 |
|
{ |
317 |
10823 |
return this.elementType == ElementType.INT || this.elementType == ElementType.QUALIFIER; |
318 |
|
} |
319 |
|
|
320 |
|
|
321 |
|
@return |
322 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
323 |
2078192 |
public Type getVersionType()... |
324 |
|
{ |
325 |
2078192 |
return this.versionType; |
326 |
|
} |
327 |
|
|
|
|
| 86.2% |
Uncovered Elements: 4 (29) |
Complexity: 9 |
Complexity Density: 0.36 |
|
328 |
883757 |
@Override... |
329 |
|
public int compareTo(Element that) |
330 |
|
{ |
331 |
883757 |
int rel; |
332 |
|
|
333 |
883757 |
if (that == null) { |
334 |
|
|
335 |
880173 |
switch (this.elementType) { |
336 |
31351 |
case STRING: |
337 |
31351 |
rel = 1; |
338 |
31351 |
break; |
339 |
788816 |
case INT: |
340 |
60006 |
case QUALIFIER: |
341 |
848822 |
rel = (Integer) this.value; |
342 |
848822 |
break; |
343 |
0 |
default: |
344 |
0 |
throw new IllegalStateException(ERROR_UNKNOWNKIND + this.elementType); |
345 |
|
} |
346 |
|
} else { |
347 |
3584 |
rel = this.elementType.compareTo(that.elementType); |
348 |
3584 |
if (rel == 0) { |
349 |
3583 |
switch (this.elementType) { |
350 |
2888 |
case INT: |
351 |
184 |
case QUALIFIER: |
352 |
3072 |
rel = (Integer) this.value - (Integer) that.value; |
353 |
3072 |
break; |
354 |
511 |
case STRING: |
355 |
511 |
rel = ((String) this.value).compareToIgnoreCase((String) that.value); |
356 |
511 |
break; |
357 |
0 |
default: |
358 |
0 |
throw new IllegalStateException(ERROR_UNKNOWNKIND + this.elementType); |
359 |
|
} |
360 |
|
} |
361 |
|
} |
362 |
|
|
363 |
883757 |
return rel; |
364 |
|
} |
365 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
366 |
0 |
@Override... |
367 |
|
public boolean equals(Object obj) |
368 |
|
{ |
369 |
0 |
return (obj instanceof Element) && compareTo((Element) obj) == 0; |
370 |
|
} |
371 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
372 |
1900991 |
@Override... |
373 |
|
public int hashCode() |
374 |
|
{ |
375 |
1900991 |
HashCodeBuilder builder = new HashCodeBuilder(); |
376 |
|
|
377 |
1900991 |
builder.append(this.value); |
378 |
1900991 |
builder.append(this.elementType); |
379 |
|
|
380 |
1900991 |
return builder.toHashCode(); |
381 |
|
} |
382 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
383 |
0 |
@Override... |
384 |
|
public String toString() |
385 |
|
{ |
386 |
0 |
return this.value.toString(); |
387 |
|
} |
388 |
|
|
389 |
|
} |
390 |
|
|
391 |
|
|
392 |
|
@param |
393 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
394 |
752517 |
public DefaultVersion(String rawVersion)... |
395 |
|
{ |
396 |
752517 |
setVersion(rawVersion); |
397 |
|
} |
398 |
|
|
399 |
|
|
400 |
|
@link |
401 |
|
|
402 |
|
@param |
403 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
404 |
0 |
public DefaultVersion(Version version)... |
405 |
|
{ |
406 |
0 |
this(version.getValue()); |
407 |
|
} |
408 |
|
|
409 |
|
|
410 |
|
|
411 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
412 |
741268 |
private void initElements()... |
413 |
|
{ |
414 |
741268 |
if (this.elements == null) { |
415 |
737025 |
parse(); |
416 |
|
} |
417 |
|
} |
418 |
|
|
419 |
|
|
420 |
|
@param |
421 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
422 |
752523 |
private void setVersion(String rawVersion)... |
423 |
|
{ |
424 |
752523 |
this.rawVersion = rawVersion; |
425 |
|
} |
426 |
|
|
427 |
|
|
428 |
|
|
429 |
|
|
|
|
| 85.7% |
Uncovered Elements: 2 (14) |
Complexity: 4 |
Complexity Density: 0.4 |
|
430 |
737025 |
private void parse()... |
431 |
|
{ |
432 |
737025 |
this.elements = new ArrayList<Element>(); |
433 |
|
|
434 |
737025 |
try { |
435 |
2782696 |
for (Tokenizer tokenizer = new Tokenizer(this.rawVersion); tokenizer.next();) { |
436 |
2045671 |
Element element = new Element(tokenizer); |
437 |
2045671 |
this.elements.add(element); |
438 |
2045671 |
if (element.getVersionType() != Type.STABLE) { |
439 |
32521 |
this.type = element.getVersionType(); |
440 |
|
} |
441 |
|
} |
442 |
|
|
443 |
737025 |
trimPadding(this.elements); |
444 |
|
} catch (Exception e) { |
445 |
|
|
446 |
0 |
LOGGER.error("Failed to parse version [" + this.rawVersion + "]", e); |
447 |
0 |
this.elements.add(new Element(this.rawVersion)); |
448 |
|
} |
449 |
|
} |
450 |
|
|
451 |
|
|
452 |
|
|
453 |
|
|
454 |
|
@param |
455 |
|
|
|
|
| 88.9% |
Uncovered Elements: 1 (9) |
Complexity: 3 |
Complexity Density: 0.6 |
|
456 |
737025 |
private static void trimPadding(List<Element> elements)... |
457 |
|
{ |
458 |
879960 |
for (ListIterator<Element> it = elements.listIterator(elements.size()); it.hasPrevious();) { |
459 |
879960 |
Element element = it.previous(); |
460 |
|
|
461 |
879960 |
if (element.compareTo(null) == 0) { |
462 |
142935 |
it.remove(); |
463 |
|
} else { |
464 |
737025 |
break; |
465 |
|
} |
466 |
|
} |
467 |
|
} |
468 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
469 |
38 |
@Override... |
470 |
|
public Type getType() |
471 |
|
{ |
472 |
38 |
initElements(); |
473 |
|
|
474 |
38 |
return this.type; |
475 |
|
} |
476 |
|
|
477 |
|
|
478 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
479 |
52849 |
@Override... |
480 |
|
public String getValue() |
481 |
|
{ |
482 |
52849 |
return this.rawVersion; |
483 |
|
} |
484 |
|
|
485 |
|
|
486 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
487 |
11133 |
@Override... |
488 |
|
public String toString() |
489 |
|
{ |
490 |
11133 |
return getValue(); |
491 |
|
} |
492 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
493 |
737314 |
@Override... |
494 |
|
public int hashCode() |
495 |
|
{ |
496 |
737314 |
if (this.hashCode == -1) { |
497 |
736068 |
initElements(); |
498 |
|
|
499 |
736068 |
this.hashCode = this.elements.hashCode(); |
500 |
|
} |
501 |
|
|
502 |
737314 |
return this.hashCode; |
503 |
|
} |
504 |
|
|
|
|
| 60% |
Uncovered Elements: 6 (15) |
Complexity: 4 |
Complexity Density: 0.44 |
|
505 |
1114 |
@Override... |
506 |
|
public boolean equals(Object obj) |
507 |
|
{ |
508 |
1114 |
if (obj == this) { |
509 |
2 |
return true; |
510 |
|
} |
511 |
|
|
512 |
1112 |
boolean equals; |
513 |
|
|
514 |
1112 |
if (obj instanceof DefaultVersion) { |
515 |
1112 |
equals = equals((DefaultVersion) obj); |
516 |
0 |
} else if (obj instanceof Version) { |
517 |
0 |
equals = equals(new DefaultVersion(((Version) obj).getValue())); |
518 |
|
} else { |
519 |
0 |
equals = false; |
520 |
|
} |
521 |
|
|
522 |
1112 |
return equals; |
523 |
|
} |
524 |
|
|
525 |
|
|
526 |
|
@param |
527 |
|
@return |
528 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
529 |
1112 |
public boolean equals(DefaultVersion version)... |
530 |
|
{ |
531 |
1112 |
return compareTo(version) == 0; |
532 |
|
} |
533 |
|
|
|
|
| 77.8% |
Uncovered Elements: 2 (9) |
Complexity: 3 |
Complexity Density: 0.6 |
|
534 |
1731 |
@Override... |
535 |
|
public int compareTo(Version version) |
536 |
|
{ |
537 |
1731 |
if (version == this) { |
538 |
284 |
return 0; |
539 |
|
} |
540 |
|
|
541 |
1447 |
if (version instanceof DefaultVersion) { |
542 |
1447 |
return compareTo((DefaultVersion) version); |
543 |
|
} else { |
544 |
0 |
return compareTo(new DefaultVersion(version.getValue())); |
545 |
|
} |
546 |
|
} |
547 |
|
|
548 |
|
|
549 |
|
@param |
550 |
|
@return |
551 |
|
|
552 |
|
@since |
553 |
|
@since |
554 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
555 |
0 |
public int compareTo(String version)... |
556 |
|
{ |
557 |
0 |
return compareTo(new DefaultVersion(version)); |
558 |
|
} |
559 |
|
|
560 |
|
|
561 |
|
@param |
562 |
|
@return |
563 |
|
|
564 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (36) |
Complexity: 8 |
Complexity Density: 0.33 |
|
565 |
2581 |
public int compareTo(DefaultVersion version)... |
566 |
|
{ |
567 |
2581 |
initElements(); |
568 |
2581 |
version.initElements(); |
569 |
|
|
570 |
2581 |
final List<Element> otherElements = version.elements; |
571 |
|
|
572 |
2581 |
boolean number = true; |
573 |
|
|
574 |
2581 |
int rel; |
575 |
|
|
576 |
2581 |
for (int index = 0;; index++) { |
577 |
5524 |
if (index >= this.elements.size() && index >= otherElements.size()) { |
578 |
1728 |
return 0; |
579 |
3796 |
} else if (index >= this.elements.size()) { |
580 |
5 |
return -comparePadding(otherElements, index, null); |
581 |
3791 |
} else if (index >= otherElements.size()) { |
582 |
29 |
return comparePadding(this.elements, index, null); |
583 |
|
} |
584 |
|
|
585 |
3762 |
Element thisElement = this.elements.get(index); |
586 |
3762 |
Element thatElement = otherElements.get(index); |
587 |
|
|
588 |
3762 |
if (thisElement.isNumber() != thatElement.isNumber()) { |
589 |
178 |
if (number == thisElement.isNumber()) { |
590 |
91 |
rel = comparePadding(this.elements, index, Boolean.valueOf(number)); |
591 |
|
} else { |
592 |
87 |
rel = -comparePadding(otherElements, index, Boolean.valueOf(number)); |
593 |
|
} |
594 |
|
|
595 |
178 |
break; |
596 |
|
} else { |
597 |
3584 |
rel = thisElement.compareTo(thatElement); |
598 |
3584 |
if (rel != 0) { |
599 |
641 |
break; |
600 |
|
} |
601 |
2943 |
number = thisElement.isNumber(); |
602 |
|
} |
603 |
|
} |
604 |
|
|
605 |
819 |
return rel; |
606 |
|
} |
607 |
|
|
608 |
|
|
609 |
|
|
610 |
|
|
611 |
|
@param |
612 |
|
@param |
613 |
|
@param |
614 |
|
@return |
615 |
|
|
|
|
| 80% |
Uncovered Elements: 3 (15) |
Complexity: 5 |
Complexity Density: 0.56 |
|
616 |
212 |
private static int comparePadding(List<Element> elements, int index, Boolean number)... |
617 |
|
{ |
618 |
212 |
int rel = 0; |
619 |
|
|
620 |
213 |
for (Iterator<Element> it = elements.listIterator(index); it.hasNext();) { |
621 |
213 |
Element element = it.next(); |
622 |
213 |
if (number != null && number.booleanValue() != element.isNumber()) { |
623 |
0 |
break; |
624 |
|
} |
625 |
|
|
626 |
213 |
rel = element.compareTo(null); |
627 |
213 |
if (rel != 0) { |
628 |
212 |
break; |
629 |
|
} |
630 |
|
} |
631 |
|
|
632 |
212 |
return rel; |
633 |
|
} |
634 |
|
|
635 |
|
|
636 |
|
|
637 |
|
|
638 |
|
@param |
639 |
|
@throws |
640 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
641 |
93 |
private void writeObject(ObjectOutputStream out) throws IOException... |
642 |
|
{ |
643 |
93 |
out.writeObject(getValue()); |
644 |
|
} |
645 |
|
|
646 |
|
|
647 |
|
@param |
648 |
|
@throws |
649 |
|
@throws |
650 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
651 |
6 |
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException... |
652 |
|
{ |
653 |
6 |
setVersion((String) in.readObject()); |
654 |
|
} |
655 |
|
} |