Class XPathRule
java.lang.Object
net.sourceforge.pmd.properties.AbstractPropertySource
net.sourceforge.pmd.lang.rule.AbstractRule
net.sourceforge.pmd.lang.rule.xpath.XPathRule
- All Implemented Interfaces:
Rule,PropertySource
Rule that tries to match an XPath expression against a DOM view of an AST.
-
Field Summary
Fields inherited from interface net.sourceforge.pmd.lang.rule.Rule
VIOLATION_SUPPRESS_REGEX_DESCRIPTOR, VIOLATION_SUPPRESS_XPATH_DESCRIPTOR -
Constructor Summary
ConstructorsConstructorDescriptionXPathRule(XPathVersion version, String expression) Make a new XPath rule with the given version + expression -
Method Summary
Modifier and TypeMethodDescriptionvoidapply(Node target, RuleContext ctx) Process the given node.protected @NonNull RuleTargetSelectorCreate the targeting strategy for this rule.deepCopy()Creates a new copy of this rule.Returns a description of why the receiver may be dysfunctional.Returns the XPath expression that implements this rule.voidinitialize(LanguageProcessor languageProcessor) Initialize the rule using the language processor if needed.Methods inherited from class net.sourceforge.pmd.lang.rule.AbstractRule
addExample, asCtx, end, equals, getDescription, getExamples, getExternalInfoUrl, getLanguage, getMaximumLanguageVersion, getMessage, getMinimumLanguageVersion, getName, getPriority, getPropertySourceType, getRuleClass, getRuleSetName, getSince, getTargetSelector, hashCode, isDeprecated, setDeprecated, setDescription, setExternalInfoUrl, setLanguage, setMaximumLanguageVersion, setMessage, setMinimumLanguageVersion, setName, setPriority, setRuleClass, setRuleSetName, setSince, startMethods inherited from class net.sourceforge.pmd.properties.AbstractPropertySource
definePropertyDescriptor, getOverriddenPropertiesByPropertyDescriptor, getOverriddenPropertyDescriptors, getPropertiesByPropertyDescriptor, getProperty, getPropertyDescriptor, getPropertyDescriptors, hasDescriptor, isPropertyOverridden, setPropertyMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.sourceforge.pmd.properties.PropertySource
definePropertyDescriptor, getOverriddenPropertiesByPropertyDescriptor, getOverriddenPropertyDescriptors, getPropertiesByPropertyDescriptor, getProperty, getPropertyDescriptor, getPropertyDescriptors, hasDescriptor, isPropertyOverridden, setProperty
-
Constructor Details
-
XPathRule
Make a new XPath rule with the given version + expression- Parameters:
version- Version of the XPath languageexpression- XPath expression- Throws:
NullPointerException- If any of the arguments is null
-
-
Method Details
-
deepCopy
Description copied from interface:RuleCreates a new copy of this rule.- Specified by:
deepCopyin interfaceRule- Overrides:
deepCopyin classAbstractRule- Returns:
- A new exact copy of this rule
-
getXPathExpression
Returns the XPath expression that implements this rule. -
apply
Description copied from interface:RuleProcess the given node. The nodes that are fed to this method are the nodes selected byRule.getTargetSelector().- Parameters:
target- Node on which to apply the rulectx- Rule context, handling violations
-
initialize
Description copied from interface:RuleInitialize the rule using the language processor if needed.- Parameters:
languageProcessor- The processor for the rule's language
-
buildTargetSelector
Description copied from class:AbstractRuleCreate the targeting strategy for this rule. Use the factory methods ofRuleTargetSelector.- Overrides:
buildTargetSelectorin classAbstractRule
-
dysfunctionReason
Description copied from interface:PropertySourceReturns a description of why the receiver may be dysfunctional. Usually due to missing property values or some kind of conflict between values. Returns null if the receiver is ok.- Specified by:
dysfunctionReasonin interfacePropertySource- Overrides:
dysfunctionReasonin classAbstractRule- Returns:
- String
-