net.sourceforge.pmd
Class CommonAbstractRule

java.lang.Object
  extended by net.sourceforge.pmd.CommonAbstractRule
All Implemented Interfaces:
Rule
Direct Known Subclasses:
AbstractJavaRule, AbstractJspRule

public abstract class CommonAbstractRule
extends java.lang.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

Field Summary
 
Fields inherited from interface net.sourceforge.pmd.Rule
LOWEST_PRIORITY, PRIORITIES
 
Constructor Summary
CommonAbstractRule()
           
 
Method Summary
 void addExample(java.lang.String example)
          Add a single example for this Rule.
 void addProperties(java.util.Properties properties)
          Deprecated.  
 void addProperty(java.lang.String name, java.lang.String value)
          Deprecated.  
 void addRuleChainVisit(java.lang.String astNodeName)
          Adds an AST node name to be visited by the Rule on the RuleChain.
protected static java.util.Map<java.lang.String,PropertyDescriptor> asFixedMap(PropertyDescriptor descriptor)
           
protected static java.util.Map<java.lang.String,PropertyDescriptor> asFixedMap(PropertyDescriptor[] descriptors)
           
 void end(RuleContext ctx)
          End processing.
 boolean equals(java.lang.Object o)
          Rules are equal if: They have the same implementation class. They have the same name. They have the same priority. They share the same properties.
 boolean[] getBooleanProperties(PropertyDescriptor descriptor)
           
 boolean getBooleanProperty(PropertyDescriptor descriptor)
           
 boolean getBooleanProperty(java.lang.String name)
          Deprecated. - use getBooleanProperty(PropertyDescriptor) instead
 java.lang.String getDescription()
          Get the description of this Rule.
 double[] getDoubleProperties(PropertyDescriptor descriptor)
           
 double getDoubleProperty(PropertyDescriptor descriptor)
           
 double getDoubleProperty(java.lang.String name)
          Deprecated. - use getDoubleProperty(PropertyDescriptor) instead
 java.lang.String getExample()
          Still used by the JDeveloper plugin
 java.util.List<java.lang.String> getExamples()
          Get the list of examples for this Rule.
 java.lang.String getExternalInfoUrl()
          Get a URL for external information about this Rule.
 int[] getIntProperties(PropertyDescriptor descriptor)
           
 int getIntProperty(PropertyDescriptor descriptor)
           
 int getIntProperty(java.lang.String name)
          Deprecated. - use getIntProperty(PropertyDescriptor) instead
 java.lang.String getMessage()
          Get the message to show when this Rule identifies a violation.
 java.lang.String getName()
          Get the name of this Rule.
 int getPriority()
          Get the priority of this Rule.
 java.lang.String getPriorityName()
          Get a name for the priority of this Rule.
 java.util.Properties getProperties()
          Deprecated. - retrieve by name using getProperty or getProperties
 java.util.List<java.lang.String> getRuleChainVisits()
          Gets the collection of AST node names visited by the Rule on the RuleChain.
 java.lang.String getRuleClass()
          Get the class of this Rule.
 java.lang.String getRuleSetName()
          Get the name of the RuleSet containing this Rule.
 java.lang.String getSince()
          Get the version of PMD in which this Rule was added.
 java.lang.String[] getStringProperties(PropertyDescriptor descriptor)
           
 java.lang.String getStringProperty(PropertyDescriptor descriptor)
           
 java.lang.String getStringProperty(java.lang.String name)
          Deprecated. - use getStringProperty(PropertyDescriptor) instead
 java.lang.Class[] getTypeProperties(PropertyDescriptor descriptor)
           
 java.lang.Class getTypeProperty(PropertyDescriptor descriptor)
           
 int hashCode()
           
 boolean hasProperty(java.lang.String name)
          Deprecated. - property values will be guaranteed available via default values
 boolean include()
          TODO What is this?
