1   package test.net.sourceforge.pmd.properties;
2   
3   import java.util.Map;
4   
5   import net.sourceforge.pmd.AbstractRule;
6   import net.sourceforge.pmd.PropertyDescriptor;
7   import net.sourceforge.pmd.properties.BooleanProperty;
8   import net.sourceforge.pmd.properties.CharacterProperty;
9   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("singleStr", "Property with a single string value", "hello world" , 3.0f);
19  	public static final PropertyDescriptor multiStr	= new StringProperty("multiStr", "Property with multiple string values", new String[] {"hello", "world"}, 5.0f, '|');
20  	
21  	public static final PropertyDescriptor singleInt	= new IntegerProperty("singleInt", "Property with a single integer value", 8 , 3.0f);
22  	public static final PropertyDescriptor multiInt	= new IntegerProperty("multiInt", "Property with multiple integer values", new int[] {1,2,3,4}, 5.0f, 5);
23  	
24  	public static final PropertyDescriptor singleBool	= new BooleanProperty("singleBool", "Property with a single boolean value", true, 6.0f);
25  	public static final PropertyDescriptor multiBool	= new BooleanProperty("multiBool", "Property with multiple boolean values", new boolean[] { true, false}, 5.0f, 2);
26  	
27  	public static final PropertyDescriptor singleChar	= new CharacterProperty("singleChar", "Property with a single character value", 'a', 5.0f);
28  	public static final PropertyDescriptor multiChar	= new CharacterProperty("multiChar", "Property with multiple character values", new char[] {'a', 'e', 'i', 'o', 'u'}, 6.0f, '|');
29  	
30  	public static final PropertyDescriptor singleFloat	= new FloatProperty("singleFloat", "Property with a single float value", 9.9f, 5.0f);
31  	public static final PropertyDescriptor multiFloat	= new FloatProperty("multiFloat", "Property with multiple float values", new float[] {1,2,3}, 6.0f, 3);
32  	
33  	public static final PropertyDescriptor singleType	= new TypeProperty("singleType", "Property with a single type value", String.class, 5.0f);
34  	public static final PropertyDescriptor multiType	= new TypeProperty("multiType", "Property with multiple type values", new Class[] {Integer.class, Object.class}, 6.0f);
35  
36  	public static final PropertyDescriptor enumType	= new EnumeratedProperty("enumType", "Property with a enumerated choices", new Object[][] {{"String", String.class},{"Object", Object.class}}, 5.0f);
37  	
38  	
39  	private static final Map propertyDescriptorsByName = asFixedMap(new PropertyDescriptor[] {
40  		singleStr, multiStr, singleInt, multiInt, singleBool, multiBool,
41  		singleChar, multiChar, singleFloat, multiFloat, singleType, multiType,
42  		enumType
43  		});	  
44  	
45  	
46  	public NonRuleWithAllPropertyTypes() {
47  		super();
48  	}
49  
50      protected Map propertiesByName() {
51      	return propertyDescriptorsByName;
52      }
53  }