01: package net.sourceforge.pmd.properties;
02:
03: /**
04: * Defines a property type that supports Boolean values.
05: *
06: * @author Brian Remedios
07: * @version $Revision$
08: */
09: public class BooleanProperty extends AbstractScalarProperty {
10:
11: /**
12: * Constructor for BooleanProperty.
13: * @param theName String
14: * @param theDescription String
15: * @param defaultValue boolean
16: * @param theUIOrder float
17: */
18: public BooleanProperty(String theName, String theDescription,
19: boolean defaultValue, float theUIOrder) {
20: super (theName, theDescription, Boolean.valueOf(defaultValue),
21: theUIOrder);
22: }
23:
24: /**
25: * Constructor for BooleanProperty.
26: * @param theName String
27: * @param theDescription String
28: * @param defaultValues boolean[]
29: * @param theUIOrder float
30: * @param theMaxValues int
31: */
32: public BooleanProperty(String theName, String theDescription,
33: boolean[] defaultValues, float theUIOrder, int theMaxValues) {
34: this (theName, theDescription, asBooleans(defaultValues),
35: theUIOrder, theMaxValues);
36:
37: }
38:
39: /**
40: * Constructor for BooleanProperty.
41: * @param theName String
42: * @param theDescription String
43: * @param defaultValues Boolean[]
44: * @param theUIOrder float
45: * @param theMaxValues int
46: */
47: public BooleanProperty(String theName, String theDescription,
48: Boolean[] defaultValues, float theUIOrder, int theMaxValues) {
49: super (theName, theDescription, defaultValues, theUIOrder);
50:
51: maxValueCount(theMaxValues);
52: }
53:
54: /**
55: * Method asBooleans.
56: * @param bools boolean[]
57: * @return Boolean[]
58: */
59: private static final Boolean[] asBooleans(boolean[] bools) {
60: Boolean[] booleans = new Boolean[bools.length];
61: for (int i = 0; i < bools.length; i++)
62: booleans[i] = Boolean.valueOf(bools[i]);
63: return booleans;
64: }
65:
66: /**
67: * Method type.
68: * @return Class
69: * @see net.sourceforge.pmd.PropertyDescriptor#type()
70: */
71: public Class<Boolean> type() {
72: return Boolean.class;
73: }
74:
75: /**
76: * Method createFrom.
77: * @param value String
78: * @return Object
79: */
80: protected Object createFrom(String value) {
81: return Boolean.valueOf(value);
82: }
83:
84: /**
85: * Method arrayFor.
86: * @param size int
87: * @return Object[]
88: */
89: protected Object[] arrayFor(int size) {
90: return new Boolean[size];
91: }
92: }
|