net.sourceforge.pmd.lang.rule.properties
Class PropertyDescriptorWrapper<T>

java.lang.Object
  extended by net.sourceforge.pmd.lang.rule.properties.PropertyDescriptorWrapper<T>
Type Parameters:
T - The type of the underlying PropertyDescriptor.
All Implemented Interfaces:
Comparable<PropertyDescriptor<?>>, PropertyDescriptor<T>

public class PropertyDescriptorWrapper<T>
extends Object
implements PropertyDescriptor<T>

This class serves as a wrapper class for a PropertyDescriptor instance. It exists to allowing the PropertyDescriptorFactory to readily flag properties it has created, versus those created by Rule classes. This is used in the encoding of a Rule to XML format to distinguish Rule defined PropertyDescriptors and those which were originally defined in XML.


Constructor Summary
PropertyDescriptorWrapper(PropertyDescriptor<T> propertyDescriptor)
           
 
Method Summary
 String asDelimitedString(T value)
          Formats the object onto a string suitable for storage within the property map.
 Map<String,String> attributeValuesById()
          Returns a map representing all the property attributes of the receiver in string form.
 Object[][] choices()
          Returns a set of choice tuples if available, returns null if none are defined.
 int compareTo(PropertyDescriptor<?> o)
           
 T defaultValue()
          Default value to use when the user hasn't specified one or when they wish to revert to a known-good state.
 String description()
          Describes the property and the role it plays within the rule it is specified for.
 boolean equals(Object obj)
           
 String errorFor(Object value)
          Validation function that returns a diagnostic error message for a sample property value.
 PropertyDescriptor<T> getPropertyDescriptor()
           
 int hashCode()
           
 boolean isMultiValue()
          Returns whether the property is multi-valued, i.e. an array of strings, As unary property rule properties will return a value of one, you must use the get/setProperty accessors when working with the actual values.
 boolean isRequired()
          Denotes whether the value is required before the rule can be executed.
 char multiValueDelimiter()
          Return the character being used to delimit multiple property values within a single string.
 String name()
          The name of the property without spaces as it serves as the key into the property map.
 int preferredRowCount()
          If the datatype is a String then return the preferred number of rows to allocate in the text widget, returns a value of one for all other types.
 String propertyErrorFor(Rule rule)
          A convenience method that returns an error string if the rule holds onto a property value that has a problem.
 String toString()
           
 Class<T> type()
          Denotes the value datatype.
 float uiOrder()
          Denotes the relative order the property field should occupy if we are using an auto-generated UI to display and edit property values.
 T valueFrom(String propertyString)
          If the property is multi-valued then return the separate values after parsing the propertyString provided.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PropertyDescriptorWrapper

public PropertyDescriptorWrapper(PropertyDescriptor<T> propertyDescriptor)
Method Detail

getPropertyDescriptor

public PropertyDescriptor<T> getPropertyDescriptor()

asDelimitedString

public String asDelimitedString(T value)
Description copied from interface: PropertyDescriptor
Formats the object onto a string suitable for storage within the property map.

Specified by:
asDelimitedString in interface PropertyDescriptor<T>
Parameters:
value - Object
Returns:
String

choices

public Object[][] choices()
Description copied from interface: PropertyDescriptor
Returns a set of choice tuples if available, returns null if none are defined.

Specified by:
choices in interface PropertyDescriptor<T>
Returns:
Object[][]

compareTo

public int compareTo(PropertyDescriptor<?> o)
Specified by:
compareTo in interface Comparable<PropertyDescriptor<?>>

defaultValue

public T defaultValue()
Description copied from interface: PropertyDescriptor
Default value to use when the user hasn't specified one or when they wish to revert to a known-good state.

Specified by:
defaultValue in interface PropertyDescriptor<T>
Returns:
Object

description

public String description()
Description copied from interface: PropertyDescriptor
Describes the property and the role it plays within the rule it is specified for. Could be used in a tooltip.

Specified by:
description in interface PropertyDescriptor<T>
Returns:
String

errorFor

public String errorFor(Object value)
Description copied from interface: PropertyDescriptor
Validation function that returns a diagnostic error message for a sample property value. Returns null if the value is acceptable.

Specified by:
errorFor in interface PropertyDescriptor<T>
Parameters:
value - Object
Returns:
String

isMultiValue

public boolean isMultiValue()
Description copied from interface: PropertyDescriptor
Returns whether the property is multi-valued, i.e. an array of strings, As unary property rule properties will return a value of one, you must use the get/setProperty accessors when working with the actual values. When working with multi-value properties then the get/setProperties accessors must be used.

Specified by:
isMultiValue in interface PropertyDescriptor<T>
Returns:
boolean

isRequired

public boolean isRequired()
Description copied from interface: PropertyDescriptor
Denotes whether the value is required before the rule can be executed. Has no meaning for primitive types such as booleans, ints, etc.

Specified by:
isRequired in interface PropertyDescriptor<T>
Returns:
boolean

multiValueDelimiter

public char multiValueDelimiter()
Description copied from interface: PropertyDescriptor
Return the character being used to delimit multiple property values within a single string. You must ensure that this character does not appear within any rule property values to avoid deserialization errors.

Specified by:
multiValueDelimiter in interface PropertyDescriptor<T>
Returns:
char

name

public String name()
Description copied from interface: PropertyDescriptor
The name of the property without spaces as it serves as the key into the property map.

Specified by:
name in interface PropertyDescriptor<T>
Returns:
String

preferredRowCount

public int preferredRowCount()
Description copied from interface: PropertyDescriptor
If the datatype is a String then return the preferred number of rows to allocate in the text widget, returns a value of one for all other types. Useful for multi-line XPATH editors.

Specified by:
preferredRowCount in interface PropertyDescriptor<T>
Returns:
int

propertyErrorFor

public String propertyErrorFor(Rule rule)
Description copied from interface: PropertyDescriptor
A convenience method that returns an error string if the rule holds onto a property value that has a problem. Returns null otherwise.

Specified by:
propertyErrorFor in interface PropertyDescriptor<T>
Parameters:
rule - Rule
Returns:
String

type

public Class<T> type()
Description copied from interface: PropertyDescriptor
Denotes the value datatype.

Specified by:
type in interface PropertyDescriptor<T>
Returns:
Class

uiOrder

public float uiOrder()
Description copied from interface: PropertyDescriptor
Denotes the relative order the property field should occupy if we are using an auto-generated UI to display and edit property values. If the value returned has a non-zero fractional part then this is can be used to place adjacent fields on the same row. Example: name -> 0.0 description 1.0 minValue -> 2.0 maxValue -> 2.1 ..would have their fields placed like: name: [ ] description: [ ] minimum: [ ] maximum: [ ]

Specified by:
uiOrder in interface PropertyDescriptor<T>
Returns:
float

valueFrom

public T valueFrom(String propertyString)
            throws IllegalArgumentException
Description copied from interface: PropertyDescriptor
If the property is multi-valued then return the separate values after parsing the propertyString provided. If it isn't a multi-valued property then the value will be returned within an array of size[1].

Specified by:
valueFrom in interface PropertyDescriptor<T>
Parameters:
propertyString - String
Returns:
Object
Throws:
IllegalArgumentException - if the given string cannot be parsed

attributeValuesById

public Map<String,String> attributeValuesById()
Description copied from interface: PropertyDescriptor
Returns a map representing all the property attributes of the receiver in string form.

Specified by:
attributeValuesById in interface PropertyDescriptor<T>
Returns:
Map

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2002-2015 InfoEther. All Rights Reserved.