Interface XPathFunctionDefinition.FunctionCall

Enclosing class:
XPathFunctionDefinition

public static interface XPathFunctionDefinition.FunctionCall
Provides the actual implementation of a custom XPath function.
  • Method Summary

    Modifier and Type
    Method
    Description
    call(@Nullable Node contextNode, Object[] arguments)
    This method is called at runtime to evaluate the XPath function expression.
    default void
    staticInit(Object[] arguments)
    This is called once before the function is evaluated.
  • Method Details

    • call

      Object call(@Nullable Node contextNode, Object[] arguments) throws XPathFunctionException
      This method is called at runtime to evaluate the XPath function expression.
      Parameters:
      contextNode - the context node or null, if this function doesn't depend on the context. See XPathFunctionDefinition.dependsOnContext().
      arguments - The arguments converted as the corresponding java types. See XPathFunctionDefinition.getArgumentTypes().
      Returns:
      The result of the function. This should be the corresponding java type of XPathFunctionDefinition.getResultType().
      Throws:
      XPathFunctionException - when any problem during evaluation occurs, like invalid arguments.
    • staticInit

      default void staticInit(Object[] arguments) throws XPathFunctionException
      This is called once before the function is evaluated. It can be used to optimize the implementation by doing expensive operations only once and cache the result. This is useful, if the argument of the function is of type String and is provided as a String literal in the XPath expression.

      This is an optional step. The default implementation does nothing.

      Parameters:
      arguments - The arguments converted as the corresponding java types. See XPathFunctionDefinition.getArgumentTypes(). Note: This array might contain null elements, if the values are not known yet because they are dynamic. Only literal values are available.
      Throws:
      XPathFunctionException - when any problem during initialization occurs, like invalid arguments.