Interface XPathFunctionDefinition.FunctionCall
-
- Enclosing class:
- XPathFunctionDefinition
public static interface XPathFunctionDefinition.FunctionCall
Provides the actual implementation of a custom XPath function.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description Object
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 Detail
-
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 ornull
, if this function doesn't depend on the context. SeeXPathFunctionDefinition.dependsOnContext()
.arguments
- The arguments converted as the corresponding java types. SeeXPathFunctionDefinition.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 typeString
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. SeeXPathFunctionDefinition.getArgumentTypes()
. Note: This array might containnull
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.
-
-