Class XPathFilter

java.lang.Object
com.onwbp.adaptation.XPathFilter

public final class XPathFilter extends Object
Defines an XPath predicate. The factory methods allow internal caching for a better performance.

Code sample:

 XPathFilter xpf = XPathFilter.newFilter("./field=$param");

 Request request = tableA.createRequest();
 request.setXPathFilter(xpf);
 request.setXPathParameter("param", "A");
 request.execute();

 request = tableB.createRequest();
 request.setXPathFilter(xpf);
 request.setXPathParameter("param", "B");
 request.execute();
 
Since:
5.7.0
See Also:
  • Method Details

    • newFilter

      public static XPathFilter newFilter(String aPredicateExpression)
      Builds a cache-enabled XPath predicate.

      This method is equivalent to:

       XPathFilter.newFilter(true, aPredicateExpression);
       

      Warning: if many cached predicates with quite specific values are cached, and are not often reused, the memory cost could counter-balance the performance gain.

      See Also:
    • newFilter

      public static XPathFilter newFilter(boolean isCached, String aPredicateExpression)
      Builds an XPath filter.

      Performance considerations: If the specified predicate must be often reused by multiple Request objects, it is recommended to enable caching. Parameterized expressions also help reuse.

      Warning: however, if many cached predicates with quite specific values are cached (isCached = true), but are not reused often, the memory cost could counter-balance the performance gain. More specifically, if a predicate is used only once, it is not recommended to use caching.

      Parameters:
      isCached - If true, the filter is cached in order to be reused when the same predicate expression is applied. If false, the filter is not cached and thus it cannot be reused.
      aPredicateExpression - XPath predicate expression to apply to the table records.
      See Also:
    • getPredicateExpression

      public String getPredicateExpression()
    • validateForTableNode

      public void validateForTableNode(SchemaNode aTableNode) throws IllegalArgumentException, MalformedXPathExpressionException
      Checks if a predicate expression is valid according to the schema of the table.
      Throws:
      IllegalArgumentException - if the specified argument is not defined or if the specified argument is not a table node.
      MalformedXPathExpressionException - if the predicate is malformed or if the predicate is not valid according to the schema of the table.
      Since:
      5.8.0
      See Also:
    • toString

      public String toString()
      Overrides:
      toString in class Object