Class ApplyFn

  • All Implemented Interfaces:
    Callable, Function, GroundedValue, Item, Sequence

    public class ApplyFn
    extends SystemFunction
    This class implements the function fn:apply(), which is a standard function in XQuery 3.1. The fn:apply function is also used internally to implement dynamic function calls.
    • Constructor Detail

      • ApplyFn

        public ApplyFn()
    • Method Detail

      • setDynamicFunctionCall

        public void setDynamicFunctionCall​(java.lang.String fnExpr)
        Say that this call to fn:apply was originally written as a dynamic function call
        Parameters:
        fnExpr - string representation of the expression used as the dynamic call
      • isDynamicFunctionCall

        public boolean isDynamicFunctionCall()
        Ask whether this call to fn:apply was originally written as a dynamic function call
        Returns:
        true if it was originally a dynamic function call
      • getResultItemType

        public ItemType getResultItemType​(Expression[] args)
        Get the return type, given knowledge of the actual arguments
        Overrides:
        getResultItemType in class SystemFunction
        Parameters:
        args - the actual arguments supplied
        Returns:
        the best available item type that the function will return
      • makeOptimizedFunctionCall

        public Expression makeOptimizedFunctionCall​(ExpressionVisitor visitor,
                                                    ContextItemStaticInfo contextInfo,
                                                    Expression... arguments)
                                             throws XPathException
        Description copied from class: SystemFunction
        Allow the function to create an optimized call based on the values of the actual arguments
        Overrides:
        makeOptimizedFunctionCall in class SystemFunction
        Parameters:
        visitor - the expression visitor
        contextInfo - information about the context item
        arguments - the supplied arguments to the function call. Note: modifying the contents of this array should not be attempted, it is likely to have no effect.
        Returns:
        either a function call on this function, or an expression that delivers the same result, or null indicating that no optimization has taken place
        Throws:
        XPathException - if an error is detected
      • call

        public Sequence call​(XPathContext context,
                             Sequence[] arguments)
                      throws XPathException
        Evaluate the expression
        Parameters:
        context - the dynamic evaluation context
        arguments - the values of the arguments. The first argument is the function item to be called; the second argument is an array containing the arguments to be passed to that function, before conversion.
        Returns:
        the result of the evaluation, in the form of a SequenceIterator
        Throws:
        XPathException - if a dynamic error occurs during the evaluation of the expression
      • exportAttributes

        public void exportAttributes​(ExpressionPresenter out)
        Description copied from class: SystemFunction
        Export any context attributes held within the SystemFunction object. The implementation will normally make one or more calls on out.emitAttribute(name, value).
        Overrides:
        exportAttributes in class SystemFunction
        Parameters:
        out - the export destination
      • importAttributes

        public void importAttributes​(java.util.Properties attributes)
        Import any attributes found in the export file, that is, any attributes output using the exportAttributes method
        Overrides:
        importAttributes in class SystemFunction
        Parameters:
        attributes - the attributes, as a properties object