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.io.File;
7   import java.util.Map;
8   
9   import net.sourceforge.pmd.PropertyDescriptorFactory;
10  import net.sourceforge.pmd.lang.rule.properties.factories.BasicPropertyDescriptorFactory;
11  import net.sourceforge.pmd.util.StringUtil;
12  
13  /**
14   * 
15   * @author Brian Remedios
16   */
17  public class FileProperty extends AbstractProperty<File> {
18  
19      public static final PropertyDescriptorFactory FACTORY = new BasicPropertyDescriptorFactory<FileProperty>(File.class) {
20  
21          public FileProperty createWith(Map<String, String> valuesById) {
22              return new FileProperty(nameIn(valuesById), descriptionIn(valuesById), null, 0f);
23          }
24      };
25  
26      public FileProperty(String theName, String theDescription, File theDefault, float theUIOrder) {
27          super(theName, theDescription, theDefault, theUIOrder);
28      }
29  
30      public Class<File> type() {
31          return File.class;
32      }
33  
34      public File valueFrom(String propertyString) throws IllegalArgumentException {
35  
36          return StringUtil.isEmpty(propertyString) ? null : new File(propertyString);
37      }
38  
39      @Override
40      protected String defaultAsString() {
41          // TODO Auto-generated method stub
42          return null;
43      }
44  
45  }