View Javadoc

1   package net.sourceforge.pmd.properties;
2   
3   
4   /**
5    * Defines a datatype that supports the Integer property values.
6    * 
7    * @author Brian Remedios
8    * @version $Revision$
9    */
10  public class IntegerProperty extends AbstractScalarProperty {
11  
12  	/**
13  	 * Constructor for IntegerProperty.
14  	 * @param theName String
15  	 * @param theDescription String
16  	 * @param theDefault int
17  	 * @param theUIOrder float
18  	 */
19  	public IntegerProperty(String theName, String theDescription, int theDefault, float theUIOrder) {
20  		super(theName, theDescription, theDefault, theUIOrder);
21  	}
22  
23  	/**
24  	 * Constructor for IntegerProperty.
25  	 * @param theName String
26  	 * @param theDescription String
27  	 * @param theDefaults int[]
28  	 * @param theUIOrder float
29  	 * @param maxCount int
30  	 */
31  	public IntegerProperty(String theName, String theDescription, int[] theDefaults, float theUIOrder, int maxCount) {
32  		this(theName, theDescription, asIntegers(theDefaults), theUIOrder, maxCount);
33  	}
34  	
35  	/**
36  	 * Constructor for IntegerProperty.
37  	 * @param theName String
38  	 * @param theDescription String
39  	 * @param theDefaults Integer[]
40  	 * @param theUIOrder float
41  	 * @param maxCount int
42  	 */
43  	public IntegerProperty(String theName, String theDescription, Integer[] theDefaults, float theUIOrder, int maxCount) {
44  		super(theName, theDescription, theDefaults, theUIOrder);
45  		
46  		maxValueCount(maxCount);
47  	}
48  	
49  	/**
50  	 * Method asIntegers.
51  	 * @param ints int[]
52  	 * @return Integer[]
53  	 */
54  	private static final Integer[] asIntegers(int[] ints) {
55  		Integer[] integers = new Integer[ints.length];
56  		for (int i=0; i<ints.length; i++) integers[i] = Integer.valueOf(ints[i]);
57  		return integers;
58  	}
59  	
60  	/**
61  	 * Method type.
62  	 * @return Class
63  	 * @see net.sourceforge.pmd.PropertyDescriptor#type()
64  	 */
65  	public Class<Integer> type() {
66  		return Integer.class;
67  	}
68  
69  	/**
70  	 * Method createFrom.
71  	 * @param value String
72  	 * @return Object
73  	 */
74  	protected Object createFrom(String value) {
75  		return Integer.valueOf(value);
76  	}
77  
78  	/**
79  	 * Method arrayFor.
80  	 * @param size int
81  	 * @return Object[]
82  	 */
83  	protected Object[] arrayFor(int size) {
84  		return new Integer[size];
85  	}
86  }