Package com.onwbp.adaptation

# 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:
  - `newFilter(String)`
  - `Request.setXPathFilter(XPathFilter)`
  - `Request.setXPathParameter(String, Object)`
  - Supported XPath syntax

- ## Method Summary

  Modifier and Type
  Method
  Description
  `String`
  `getPredicateExpression()`
  `static XPathFilter`
  `newFilter(boolean isCached, String aPredicateExpression)`
  Builds an XPath filter.
  `static XPathFilter`
  `newFilter(String aPredicateExpression)`
  Builds a cache-enabled XPath predicate.
  `String`
  `toString()`
  `void`
  `validateForTableNode(SchemaNode aTableNode)`
  Checks if a predicate expression is valid according to the schema of the table.

  ### Methods inherited from class java.lang.Object

  `equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- ## 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:
      - `Request.setXPathFilter(XPathFilter)`

  - ### 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:
      - `Request.setXPathFilter(XPathFilter)`

  - ### 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:
      - `newFilter(String)`
      - `Request.setXPathFilter(XPathFilter)`

  - ### toString

    public String toString()
    Overrides:
      `toString` in class `Object`