net.sourceforge.pmd
Class CommonAbstractRule

java.lang.Object
  extended bynet.sourceforge.pmd.CommonAbstractRule
All Implemented Interfaces:
Rule
Direct Known Subclasses:
XPathRule

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
protected  java.lang.String description
           
protected  java.lang.String example
           
protected  java.lang.String externalInfoUrl
           
protected  boolean include
           
protected  java.lang.String message
           
protected  java.lang.String name
           
protected  int priority
           
protected  java.util.Properties properties
           
protected  java.lang.String ruleSetName
           
protected  boolean usesDFA
           
 
Fields inherited from interface net.sourceforge.pmd.Rule
LOWEST_PRIORITY, PRIORITIES
 
Constructor Summary
CommonAbstractRule()
           
 
Method Summary
 void addProperties(java.util.Properties properties)
           
 void addProperty(java.lang.String name, java.lang.String value)
           
protected  void addViolation(java.lang.Object data, Node node, java.lang.Object[] args)
          Adds a violation to the report.
protected  void addViolation(java.lang.Object data, SimpleNode node)
          Adds a violation to the report.
protected  void addViolation(java.lang.Object data, SimpleNode node, java.lang.String embed)
          Adds a violation to the report.
protected  void addViolationWithMessage(java.lang.Object data, SimpleNode node, java.lang.String msg)
          Adds a violation to the report.
 boolean equals(java.lang.Object o)
          Test if rules are equals.
 boolean getBooleanProperty(java.lang.String name)
           
 java.lang.String getDescription()
           
 double getDoubleProperty(java.lang.String name)
           
 java.lang.String getExample()
           
 java.lang.String getExternalInfoUrl()
           
 int getIntProperty(java.lang.String name)
           
 java.lang.String getMessage()
           
 java.lang.String getName()
           
 int getPriority()
           
 java.lang.String getPriorityName()
           
 java.util.Properties getProperties()
           
 java.lang.String getRuleSetName()
           
 java.lang.String getStringProperty(java.lang.String name)
           
 int hashCode()
          Return a hash code to conform to equality.
 boolean hasProperty(java.lang.String name)
           
 boolean include()
           
 void setDescription(java.lang.String description)
           
 void setExample(java.lang.String example)
           
 void setExternalInfoUrl(java.lang.String url)
           
 void setInclude(boolean include)
           
 void setMessage(java.lang.String message)
           
 void setName(java.lang.String name)
           
 void setPriority(int priority)
           
 void setRuleSetName(java.lang.String ruleSetName)
           
 void setUsesDFA()
           
 boolean usesDFA()
           
 
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
 

Field Detail

name

protected java.lang.String name

properties

protected java.util.Properties properties

message

protected java.lang.String message

description

protected java.lang.String description

example

protected java.lang.String example

ruleSetName

protected java.lang.String ruleSetName

include

protected boolean include

usesDFA

protected boolean usesDFA

priority

protected int priority

externalInfoUrl

protected java.lang.String externalInfoUrl
Constructor Detail

CommonAbstractRule

public CommonAbstractRule()
Method Detail

getRuleSetName

public java.lang.String getRuleSetName()
Specified by:
getRuleSetName in interface Rule

setRuleSetName

public void setRuleSetName(java.lang.String ruleSetName)
Specified by:
setRuleSetName in interface Rule

getDescription

public java.lang.String getDescription()
Specified by:
getDescription in interface Rule

setDescription

public void setDescription(java.lang.String description)
Specified by:
setDescription in interface Rule

getExample

public java.lang.String getExample()
Specified by:
getExample in interface Rule

setExample

public void setExample(java.lang.String example)
Specified by:
setExample in interface Rule

hasProperty

public boolean hasProperty(java.lang.String name)
Specified by:
hasProperty in interface Rule

addProperty

public void addProperty(java.lang.String name,
                        java.lang.String value)
Specified by:
addProperty in interface Rule

addProperties

public void addProperties(java.util.Properties properties)
Specified by:
addProperties in interface Rule

getDoubleProperty

public double getDoubleProperty(java.lang.String name)
Specified by:
getDoubleProperty in interface Rule

getIntProperty

public int getIntProperty(java.lang.String name)
Specified by:
getIntProperty in interface Rule

getBooleanProperty

public boolean getBooleanProperty(java.lang.String name)
Specified by:
getBooleanProperty in interface Rule

getStringProperty

public java.lang.String getStringProperty(java.lang.String name)
Specified by:
getStringProperty in interface Rule

getName

public java.lang.String getName()
Specified by:
getName in interface Rule

setName

public void setName(java.lang.String name)
Specified by:
setName in interface Rule

getMessage

public java.lang.String getMessage()
Specified by:
getMessage in interface Rule

setMessage

public void setMessage(java.lang.String message)
Specified by:
setMessage in interface Rule

getExternalInfoUrl

public java.lang.String getExternalInfoUrl()
Specified by:
getExternalInfoUrl in interface Rule

setExternalInfoUrl

public void setExternalInfoUrl(java.lang.String url)
Specified by:
setExternalInfoUrl in interface Rule

equals

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


hashCode

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


getProperties

public java.util.Properties getProperties()
Specified by:
getProperties in interface Rule

include

public boolean include()
Specified by:
include in interface Rule

setInclude

public void setInclude(boolean include)
Specified by:
setInclude in interface Rule

getPriority

public int getPriority()
Specified by:
getPriority in interface Rule

getPriorityName

public java.lang.String getPriorityName()
Specified by:
getPriorityName in interface Rule

setPriority

public void setPriority(int priority)
Specified by:
setPriority in interface Rule

setUsesDFA

public void setUsesDFA()
Specified by:
setUsesDFA in interface Rule

usesDFA

public boolean usesDFA()
Specified by:
usesDFA in interface Rule

addViolation

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

Parameters:
node - the node that produces the violation

addViolationWithMessage

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

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

addViolation

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

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

addViolation

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

Parameters:
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


Copyright © 2002-2006 InfoEther. All Rights Reserved.