net.sourceforge.pmd.lang.rule
Class AbstractDelegateRule

java.lang.Object
  extended by net.sourceforge.pmd.lang.rule.AbstractDelegateRule
All Implemented Interfaces:
PropertySource, Rule
Direct Known Subclasses:
RuleReference

public abstract class AbstractDelegateRule
extends Object
implements Rule

Base class for Rule implementations which delegate to another Rule instance.


Field Summary
 
Fields inherited from interface net.sourceforge.pmd.Rule
VIOLATION_SUPPRESS_REGEX_DESCRIPTOR, VIOLATION_SUPPRESS_XPATH_DESCRIPTOR
 
Constructor Summary
AbstractDelegateRule()
           
 
Method Summary
 void addExample(String example)
          Add a single example for this Rule.
 void addRuleChainVisit(Class<? extends Node> nodeClass)
          Adds an AST node by class to be visited by the Rule on the RuleChain.
 void addRuleChainVisit(String astNodeName)
          Adds an AST node by name to be visited by the Rule on the RuleChain.
 void apply(List<? extends Node> nodes, RuleContext ctx)
          Apply this rule to the given collection of nodes, using the given context.
 void definePropertyDescriptor(PropertyDescriptor<?> propertyDescriptor)
          Define a new property via a PropertyDescriptor.
 String dysfunctionReason()
          Returns a description of why the receiver may be dysfunctional.
 void end(RuleContext ctx)
          End processing.
 String getDescription()
          Get the description of this Rule.
 List<String> getExamples()
          Get the list of examples for this Rule.
 String getExternalInfoUrl()
          Get a URL for external information about this Rule.
 Language getLanguage()
          Get the Language of this Rule.
 LanguageVersion getMaximumLanguageVersion()
          Get the maximum LanguageVersion to which this Rule applies.
 String getMessage()
          Get the message to show when this Rule identifies a violation.
 LanguageVersion getMinimumLanguageVersion()
          Get the minimum LanguageVersion to which this Rule applies.
 String getName()
          Get the name of this Rule.
 ParserOptions getParserOptions()
          Get the parser options for this Rule.
 RulePriority getPriority()
          Get the priority of this Rule.
 Map<PropertyDescriptor<?>,Object> getPropertiesByPropertyDescriptor()
          Returns all the current property values for the receiver or an immutable empty map if none are specified.
<T> T
getProperty(PropertyDescriptor<T> propertyDescriptor)
          Get the typed value for the given property.
 PropertyDescriptor<?> getPropertyDescriptor(String name)
          Get the PropertyDescriptor for the given property name.
 List<PropertyDescriptor<?>> getPropertyDescriptors()
          Get the PropertyDescriptors for all defined properties.
 Rule getRule()
           
 List<String> getRuleChainVisits()
          Gets the collection of AST node names visited by the Rule on the RuleChain.
 String getRuleClass()
          Get the implementation class of this Rule.
 String getRuleSetName()
          Get the name of the RuleSet containing this Rule.
 String getSince()
          Get the version of PMD in which this Rule was added.
 boolean hasDescriptor(PropertyDescriptor<?> descriptor)
          Returns whether this Rule has the specified PropertyDescriptor.
 Set<PropertyDescriptor<?>> ignoredProperties()
          Return the properties that are effectively ignored due to the configuration of the rule and values held by other properties.
 boolean isDeprecated()
          Gets whether this Rule is deprecated.
 void setDeprecated(boolean deprecated)
          Sets whether this Rule is deprecated.
 void setDescription(String description)
          Set the description of this Rule.
 void setExternalInfoUrl(String url)
          Set a URL for external information about this Rule.
 void setLanguage(Language language)
          Set the Language of this Rule.
 void setMaximumLanguageVersion(LanguageVersion maximumlanguageVersion)
          Set the maximum LanguageVersion to which this Rule applies.
 void setMessage(String message)
          Set the message to show when this Rule identifies a violation.
 void setMinimumLanguageVersion(LanguageVersion minimumlanguageVersion)
          Set the minimum LanguageVersion to which this Rule applies.
 void setName(String name)
          Set the name of this Rule.
 void setPriority(RulePriority priority)
          Set the priority of this Rule.
