View Javadoc

1   /**
2    * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
3    */
4   package net.sourceforge.pmd.lang.rule.properties;
5   
6   import java.util.Map;
7   
8   import net.sourceforge.pmd.PropertyDescriptorFactory;
9   import net.sourceforge.pmd.lang.rule.properties.factories.BasicPropertyDescriptorFactory;
10  
11  /**
12   * Defines a datatype that supports single String values.
13   * 
14   * @author Brian Remedios
15   */
16  public class StringProperty extends AbstractProperty<String> {
17  	
18  	public static final PropertyDescriptorFactory FACTORY = new BasicPropertyDescriptorFactory<StringProperty>(String.class) {
19  
20  		public StringProperty createWith(Map<String, String> valuesById) {
21  			return new StringProperty(
22  					nameIn(valuesById),
23  					descriptionIn(valuesById),
24  					defaultValueIn(valuesById),
25  					0f);
26  		}
27  	};
28  	
29  	/**
30  	 * Constructor for StringProperty.
31  	 * @param theName String
32  	 * @param theDescription String
33  	 * @param theDefaultValue String
34  	 * @param theUIOrder float
35  	 */
36  	public StringProperty(String theName, String theDescription, String theDefaultValue, float theUIOrder) {
37  		super(theName, theDescription, theDefaultValue, theUIOrder);
38  	}
39  	
40      /**
41       * @return String
42       */
43      protected String defaultAsString() {
44          return defaultValue();
45      }
46  	
47  	/**
48  	 *
49  	 * @return Class
50  	 * @see net.sourceforge.pmd.PropertyDescriptor#type()
51  	 */
52  	public Class<String> type() {
53  		return String.class;
54  	}
55  	
56  	/**
57  	 *
58  	 * @param valueString String
59  	 * @return Object
60  	 * @see net.sourceforge.pmd.PropertyDescriptor#valueFrom(String)
61  	 */
62  	public String valueFrom(String valueString) {
63  		return valueString;
64  	}
65  }