net.sourceforge.pmd

Interface PropertyDescriptor

public interface PropertyDescriptor extends Comparable<PropertyDescriptor>

Property value descriptor that defines the use & requirements for setting property values for use within PMD and any associated GUIs.

Version: $Revision$

Author: Brian Remedios

Field Summary
PropertyDescriptor[]emptyPropertySet
Method Summary
StringasDelimitedString(Object value)
Formats the object onto a string suitable for storage within the property map.
Object[][]choices()
Returns a set of choice tuples of available, returns null if none present.
ObjectdefaultValue()
Default value to use when the user hasn't specified one or when they wish to revert to a known-good state.
Stringdescription()
Describes the property and the role it plays within the rule it is specified for.
StringerrorFor(Object value)
Validation function that returns a diagnostic error message for a sample property value.
booleanisRequired()
Denotes whether the value is required before the rule can be executed.
intmaxValueCount()
If the property is multi-valued, i.e. an array of strings, then this returns the maximum number permitted.
charmultiValueDelimiter()
Return the character being used to delimit multiple property values within a single string.
Stringname()
The name of the property without spaces as it serves as the key into the property map.
intpreferredRowCount()
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.
StringpropertyErrorFor(Rule rule)
A convenience method that returns an error string if the rule holds onto a property value that has a problem.
Class<?>type()
Denotes the value datatype.
floatuiOrder()
Denotes the relative order the property field should occupy if we are using an auto-generated UI to display and edit values.
ObjectvalueFrom(String propertyString)
If the property is multi-valued then return the separate values after parsing the propertyString provided.

Field Detail

emptyPropertySet

public PropertyDescriptor[] emptyPropertySet

Method Detail

asDelimitedString

public String asDelimitedString(Object value)
Formats the object onto a string suitable for storage within the property map.

Parameters: value Object

Returns: String

choices

public Object[][] choices()
Returns a set of choice tuples of available, returns null if none present.

Returns: Object[]

defaultValue

public Object defaultValue()
Default value to use when the user hasn't specified one or when they wish to revert to a known-good state.

Returns: Object

description

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

Returns: String

errorFor

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

Parameters: value Object

Returns: String

isRequired

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

Returns: boolean

maxValueCount

public int maxValueCount()
If the property is multi-valued, i.e. an array of strings, then this returns the maximum number permitted. Unary property rule properties normally return a value of one.

Returns: int

multiValueDelimiter

public char multiValueDelimiter()
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.

Returns: char

name

public String name()
The name of the property without spaces as it serves as the key into the property map.

Returns: String

preferredRowCount

public 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. Useful for multi-line XPATH editors.

Returns: int

propertyErrorFor

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

Parameters: rule Rule

Returns: String

type

public Class<?> type()
Denotes the value datatype.

Returns: Class

uiOrder

public float uiOrder()
Denotes the relative order the property field should occupy if we are using an auto-generated UI to display and edit 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: [ ]

Returns: float

valueFrom

public Object valueFrom(String propertyString)
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].

Parameters: propertyString String

Returns: Object

Throws: IllegalArgumentException