net.sourceforge.pmd
Class AbstractRule
java.lang.Object
net.sourceforge.pmd.ast.JavaParserVisitorAdapter
net.sourceforge.pmd.AbstractRule
- All Implemented Interfaces:
- JavaParserVisitor, Rule
- Direct Known Subclasses:
- AbstractOptimizationRule, AbstractSunSecureRule, AccessorClassGeneration, AssignmentToNonFinalStatic, AvoidCatchingThrowable, AvoidConcatenatingNonLiteralsInStringBuffer, AvoidDeeplyNestedIfStmtsRule, AvoidDuplicateLiteralsRule, AvoidFieldNameMatchingMethodName, AvoidFieldNameMatchingTypeName, AvoidNonConstructorMethodsWithClassName, AvoidReassigningParameters, BeanMembersShouldSerializeRule, ClassNamingConventions, CloseConnection, CompareObjectsWithEquals, ConfusingTernary, ConstructorCallsOverridableMethod, CouplingBetweenObjects, CyclomaticComplexity, DaaRule, DFAGraphRule, DoubleCheckedLocking, DuplicateImportsRule, EmptyIf, ExceptionAsFlowControl, ExceptionSignatureDeclaration, ExceptionTypeChecking, IdempotentOperations, ImmutableField, ImportFromSamePackageRule, JUnitAssertionsShouldIncludeMessage, JUnitTestsShouldContainAsserts, LooseCoupling, MethodNamingConventions, MethodWithSameNameAsEnclosingClass, NullAssignmentRule, OnlyOneReturnRule, PositionalIteratorRule, PositionLiteralsFirstInComparisons, SimplifyBooleanReturns, SingularField, StatisticalRule, StringConcatenationRule, StringInstantiation, StringToStringRule, SuspiciousOctalEscape, SymbolTableTestRule, TestClassWithoutTestCases, TooManyFields, UnnecessaryCaseChange, UnnecessaryConversionTemporary, UnnecessaryLocalBeforeReturn, UnusedFormalParameterRule, UnusedImportsRule, UnusedLocalVariableRule, UnusedModifier, UnusedPrivateFieldRule, UnusedPrivateMethodRule, UselessAssignment, UselessOverridingMethod, UseSingleton, VariableNamingConventions, XPathRule
- public abstract class AbstractRule
- extends JavaParserVisitorAdapter
- implements Rule
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,
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. |
void |
apply(java.util.List acus,
RuleContext ctx)
|
RuleViolation |
createRuleViolation(RuleContext ctx,
SimpleNode node)
|
RuleViolation |
createRuleViolation(RuleContext ctx,
SimpleNode node,
java.lang.String specificDescription)
|
RuleViolation |
createRuleViolation(RuleContext ctx,
SimpleNode node,
java.lang.String variableName,
java.lang.String specificDescription)
|
boolean |
equals(java.lang.Object o)
Test if rules are equals. |
boolean |
getBooleanProperty(java.lang.String name)
|
protected java.lang.String |
getDeclaringType(SimpleNode node)
Gets the Image of the first parent node of type ASTClassOrInterfaceDeclaration or null |
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()
|
protected void |
visitAll(java.util.List acus,
RuleContext ctx)
|
Methods inherited from class net.sourceforge.pmd.ast.JavaParserVisitorAdapter |
visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
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
AbstractRule
public AbstractRule()
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.
apply
public void apply(java.util.List acus,
RuleContext ctx)
- Specified by:
apply
in interface Rule
createRuleViolation
public RuleViolation createRuleViolation(RuleContext ctx,
SimpleNode node)
createRuleViolation
public RuleViolation createRuleViolation(RuleContext ctx,
SimpleNode node,
java.lang.String specificDescription)
createRuleViolation
public RuleViolation createRuleViolation(RuleContext ctx,
SimpleNode node,
java.lang.String variableName,
java.lang.String specificDescription)
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
visitAll
protected void visitAll(java.util.List acus,
RuleContext ctx)
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, may be null, in which case all line and column info will be set to zero
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, may be null, in which case all line and column info will be set to zeroembed
- a message to embed in the rule violation message
getDeclaringType
protected final java.lang.String getDeclaringType(SimpleNode node)
- Gets the Image of the first parent node of type ASTClassOrInterfaceDeclaration or
null
- Parameters:
node
- the node which will be searched
Copyright © 2002-2005 InfoEther. All Rights Reserved.