<T> void
setProperty(PropertyDescriptor<T> propertyDescriptor, T value)
          Set the property value specified (will be type-checked)
 void setRule(Rule rule)
           
 void setRuleClass(String ruleClass)
          Set the class of this Rule.
 void setRuleSetName(String name)
          Set the name of the RuleSet containing this Rule.
 void setSince(String since)
          Set the version of PMD in which this Rule was added.
 void setUsesDFA()
          Sets whether this Rule uses Data Flow Analysis.
 void setUsesTypeResolution()
          Sets whether this Rule uses Type Resolution.
 void start(RuleContext ctx)
          Start processing.
 boolean usesDFA()
          Gets whether this Rule uses Data Flow Analysis.
 boolean usesRuleChain()
          Gets whether this Rule uses the RuleChain.
 boolean usesTypeResolution()
          Gets whether this Rule uses Type Resolution.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.sourceforge.pmd.PropertySource
useDefaultValueFor, usesDefaultValues
 

Constructor Detail

AbstractDelegateRule

public AbstractDelegateRule()
Method Detail

setRule

public void setRule(Rule rule)

getRule

public Rule getRule()

getLanguage

public Language getLanguage()
Description copied from interface: Rule
Get the Language of this Rule.

Specified by:
getLanguage in interface Rule
Returns:
the language

setLanguage

public void setLanguage(Language language)
Description copied from interface: Rule
Set the Language of this Rule.

Specified by:
setLanguage in interface Rule
Parameters:
language - the language

getMinimumLanguageVersion

public LanguageVersion getMinimumLanguageVersion()
Description copied from interface: Rule
Get the minimum LanguageVersion to which this Rule applies. If this value is null it indicates there is no minimum bound.

Specified by:
getMinimumLanguageVersion in interface Rule
Returns:
the minimum language version

setMinimumLanguageVersion

public void setMinimumLanguageVersion(LanguageVersion minimumlanguageVersion)
Description copied from interface: Rule
Set the minimum LanguageVersion to which this Rule applies.

Specified by:
setMinimumLanguageVersion in interface Rule
Parameters:
minimumlanguageVersion - the minimum language version

setMaximumLanguageVersion

public void setMaximumLanguageVersion(LanguageVersion maximumlanguageVersion)
Description copied from interface: Rule
Set the maximum LanguageVersion to which this Rule applies.

Specified by:
setMaximumLanguageVersion in interface Rule
Parameters:
maximumlanguageVersion - the maximum language version

getMaximumLanguageVersion

public LanguageVersion getMaximumLanguageVersion()
Description copied from interface: Rule
Get the maximum LanguageVersion to which this Rule applies. If this value is null it indicates there is no maximum bound.

Specified by:
getMaximumLanguageVersion in interface Rule
Returns:
the maximum language version

isDeprecated

public boolean isDeprecated()
Description copied from interface: Rule
Gets whether this Rule is deprecated. A deprecated Rule is one which:

Specified by:
isDeprecated in interface Rule
Returns:
true if this rule is deprecated

dysfunctionReason

public String dysfunctionReason()
Description copied from interface: PropertySource
Returns a description of why the receiver may be dysfunctional. Usually due to missing property values or some kind of conflict between values. Returns null if the receiver is ok.

Specified by:
dysfunctionReason in interface PropertySource
Returns:
String
See Also:
PropertySource.dysfunctionReason()

ignoredProperties

public Set<PropertyDescriptor<?>> ignoredProperties()
Description copied from interface: PropertySource
Return the properties that are effectively ignored due to the configuration of the rule and values held by other properties. This can be used to disable corresponding widgets in a UI.

Specified by:
ignoredProperties in interface PropertySource
Returns:
the properties that are ignored

setDeprecated

public void setDeprecated(boolean deprecated)
Description copied from interface: Rule
Sets whether this Rule is deprecated.

Specified by:
setDeprecated in interface Rule
Parameters:
deprecated - whether this rule is deprecated

getName

public String getName()
Description copied from interface: Rule
Get the name of this Rule.

Specified by:
getName in interface Rule
Returns:
the name

setName

public void setName(String name)
Description copied from interface: Rule
Set the name of this Rule.

Specified by:
setName in interface Rule
Parameters:
name - the name

getSince

public String getSince()
Description copied from interface: Rule
Get the version of PMD in which this Rule was added. Return null if not applicable.

Specified by:
getSince in interface Rule
Returns:
version of PMD since when this rule was added

setSince

