KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sourceforge > pmd > properties > IntegerProperty


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 JavaDoc theName, String JavaDoc theDescription, int theDefault, float theUIOrder) {
20         super(theName, theDescription, new Integer JavaDoc(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 JavaDoc theName, String JavaDoc 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 JavaDoc theName, String JavaDoc theDescription, Integer JavaDoc[] 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 JavaDoc[] asIntegers(int[] ints) {
55         Integer JavaDoc[] integers = new Integer JavaDoc[ints.length];
56         for (int i=0; i<ints.length; i++) integers[i] = new Integer JavaDoc(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 JavaDoc type() {
66         return Integer JavaDoc.class;
67     }
68
69     /**
70      * Method createFrom.
71      * @param value String
72      * @return Object
73      */

74     protected Object JavaDoc createFrom(String JavaDoc value) {
75         return new Integer JavaDoc(value);
76     }
77
78     /**
79      * Method arrayFor.
80      * @param size int
81      * @return Object[]
82      */

83     protected Object JavaDoc[] arrayFor(int size) {
84         return new Integer JavaDoc[size];
85     }
86 }
87
Popular Tags