|
1 |
| package net.sourceforge.pmd.properties; |
|
2 |
| |
|
3 |
| import net.sourceforge.pmd.util.StringUtil; |
|
4 |
| |
|
5 |
| |
|
6 |
| |
|
7 |
| |
|
8 |
| |
|
9 |
| |
|
10 |
| |
|
11 |
| |
|
12 |
| public abstract class AbstractScalarProperty extends AbstractPMDProperty { |
|
13 |
| |
|
14 |
| |
|
15 |
| |
|
16 |
| |
|
17 |
| |
|
18 |
| |
|
19 |
| |
|
20 |
| |
|
21 |
414
| public AbstractScalarProperty(String theName, String theDescription, Object theDefault, float theUIOrder) {
|
|
22 |
414
| super(theName, theDescription, theDefault, theUIOrder);
|
|
23 |
| } |
|
24 |
| |
|
25 |
| |
|
26 |
| |
|
27 |
| |
|
28 |
| |
|
29 |
| |
|
30 |
| protected abstract Object createFrom(String value); |
|
31 |
| |
|
32 |
| |
|
33 |
| |
|
34 |
| |
|
35 |
| |
|
36 |
| |
|
37 |
| protected abstract Object[] arrayFor(int size); |
|
38 |
| |
|
39 |
| |
|
40 |
| |
|
41 |
| |
|
42 |
| |
|
43 |
| |
|
44 |
| |
|
45 |
| |
|
46 |
457
| public Object valueFrom(String valueString) throws IllegalArgumentException {
|
|
47 |
| |
|
48 |
451
| if (maxValueCount() == 1) return createFrom(valueString);
|
|
49 |
| |
|
50 |
6
| String[] strValues = StringUtil.substringsOf(valueString, multiValueDelimiter);
|
|
51 |
| |
|
52 |
6
| Object[] values = arrayFor(strValues.length);
|
|
53 |
44
| for (int i=0; i<strValues.length; i++) values[i] = createFrom(strValues[i]);
|
|
54 |
6
| return values;
|
|
55 |
| } |
|
56 |
| } |