public void setSince(String since)
Description copied from interface: Rule
Set the version of PMD in which this Rule was added.

Specified by:
setSince in interface Rule
Parameters:
since - the version of PMD since when this rule was added

getRuleClass

public String getRuleClass()
Description copied from interface: Rule
Get the implementation class of this Rule.

Specified by:
getRuleClass in interface Rule
Returns:
the implementation class name of this rule.

setRuleClass

public void setRuleClass(String ruleClass)
Description copied from interface: Rule
Set the class of this Rule.

Specified by:
setRuleClass in interface Rule
Parameters:
ruleClass - the class name of this rule.

getRuleSetName

public String getRuleSetName()
Description copied from interface: Rule
Get the name of the RuleSet containing this Rule.

Specified by:
getRuleSetName in interface Rule
Returns:
the name of th ruleset containing this rule.
See Also:
RuleSet

setRuleSetName

public void setRuleSetName(String name)
Description copied from interface: Rule
Set the name of the RuleSet containing this Rule.

Specified by:
setRuleSetName in interface Rule
Parameters:
name - the name of the ruleset containing this rule.
See Also:
RuleSet

getMessage

public String getMessage()
Description copied from interface: Rule
Get the message to show when this Rule identifies a violation.

Specified by:
getMessage in interface Rule
Returns:
the message to show for a violation.

setMessage

public void setMessage(String message)
Description copied from interface: Rule
Set the message to show when this Rule identifies a violation.

Specified by:
setMessage in interface Rule
Parameters:
message - the message to show for a violation.

getDescription

public String getDescription()
Description copied from interface: Rule
Get the description of this Rule.

Specified by:
getDescription in interface Rule
Returns:
the description

setDescription

public void setDescription(String description)
Description copied from interface: Rule
Set the description of this Rule.

Specified by:
setDescription in interface Rule
Parameters:
description - the description

getExamples

public List<String> getExamples()
Description copied from interface: Rule
Get the list of examples for this Rule.

Specified by:
getExamples in interface Rule
Returns:
the list of examples for this rule.

addExample

public void addExample(String example)
Description copied from interface: Rule
Add a single example for this Rule.

Specified by:
addExample in interface Rule
Parameters:
example - a single example to add

getExternalInfoUrl

public String getExternalInfoUrl()
Description copied from interface: Rule
Get a URL for external information about this Rule.

Specified by:
getExternalInfoUrl in interface Rule
Returns:
the URL for external information about this rule.

setExternalInfoUrl

public void setExternalInfoUrl(String url)
Description copied from interface: Rule
Set a URL for external information about this Rule.

Specified by:
setExternalInfoUrl in interface Rule
Parameters:
url - the URL for external information about this rule.

getPriority

public RulePriority getPriority()
Description copied from interface: Rule
Get the priority of this Rule.

Specified by:
getPriority in interface Rule
Returns:
the priority

setPriority

public void setPriority(RulePriority priority)
Description copied from interface: Rule
Set the priority of this Rule.

Specified by:
setPriority in interface Rule
Parameters:
priority - the priority

getParserOptions

public ParserOptions getParserOptions()
Description copied from interface: Rule
Get the parser options for this Rule. Parser options are used to configure the Parser to create an AST in the form the Rule is expecting. Because ParserOptions are mutable, a Rule should return a new instance on each call.

Specified by:
getParserOptions in interface Rule
Returns:
the parser options

definePropertyDescriptor

public void definePropertyDescriptor(PropertyDescriptor<?> propertyDescriptor)
                              throws IllegalArgumentException
Description copied from interface: PropertySource
Define a new property via a PropertyDescriptor.

Specified by:
definePropertyDescriptor in interface PropertySource
Parameters:
propertyDescriptor - The property descriptor.
Throws:
IllegalArgumentException - If there is already a property defined the same name.

getPropertyDescriptor

public PropertyDescriptor<?> getPropertyDescriptor(String name)
Description copied from interface: PropertySource
Get the PropertyDescriptor for the given property name.

Specified by:
getPropertyDescriptor in interface PropertySource
Parameters:
name - The name of the property.
Returns:
The PropertyDescriptor for the named property, null if there is no such property defined.

getPropertyDescriptors

public List<PropertyDescriptor<?>> getPropertyDescriptors()
Description copied from interface: PropertySource
Get the PropertyDescriptors for all defined properties. The properties are returned sorted by UI order.

