KickJava   Java API By Example, From Geeks To Geeks.

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


1 package net.sourceforge.pmd.properties;
2
3 import net.sourceforge.pmd.util.StringUtil;
4
5 /**
6  * No, subclasses are not necessarily scalar per se, they're just easy to parse without error.
7  * If you can come up with a better name...
8  *
9  * @author Brian Remedios
10  * @version $Revision$
11  */

12 public abstract class AbstractScalarProperty extends AbstractPMDProperty {
13
14     /**
15      * Constructor for AbstractScalarProperty.
16      * @param theName String
17      * @param theDescription String
18      * @param theDefault Object
19      * @param theUIOrder float
20      */

21     public AbstractScalarProperty(String JavaDoc theName, String JavaDoc theDescription, Object JavaDoc theDefault, float theUIOrder) {
22         super(theName, theDescription, theDefault, theUIOrder);
23     }
24
25     /**
26      * Method createFrom.
27      * @param value String
28      * @return Object
29      */

30     protected abstract Object JavaDoc createFrom(String JavaDoc value);
31     
32     /**
33      * Method arrayFor.
34      * @param size int
35      * @return Object[]
36      */

37     protected abstract Object JavaDoc[] arrayFor(int size);
38     
39     /**
40      * Method valueFrom.
41      * @param valueString String
42      * @return Object[]
43      * @throws IllegalArgumentException
44      * @see net.sourceforge.pmd.PropertyDescriptor#valueFrom(String)
45      */

46     public Object JavaDoc valueFrom(String JavaDoc valueString) throws IllegalArgumentException JavaDoc {
47         
48         if (maxValueCount() == 1) return createFrom(valueString);
49         
50         String JavaDoc[] strValues = StringUtil.substringsOf(valueString, multiValueDelimiter);
51         
52         Object JavaDoc[] values = arrayFor(strValues.length);
53         for (int i=0; i<strValues.length; i++) values[i] = createFrom(strValues[i]);
54         return values;
55     }
56 }
57
Popular Tags