net.sourceforge.pmd
Interface Rule

All Known Implementing Classes:
AbstractDelegateRule, AbstractInefficientZeroCheck, AbstractJavaRule, AbstractJspRule, AbstractJUnitRule, AbstractNcssCount, AbstractOptimizationRule, AbstractPoorMethodCall, AbstractRule, AbstractSunSecureRule, AccessorClassGeneration, AppendCharacterWithChar, ArrayIsStoredDirectly, AssignmentInOperand, AssignmentToNonFinalStatic, AvoidCallingFinalize, AvoidCatchingThrowable, AvoidDeeplyNestedIfStmtsRule, AvoidDollarSigns, AvoidDuplicateLiteralsRule, AvoidFieldNameMatchingMethodName, AvoidFieldNameMatchingTypeName, AvoidInstantiatingObjectsInLoops, AvoidMultipleUnaryOperators, AvoidNonConstructorMethodsWithClassName, AvoidReassigningParameters, AvoidUsingHardCodedIP, AvoidUsingOctalValues, BeanMembersShouldSerializeRule, BigIntegerInstantiation, BooleanInstantiation, BrokenNullCheck, ClassNamingConventions, CloneMethodMustImplementCloneable, CloseResource, CommonAbstractRule, CompareObjectsWithEquals, ConfusingTernary, ConsecutiveLiteralAppends, ConstructorCallsOverridableMethod, CouplingBetweenObjects, CyclomaticComplexity, DaaRule, DFAGraphRule, DontImportJavaLang, DontImportSun, DoubleCheckedLocking, DuplicateImportsRule, DuplicateJspImports, ExceptionAsFlowControl, ExceptionSignatureDeclaration, ExcessiveImports, ExcessiveLengthRule, ExcessiveNodeCountRule, ExcessivePublicCount, GenericClassCounterRule, GenericLiteralCheckerRule, IdempotentOperations, ImmutableField, ImportFromSamePackageRule, InefficientEmptyStringCheck, InefficientStringBuffering, InsufficientStringBufferDeclaration, JUnitAssertionsShouldIncludeMessage, JUnitTestsShouldContainAsserts, JUnitUseExpected, LocalVariableCouldBeFinal, LongClassRule, LongMethodRule, LongParameterListRule, LooseCoupling, LooseCoupling, MethodArgumentCouldBeFinal, MethodNamingConventions, MethodReturnsInternalArray, MethodWithSameNameAsEnclosingClass, MockRule, MoreThanOneLogger, NcssConstructorCount, NcssMethodCount, NcssTypeCount, NoInlineStyleInformation, NonThreadSafeSingleton, NpathComplexity, NullAssignmentRule, OnlyOneReturnRule, OverrideBothEqualsAndHashcode, PositionalIteratorRule, PreserveStackTrace, RuleReference, SignatureDeclareThrowsException, SimplifyBooleanReturns, SingularField, StatisticalRule, StringConcatenationRule, StringInstantiation, StringToStringRule, SuspiciousHashcodeMethodName, SuspiciousOctalEscape, SwitchDensityRule, SymbolTableTestRule, TestClassWithoutTestCases, TooManyFields, UnnecessaryCaseChange, UnnecessaryCast, UnnecessaryConversionTemporary, UnnecessaryLocalBeforeReturn, UnnecessaryReturn, UnnecessaryWrapperObjectCreation, UnsynchronizedStaticDateFormatter, UnusedFormalParameterRule, UnusedImports, UnusedImportsRule, UnusedLocalVariableRule, UnusedModifier, UnusedPrivateFieldRule, UnusedPrivateMethodRule, UseCollectionIsEmpty, UseIndexOfChar, UselessAssignment, UselessOperationOnImmutable, UselessOverridingMethod, UselessStringValueOf, UseSingleton, UseStringBufferForStringAppends, UseStringBufferLength, VariableNamingConventions, XPathRule

public interface Rule

This is the basic Rule interface for PMD rules.


Field Summary
static int LOWEST_PRIORITY
           
static java.lang.String[] PRIORITIES
           
 
Method Summary
 void addExample(java.lang.String example)
          Add a single example for this Rule.
 void addProperties(java.util.Properties properties)
          Add a set of properties to this Rule.
 void addProperty(java.lang.String name, java.lang.String property)
          Add a specific property to this Rule.
 void addRuleChainVisit(java.lang.String astNodeName)
          Adds an AST node name to be visited by the Rule on the RuleChain.
 void apply(java.util.List<?> astCompilationUnits, RuleContext ctx)
          Apply this rule to the given collection of compilation units, using the given context.
 void end(RuleContext ctx)
          End processing.
 boolean getBooleanProperty(java.lang.String name)
          Get the boolean value for the given property.
 java.lang.String getDescription()
          Get the description of this Rule.
 double getDoubleProperty(java.lang.String name)
          Get the double value for the given property.
 java.lang.String getExample()
          Deprecated. use getExamples(), since we now support multiple examples
 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 getIntProperty(java.lang.String name)
          Get the int value for the given property.
 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()
          Get all properties for this Rule.
 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 getStringProperty(java.lang.String name)
          Get the java.util.String value for the given property.
 boolean hasProperty(java.lang.String name)
          Get whether this Rule has a property of the given name.
 boolean include()
          Deprecated. Don't know what this is for, so deprecating it.
 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)
          Deprecated. Don't know what this is for, so deprecating it.
 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 setRuleClass(java.lang.String ruleClass)
          Set the class of this Rule.
 void setRuleSetName(java.lang.String name)
          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.
 