protected  java.util.Map<java.lang.String,PropertyDescriptor> propertiesByName()
          Return all the relevant properties for the receiver by overriding in subclasses as necessary.
 PropertyDescriptor propertyDescriptorFor(java.lang.String name)
          Get the PropertyDescriptor for the given property.
 void setDescription(java.lang.String description)
          Set the description of this Rule.
 void setExternalInfoUrl(java.lang.String externalInfoUrl)
          Set a URL for external information about this Rule.
 void setInclude(boolean include)
          TODO What is this?
 void setMessage(java.lang.String message)
          Set the message to show when this Rule identifies a violation.
 void setName(java.lang.String name)
          Set the name of this Rule.
 void setPriority(int priority)
          Set the priority of this Rule.
 void setProperties(PropertyDescriptor descriptor, java.lang.Object[] values)
           
 void setProperty(PropertyDescriptor descriptor, java.lang.Object value)
           
 void setRuleClass(java.lang.String ruleClass)
          Set the class of this Rule.
 void setRuleSetName(java.lang.String ruleSetName)
          Set the name of the RuleSet containing this Rule.
 void setSince(java.lang.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, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.sourceforge.pmd.Rule
apply
 

Constructor Detail

CommonAbstractRule

public CommonAbstractRule()
Method Detail

getName

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

Specified by:
getName in interface Rule

setName

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

Specified by:
setName in interface Rule

getSince

public java.lang.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

setSince

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

Specified by:
setSince in interface Rule

getRuleClass

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

Specified by:
getRuleClass in interface Rule

setRuleClass

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

Specified by:
setRuleClass in interface Rule

getRuleSetName

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

Specified by:
getRuleSetName in interface Rule
See Also:
RuleSet

setRuleSetName

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

Specified by:
setRuleSetName in interface Rule
See Also:
RuleSet

getMessage

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

Specified by:
getMessage in interface Rule

setMessage

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

Specified by:
setMessage in interface Rule

getDescription

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

Specified by:
getDescription in interface Rule

setDescription

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

Specified by:
setDescription in interface Rule

getExamples

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

Specified by:
getExamples in interface Rule

getExample

public java.lang.String getExample()
Description copied from interface: Rule
Still used by the JDeveloper plugin

Specified by:
getExample in interface Rule

addExample

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

Specified by:
addExample in interface Rule

getExternalInfoUrl

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

Specified by:
getExternalInfoUrl in interface Rule

setExternalInfoUrl

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

Specified by:
setExternalInfoUrl in interface Rule

getPriority

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

Specified by:
getPriority in interface Rule

setPriority

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

Specified by:
setPriority in interface Rule

getPriorityName

public java.lang.String getPriorityName()
Description copied from interface: Rule
Get a name for the priority of this Rule.

Specified by:
getPriorityName in interface Rule

include

public boolean include()
Description copied from interface: Rule
TODO What is this?

Specified by:
include in interface Rule

setInclude

public void setInclude(boolean include)
Description copied from interface: Rule
TODO What is this?

Specified by:
setInclude in interface Rule

getProperties

public java.util.Properties getProperties()
Deprecated. - retrieve by name using getProperty or getProperties

Description copied from interface: Rule
Get all properties for this Rule.

Specified by:
getProperties in interface Rule
Returns:
the properties for the rule

addProperty

public void addProperty(java.lang.String name,
                        java.lang.String value)
Deprecated. 

Description copied from interface: Rule
Add a specific property to this Rule.

Specified by:
addProperty in interface Rule

addProperties

public void addProperties(java.util.Properties properties)
Deprecated. 

Description copied from interface: Rule
Add a set of properties to this Rule.

Specified by:
addProperties in interface Rule

hasProperty

public boolean hasProperty(java.lang.String name)
Deprecated. - property values will be guaranteed available via default values

Description copied from interface: Rule
Get whether this Rule has a property of the given name.

Specified by:
hasProperty in interface Rule

getBooleanProperty

public boolean getBooleanProperty(java.lang.String name)
Deprecated. - use getBooleanProperty(PropertyDescriptor) instead

Description copied from interface: Rule
Get the boolean value for the given property.

Specified by:
getBooleanProperty in interface Rule

getBooleanProperty

public boolean getBooleanProperty(PropertyDescriptor descriptor)

getBooleanProperties

public boolean[] getBooleanProperties(PropertyDescriptor descriptor)

getIntProperty

public int getIntProperty(java.lang.String name)
Deprecated. - use getIntProperty(PropertyDescriptor) instead

Description copied from interface: Rule
Get the int value for the given property.

Specified by:
getIntProperty in interface Rule

getIntProperty

public int getIntProperty(PropertyDescriptor descriptor)

getIntProperties

public int[] getIntProperties(PropertyDescriptor descriptor)

getDoubleProperty

public double getDoubleProperty(java.lang.String name)
Deprecated. - use getDoubleProperty(PropertyDescriptor) instead

Description copied from interface: Rule
Get the double value for the given property.

Specified by:
getDoubleProperty in interface Rule

getDoubleProperty

public double getDoubleProperty(PropertyDescriptor descriptor)

getDoubleProperties

public double[] getDoubleProperties(PropertyDescriptor descriptor)

getStringProperty

public java.lang.String getStringProperty(java.lang.String name)
Deprecated. - use getStringProperty(PropertyDescriptor) instead

Description copied from interface: Rule
Get the java.util.String value for the given property.

Specified by:
getStringProperty in interface Rule

getStringProperty

public java.lang.String getStringProperty(PropertyDescriptor descriptor)

getStringProperties

public java.lang.String[] getStringProperties(PropertyDescriptor descriptor)

getTypeProperties

public java.lang.Class[] getTypeProperties(PropertyDescriptor descriptor)

getTypeProperty

public java.lang.Class getTypeProperty(PropertyDescriptor descriptor)

setProperty

public void setProperty(PropertyDescriptor descriptor,
                        java.lang.Object value)

setProperties

public void setProperties(PropertyDescriptor descriptor,
                          java.lang.Object[] values)

propertiesByName

protected java.util.Map<java.lang.String,PropertyDescriptor> propertiesByName()
Return all the relevant properties for the receiver by overriding in subclasses as necessary.

Returns:
Map

propertyDescriptorFor

public PropertyDescriptor propertyDescriptorFor(java.lang.String name)
Description copied from interface: Rule
Get the PropertyDescriptor for the given property.

Specified by:
propertyDescriptorFor in interface Rule

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

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

usesRuleChain

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

Specified by:
usesRuleChain in interface Rule

getRuleChainVisits

public java.util.List<java.lang.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

addRuleChainVisit

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

Specified by:
addRuleChainVisit in interface Rule

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

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

equals

public boolean equals(java.lang.Object o)
Rules are equal 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.

Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object
See Also:
equals(Object)

asFixedMap

protected static java.util.Map<java.lang.String,PropertyDescriptor> asFixedMap(PropertyDescriptor[] descriptors)

asFixedMap

protected static java.util.Map<java.lang.String,PropertyDescriptor> asFixedMap(PropertyDescriptor descriptor)


Copyright © 2002-2011 InfoEther. All Rights Reserved.