net.sourceforge.pmd.lang.rule
Class XPathRule
java.lang.Object
net.sourceforge.pmd.AbstractPropertySource
net.sourceforge.pmd.lang.rule.AbstractRule
net.sourceforge.pmd.lang.rule.XPathRule
- All Implemented Interfaces:
- PropertySource, Rule
public class XPathRule
- extends AbstractRule
Rule that tries to match an XPath expression against a DOM view of an AST.
This rule needs a "xpath" property value in order to function.
Methods inherited from class net.sourceforge.pmd.lang.rule.AbstractRule |
addExample, addRuleChainVisit, addRuleChainVisit, addViolation, addViolation, addViolation, addViolationWithMessage, addViolationWithMessage, addViolationWithMessage, deepCopyValuesTo, end, equals, getDescription, getExamples, getExternalInfoUrl, getLanguage, getMaximumLanguageVersion, getMessage, getMinimumLanguageVersion, getName, getParserOptions, getPriority, getRuleClass, getRuleSetName, getSince, hashCode, isDeprecated, setDeprecated, setDescription, setExternalInfoUrl, setLanguage, setMaximumLanguageVersion, setMessage, setMinimumLanguageVersion, setName, setPriority, setRuleClass, setRuleSetName, setSince, setUsesDFA, setUsesTypeResolution, start, usesDFA, usesRuleChain, usesTypeResolution |
Methods inherited from class net.sourceforge.pmd.AbstractPropertySource |
copyPropertyDescriptors, copyPropertyValues, definePropertyDescriptor, getPropertiesByPropertyDescriptor, getProperty, getPropertyDescriptor, getPropertyDescriptors, hasDescriptor, ignoredProperties, setProperty, useDefaultValueFor, usesDefaultValues |
XPATH_DESCRIPTOR
public static final StringProperty XPATH_DESCRIPTOR
VERSION_DESCRIPTOR
public static final EnumeratedProperty<String> VERSION_DESCRIPTOR
XPathRule
public XPathRule()
XPathRule
public XPathRule(String xPath)
setXPath
public void setXPath(String xPath)
setVersion
public void setVersion(String version)
apply
public void apply(List<? extends Node> nodes,
RuleContext ctx)
- Apply the rule to all nodes.
- Parameters:
nodes
- the nodesctx
- the rule context
evaluate
public void evaluate(Node node,
RuleContext data)
- Evaluate the XPath query with the AST node.
All matches are reported as violations.
- Parameters:
node
- The Node that to be checked.data
- The RuleContext.
getRuleChainVisits
public List<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
- Overrides:
getRuleChainVisits
in class AbstractRule
- Returns:
- the list of AST node names
- See Also:
Rule.getRuleChainVisits()
hasXPathExpression
public boolean hasXPathExpression()
dysfunctionReason
public String dysfunctionReason()
- Description copied from class:
AbstractPropertySource
- Returns 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:
dysfunctionReason
in interface PropertySource
- Overrides:
dysfunctionReason
in class AbstractPropertySource
- Returns:
- String
- See Also:
PropertySource.dysfunctionReason()
Copyright © 2002-2015 InfoEther. All Rights Reserved.