Field Detail

LOWEST_PRIORITY

static final int LOWEST_PRIORITY
See Also:
Constant Field Values

PRIORITIES

static final java.lang.String[] PRIORITIES
Method Detail

getName

java.lang.String getName()
Get the name of this Rule.


setName

void setName(java.lang.String name)
Set the name of this Rule.


getSince

java.lang.String getSince()
Get the version of PMD in which this Rule was added. Return null if not applicable.


setSince

void setSince(java.lang.String since)
Set the version of PMD in which this Rule was added.


getRuleClass

java.lang.String getRuleClass()
Get the class of this Rule.


setRuleClass

void setRuleClass(java.lang.String ruleClass)
Set the class of this Rule.


getRuleSetName

java.lang.String getRuleSetName()
Get the name of the RuleSet containing this Rule.

See Also:
RuleSet

setRuleSetName

void setRuleSetName(java.lang.String name)
Set the name of the RuleSet containing this Rule.

See Also:
RuleSet

getMessage

java.lang.String getMessage()
Get the message to show when this Rule identifies a violation.


setMessage

void setMessage(java.lang.String message)
Set the message to show when this Rule identifies a violation.


getDescription

java.lang.String getDescription()
Get the description of this Rule.


setDescription

void setDescription(java.lang.String description)
Set the description of this Rule.


getExamples

java.util.List<java.lang.String> getExamples()
Get the list of examples for this Rule.


getExample

java.lang.String getExample()
Deprecated. use getExamples(), since we now support multiple examples

Still used by the JDeveloper plugin


addExample

void addExample(java.lang.String example)
Add a single example for this Rule.


getExternalInfoUrl

java.lang.String getExternalInfoUrl()
Get a URL for external information about this Rule.


setExternalInfoUrl

void setExternalInfoUrl(java.lang.String externalInfoUrl)
Set a URL for external information about this Rule.


getPriority

int getPriority()
Get the priority of this Rule.


setPriority

void setPriority(int priority)
Set the priority of this Rule.


getPriorityName

java.lang.String getPriorityName()
Get a name for the priority of this Rule.


include

boolean include()
Deprecated. Don't know what this is for, so deprecating it.

TODO What is this?


setInclude

void setInclude(boolean include)
Deprecated. Don't know what this is for, so deprecating it.

TODO What is this?


getProperties

java.util.Properties getProperties()
Get all properties for this Rule.

Returns:
the properties for the rule

addProperty

void addProperty(java.lang.String name,
                 java.lang.String property)
Add a specific property to this Rule.


addProperties

void addProperties(java.util.Properties properties)
Add a set of properties to this Rule.


hasProperty

boolean hasProperty(java.lang.String name)
Get whether this Rule has a property of the given name.


getBooleanProperty

boolean getBooleanProperty(java.lang.String name)
Get the boolean value for the given property.


getIntProperty

int getIntProperty(java.lang.String name)
Get the int value for the given property.


getDoubleProperty

double getDoubleProperty(java.lang.String name)
Get the double value for the given property.


getStringProperty

java.lang.String getStringProperty(java.lang.String name)
Get the java.util.String value for the given property.


propertyDescriptorFor

PropertyDescriptor propertyDescriptorFor(java.lang.String name)
Get the PropertyDescriptor for the given property.


setUsesDFA

void setUsesDFA()
Sets whether this Rule uses Data Flow Analysis.


usesDFA

boolean usesDFA()
Gets whether this Rule uses Data Flow Analysis.


setUsesTypeResolution

void setUsesTypeResolution()
Sets whether this Rule uses Type Resolution.


usesTypeResolution

boolean usesTypeResolution()
Gets whether this Rule uses Type Resolution.


usesRuleChain

boolean usesRuleChain()
Gets whether this Rule uses the RuleChain.


getRuleChainVisits

java.util.List<java.lang.String> getRuleChainVisits()
Gets the collection of AST node names visited by the Rule on the RuleChain.


addRuleChainVisit

void addRuleChainVisit(java.lang.String astNodeName)
Adds an AST node name to be visited by the Rule on the RuleChain.


start

void start(RuleContext ctx)
Start processing. Called once, before apply() is first called.


apply

void apply(java.util.List<?> astCompilationUnits,
           RuleContext ctx)
Apply this rule to the given collection of compilation units, using the given context.


end

void end(RuleContext ctx)
End processing. Called once, after apply() is last called.



Copyright © 2002-2011 InfoEther. All Rights Reserved.