Class XPathEvaluator


  • public final class XPathEvaluator
    extends Object
    Evaluates XPath expressions.
    Since:
    6.0.0
    Author:
    Clément Fournier
    • Method Detail

      • simpleEvaluate

        public static List<net.sourceforge.pmd.lang.ast.Node> simpleEvaluate​(DesignerRoot root,
                                                                             String query)
        Evaluates the query with default parameters on the global compilation unit and with the global language version. This method hides errors.
        Returns:
        The results, or an empty list if there was an error
      • evaluateQuery

        public static List<net.sourceforge.pmd.lang.ast.Node> evaluateQuery​(net.sourceforge.pmd.lang.ast.Node compilationUnit,
                                                                            net.sourceforge.pmd.lang.rule.xpath.XPathVersion xpathVersion,
                                                                            String xpathQuery,
                                                                            Map<String,​String> propertyValues,
                                                                            List<PropertyDescriptorSpec> properties)
                                                                     throws XPathEvaluationException
        Evaluates an XPath query on the compilation unit. Performs no side effects.
        Parameters:
        compilationUnit - AST root
        xpathVersion - XPath version
        xpathQuery - XPath query
        properties - Properties of the rule
        Throws:
        XPathEvaluationException - if there was an error during the evaluation. The cause is preserved