net.sourceforge.pmd

Class CommonAbstractRule

public abstract class CommonAbstractRule extends Object implements Rule

Basic abstract implementation of all parser-independent methods of the Rule interface.

Author: pieter_van_raemdonck - Application Engineers NV/SA - www.ae.be

Method Summary
voidaddExample(String example)
voidaddProperties(Properties properties)
voidaddProperty(String name, String value)
voidaddRuleChainVisit(String astNodeName)
protected voidaddViolation(Object data, SimpleNode node)
Adds a violation to the report.
protected voidaddViolation(Object data, SimpleNode node, String embed)
Adds a violation to the report.
protected voidaddViolation(Object data, Node node, Object[] args)
Adds a violation to the report.
protected voidaddViolationWithMessage(Object data, SimpleNode node, String msg)
Adds a violation to the report.
booleanequals(Object o)
Test if rules are equals.
booleangetBooleanProperty(String name)
StringgetDescription()
doublegetDoubleProperty(String name)
StringgetExample()
Still used by the JDeveloper plugin
List<String>getExamples()
StringgetExternalInfoUrl()
intgetIntProperty(String name)
StringgetMessage()
StringgetName()
intgetPriority()
StringgetPriorityName()
PropertiesgetProperties()
List<String>getRuleChainVisits()
StringgetRuleSetName()
StringgetStringProperty(String name)
inthashCode()
Return a hash code to conform to equality.
booleanhasProperty(String name)
booleaninclude()
PropertyDescriptorpropertyDescriptorFor(String name)
voidsetDescription(String description)
voidsetExternalInfoUrl(String url)
voidsetInclude(boolean include)
voidsetMessage(String message)
voidsetName(String name)
voidsetPriority(int priority)
voidsetRuleSetName(String ruleSetName)
voidsetUsesDFA()
voidsetUsesTypeResolution()
booleanusesDFA()
booleanusesRuleChain()
booleanusesTypeResolution()

Method Detail

addExample

public void addExample(String example)

addProperties

public void addProperties(Properties properties)

addProperty

public void addProperty(String name, String value)

addRuleChainVisit

public void addRuleChainVisit(String astNodeName)

addViolation

protected final void addViolation(Object data, SimpleNode node)
Adds a violation to the report.

Parameters: ctx the RuleContext node the node that produces the violation

addViolation

protected final void addViolation(Object data, SimpleNode node, String embed)
Adds a violation to the report.

Parameters: ctx the RuleContext node the node that produces the violation embed a variable to embed in the rule violation message

addViolation

protected final void addViolation(Object data, Node node, Object[] args)
Adds a violation to the report.

Parameters: ctx the RuleContext node the node that produces the violation, may be null, in which case all line and column info will be set to zero args objects to embed in the rule violation message

addViolationWithMessage

protected final void addViolationWithMessage(Object data, SimpleNode node, String msg)
Adds a violation to the report.

Parameters: ctx the RuleContext node the node that produces the violation msg specific message to put in the report

equals

public boolean equals(Object o)
Test if rules are equals. Rules are equals if 1. they have the same implementation class 2. they have the same name 3. they have the same priority 4. they share the same properties/values

getBooleanProperty

public boolean getBooleanProperty(String name)

getDescription

public String getDescription()

getDoubleProperty

public double getDoubleProperty(String name)

getExample

public String getExample()

Deprecated: use getExamples(), since we now support multiple examples

Still used by the JDeveloper plugin

getExamples

public List<String> getExamples()

getExternalInfoUrl

public String getExternalInfoUrl()

getIntProperty

public int getIntProperty(String name)

getMessage

public String getMessage()

getName

public String getName()

getPriority

public int getPriority()

getPriorityName

public String getPriorityName()

getProperties

public Properties getProperties()

getRuleChainVisits

public List<String> getRuleChainVisits()

getRuleSetName

public String getRuleSetName()

getStringProperty

public String getStringProperty(String name)

hashCode

public int hashCode()
Return a hash code to conform to equality. Try with a string.

hasProperty

public boolean hasProperty(String name)

include

public boolean include()

propertyDescriptorFor

public PropertyDescriptor propertyDescriptorFor(String name)

setDescription

public void setDescription(String description)

setExternalInfoUrl

public void setExternalInfoUrl(String url)

setInclude

public void setInclude(boolean include)

setMessage

public void setMessage(String message)

setName

public void setName(String name)

setPriority

public void setPriority(int priority)

setRuleSetName

public void setRuleSetName(String ruleSetName)

setUsesDFA

public void setUsesDFA()

setUsesTypeResolution

public void setUsesTypeResolution()

usesDFA

public boolean usesDFA()

usesRuleChain

public boolean usesRuleChain()

usesTypeResolution

public boolean usesTypeResolution()