01: package test.net.sourceforge.pmd.properties;
02:
03: import java.util.Map;
04:
05: import net.sourceforge.pmd.AbstractRule;
06: import net.sourceforge.pmd.PropertyDescriptor;
07: import net.sourceforge.pmd.properties.BooleanProperty;
08: import net.sourceforge.pmd.properties.CharacterProperty;
09: import net.sourceforge.pmd.properties.EnumeratedProperty;
10: import net.sourceforge.pmd.properties.FloatProperty;
11: import net.sourceforge.pmd.properties.IntegerProperty;
12: import net.sourceforge.pmd.properties.StringProperty;
13: import net.sourceforge.pmd.properties.TypeProperty;
14:
15: class NonRuleWithAllPropertyTypes extends AbstractRule {
16:
17: // descriptors are public to enable us to write external tests
18: public static final PropertyDescriptor singleStr = new StringProperty(
19: "singleStr", "Property with a single string value",
20: "hello world", 3.0f);
21: public static final PropertyDescriptor multiStr = new StringProperty(
22: "multiStr", "Property with multiple string values",
23: new String[] { "hello", "world" }, 5.0f, '|');
24:
25: public static final PropertyDescriptor singleInt = new IntegerProperty(
26: "singleInt", "Property with a single integer value", 8,
27: 3.0f);
28: public static final PropertyDescriptor multiInt = new IntegerProperty(
29: "multiInt", "Property with multiple integer values",
30: new int[] { 1, 2, 3, 4 }, 5.0f, 5);
31:
32: public static final PropertyDescriptor singleBool = new BooleanProperty(
33: "singleBool", "Property with a single boolean value", true,
34: 6.0f);
35: public static final PropertyDescriptor multiBool = new BooleanProperty(
36: "multiBool", "Property with multiple boolean values",
37: new boolean[] { true, false }, 5.0f, 2);
38:
39: public static final PropertyDescriptor singleChar = new CharacterProperty(
40: "singleChar", "Property with a single character value",
41: 'a', 5.0f);
42: public static final PropertyDescriptor multiChar = new CharacterProperty(
43: "multiChar", "Property with multiple character values",
44: new char[] { 'a', 'e', 'i', 'o', 'u' }, 6.0f, '|');
45:
46: public static final PropertyDescriptor singleFloat = new FloatProperty(
47: "singleFloat", "Property with a single float value", 9.9f,
48: 5.0f);
49: public static final PropertyDescriptor multiFloat = new FloatProperty(
50: "multiFloat", "Property with multiple float values",
51: new float[] { 1, 2, 3 }, 6.0f, 3);
52:
53: public static final PropertyDescriptor singleType = new TypeProperty(
54: "singleType", "Property with a single type value",
55: String.class, 5.0f);
56: public static final PropertyDescriptor multiType = new TypeProperty(
57: "multiType", "Property with multiple type values",
58: new Class[] { Integer.class, Object.class }, 6.0f);
59:
60: public static final PropertyDescriptor enumType = new EnumeratedProperty<Class>(
61: "enumType", "Property with a enumerated choices",
62: new String[] { "String", "Object" }, new Class[] {
63: String.class, Object.class }, 5.0f);
64:
65: private static final Map<String, PropertyDescriptor> propertyDescriptorsByName = asFixedMap(new PropertyDescriptor[] {
66: singleStr, multiStr, singleInt, multiInt, singleBool,
67: multiBool, singleChar, multiChar, singleFloat, multiFloat,
68: singleType, multiType, enumType });
69:
70: public NonRuleWithAllPropertyTypes() {
71: super ();
72: }
73:
74: protected Map<String, PropertyDescriptor> propertiesByName() {
75: return propertyDescriptorsByName;
76: }
77:
78: public static junit.framework.Test suite() {
79: return new junit.framework.JUnit4TestAdapter(
80: NonRuleWithAllPropertyTypes.class);
81: }
82: }
|