Specified by:
getPropertyDescriptors in interface PropertySource
Returns:
The PropertyDescriptors in UI order.

getProperty

public <T> T getProperty(PropertyDescriptor<T> propertyDescriptor)
Description copied from interface: PropertySource
Get the typed value for the given property.

Specified by:
getProperty in interface PropertySource
Type Parameters:
T - The underlying type of the property descriptor.
Parameters:
propertyDescriptor - The property descriptor.
Returns:
The property value.

setProperty

public <T> void setProperty(PropertyDescriptor<T> propertyDescriptor,
                            T value)
Description copied from interface: PropertySource
Set the property value specified (will be type-checked)

Specified by:
setProperty in interface PropertySource
Type Parameters:
T - The underlying type of the property descriptor.
Parameters:
propertyDescriptor - The property descriptor.
value - The value to set.

getPropertiesByPropertyDescriptor

public Map<PropertyDescriptor<?>,Object> getPropertiesByPropertyDescriptor()
Description copied from interface: PropertySource
Returns all the current property values for the receiver or an immutable empty map if none are specified.

Specified by:
getPropertiesByPropertyDescriptor in interface PropertySource
Returns:
all current property values or a empty map.

setUsesDFA

public void setUsesDFA()
Description copied from interface: Rule
Sets whether this Rule uses Data Flow Analysis.

Specified by:
setUsesDFA in interface Rule

usesDFA

public boolean usesDFA()
Description copied from interface: Rule
Gets whether this Rule uses Data Flow Analysis.

Specified by:
usesDFA in interface Rule
Returns:
true if Data Flow Analysis is used.

setUsesTypeResolution

public void setUsesTypeResolution()
Description copied from interface: Rule
Sets whether this Rule uses Type Resolution.

Specified by:
setUsesTypeResolution in interface Rule

usesTypeResolution

public boolean usesTypeResolution()
Description copied from interface: Rule
Gets whether this Rule uses Type Resolution.

Specified by:
usesTypeResolution in interface Rule
Returns:
true if Type Resolution is used.

usesRuleChain

public boolean usesRuleChain()
Description copied from interface: Rule
Gets whether this Rule uses the RuleChain.

Specified by:
usesRuleChain in interface Rule
Returns:
true if RuleChain is used.

getRuleChainVisits

public List<String> getRuleChainVisits()
Description copied from interface: Rule
Gets the collection of AST node names visited by the Rule on the RuleChain.

Specified by:
getRuleChainVisits in interface Rule
Returns:
the list of AST node names

addRuleChainVisit

public void addRuleChainVisit(Class<? extends Node> nodeClass)
Description copied from interface: Rule
Adds an AST node by class to be visited by the Rule on the RuleChain.

Specified by:
addRuleChainVisit in interface Rule
Parameters:
nodeClass - the AST node to add to the RuleChain visit list

addRuleChainVisit

public void addRuleChainVisit(String astNodeName)
Description copied from interface: Rule
Adds an AST node by name to be visited by the Rule on the RuleChain.

Specified by:
addRuleChainVisit in interface Rule
Parameters:
astNodeName - the AST node to add to the RuleChain visit list as string

start

public void start(RuleContext ctx)
Description copied from interface: Rule
Start processing. Called once, before apply() is first called.

Specified by:
start in interface Rule
Parameters:
ctx - the rule context

apply

public void apply(List<? extends Node> nodes,
                  RuleContext ctx)
Description copied from interface: Rule
Apply this rule to the given collection of nodes, using the given context.

Specified by:
apply in interface Rule
Parameters:
nodes - the nodes
ctx - the rule context

end

public void end(RuleContext ctx)
Description copied from interface: Rule
End processing. Called once, after apply() is last called.

Specified by:
end in interface Rule
Parameters:
ctx - the rule context

hasDescriptor

public boolean hasDescriptor(PropertyDescriptor<?> descriptor)
Description copied from interface: PropertySource
Returns whether this Rule has the specified PropertyDescriptor.

Specified by:
hasDescriptor in interface PropertySource
Parameters:
descriptor - The PropertyDescriptor for which to check.
Returns:
boolean true if the descriptor is present, false otherwise.
See Also:
PropertySource.hasDescriptor(PropertyDescriptor)


Copyright © 2002-2015 InfoEther. All Rights Reserved.