1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
|
22 |
|
|
23 |
|
|
24 |
|
package net.smartlab.web.bean; |
25 |
|
|
26 |
|
import java.util.List; |
27 |
|
import java.util.Locale; |
28 |
|
|
29 |
|
|
30 |
|
|
31 |
|
|
32 |
|
@author |
33 |
|
|
|
|
| 0% |
Uncovered Elements: 24 (24) |
Complexity: 7 |
Complexity Density: 0,47 |
|
34 |
|
public class CharArrayConverter extends ArrayConverter { |
35 |
|
|
36 |
|
private static final char[] model = new char[0]; |
37 |
|
|
38 |
|
|
39 |
|
@see |
40 |
|
|
41 |
|
|
|
|
| 0% |
Uncovered Elements: 23 (23) |
Complexity: 7 |
Complexity Density: 0,47 |
|
42 |
0
|
public Object convert(Class type, Object value, Locale locale) throws ConversionException {... |
43 |
|
|
44 |
0
|
if (model.getClass() == value.getClass()) { |
45 |
0
|
return (value); |
46 |
|
} |
47 |
|
|
48 |
|
|
49 |
0
|
if (ArrayConverter.model.getClass() == value.getClass()) { |
50 |
0
|
try { |
51 |
0
|
String values[] = (String[])value; |
52 |
0
|
char[] results = new char[values.length]; |
53 |
0
|
for (int i = 0; i < values.length; i++) { |
54 |
0
|
results[i] = values[i].charAt(0); |
55 |
|
} |
56 |
0
|
return (results); |
57 |
|
} catch (Exception e) { |
58 |
|
throw new ConversionException(value.toString(), e); |
59 |
|
} |
60 |
|
} |
61 |
|
|
62 |
|
|
63 |
|
|
64 |
0
|
try { |
65 |
0
|
List list = parseElements(value.toString()); |
66 |
0
|
char[] results = new char[list.size()]; |
67 |
0
|
for (int i = 0; i < results.length; i++) { |
68 |
0
|
results[i] = ((String)list.get(i)).charAt(0); |
69 |
|
} |
70 |
0
|
return (results); |
71 |
|
} catch (Exception e) { |
72 |
|
throw new ConversionException(value.toString(), e); |
73 |
|
} |
74 |
|
} |
75 |
|
} |