KickJava   Java API By Example, From Geeks To Geeks.

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


1 package net.sourceforge.pmd.properties;
2
3
4 /**
5  * Defines a property type that support double property values.
6  *
7  * @author Brian Remedios
8  */

9 public class DoubleProperty extends AbstractScalarProperty {
10
11     /**
12      * Constructor for DoubleProperty.
13      * @param theName String
14      * @param theDescription String
15      * @param theDefault double
16      * @param theUIOrder float
17      */

18     public DoubleProperty(String JavaDoc theName, String JavaDoc theDescription, double theDefault, float theUIOrder) {
19         super(theName, theDescription, new Double JavaDoc(theDefault), theUIOrder);
20     }
21
22     /**
23      * Constructor for DoubleProperty.
24      * @param theName String
25      * @param theDescription String
26      * @param defaultValues boolean[]
27      * @param theUIOrder float
28      * @param theMaxValues int
29      */

30     public DoubleProperty(String JavaDoc theName, String JavaDoc theDescription, double[] defaultValues, float theUIOrder, int theMaxValues) {
31         this(theName, theDescription, asDoubles(defaultValues), theUIOrder, theMaxValues);
32     }
33     
34     /**
35      * Constructor for DoubleProperty.
36      * @param theName String
37      * @param theDescription String
38      * @param defaultValues Double[]
39      * @param theUIOrder float
40      * @param theMaxValues int
41      */

42     public DoubleProperty(String JavaDoc theName, String JavaDoc theDescription, Double JavaDoc[] defaultValues, float theUIOrder, int theMaxValues) {
43         super(theName, theDescription, defaultValues, theUIOrder);
44         
45         maxValueCount(theMaxValues);
46     }
47     
48     /**
49      * Method type.
50      * @return Class
51      * @see net.sourceforge.pmd.PropertyDescriptor#type()
52      */

53     public Class JavaDoc type() {
54         return Double JavaDoc.class;
55     }
56
57     /**
58      * Method asDoubles.
59      * @param doubles double[]
60      * @return Double[]
61      */

62     private static final Double JavaDoc[] asDoubles(double[] doubles) {
63         Double JavaDoc[] Doubles = new Double JavaDoc[doubles.length];
64         for (int i=0; i<doubles.length; i++) Doubles[i] = new Double JavaDoc(doubles[i]);
65         return Doubles;
66     }
67
68     /**
69      * Method createFrom.
70      * @param value String
71      * @return Object
72      */

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

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