Package net.sf.saxon.functions

## Class ApplyFn

- java.lang.Object
- - net.sf.saxon.functions.AbstractFunction
  - - net.sf.saxon.functions.SystemFunction
    - - net.sf.saxon.functions.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 Summary

    Constructors
    Constructor | Description
    --- | ---
    `ApplyFn()` |

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `Sequence` | `call​(XPathContext context, Sequence[] arguments)` | Evaluate the expression
    `void` | `exportAttributes​(ExpressionPresenter out)` | Export any context attributes held within the SystemFunction object.
    `ItemType` | `getResultItemType​(Expression[] args)` | Get the return type, given knowledge of the actual arguments
    `void` | `importAttributes​(java.util.Properties attributes)` | Import any attributes found in the export file, that is, any attributes output using the exportAttributes method
    `boolean` | `isDynamicFunctionCall()` | Ask whether this call to fn:apply was originally written as a dynamic function call
    `Expression` | `makeOptimizedFunctionCall​(ExpressionVisitor visitor, ContextItemStaticInfo contextInfo, Expression... arguments)` | Allow the function to create an optimized call based on the values of the actual arguments
    `void` | `setDynamicFunctionCall​(java.lang.String fnExpr)` | Say that this call to fn:apply was originally written as a dynamic function call

    - ### Methods inherited from class net.sf.saxon.functions.SystemFunction

      `dependsOnContextItem, dynamicCall, equals, export, exportAdditionalArguments, fixArguments, getArity, getCardinality, getCompilerName, getContextNode, getDescription, getDetails, getErrorCodeForTypeErrors, getFunctionItemType, getFunctionName, getIntegerBounds, getNetCost, getOperandRoles, getRequiredType, getResultItemType, getRetainedStaticContext, getSpecialProperties, getStaticBaseUriString, getStreamerName, isTrustedResultType, makeCall, makeFunction, makeFunctionCall, resultIfEmpty, setArity, setDetails, setRetainedStaticContext, supplyTypeInformation, toShortString, toString, typeCheckCaller`

    - ### Methods inherited from class net.sf.saxon.functions.AbstractFunction

      `atomize, deepEquals, effectiveBooleanValue, getAnnotations, getStringValue, getStringValueCS, isArray, isMap, makeNewContext, simplify, typeCheck`

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

      `clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface net.sf.saxon.om.Function

      `getGenre`

    - ### Methods inherited from interface net.sf.saxon.om.GroundedValue

      `asIterable, concatenate, containsNode, materialize`

    - ### Methods inherited from interface net.sf.saxon.om.Item

      `getLength, head, isStreamed, itemAt, iterate, reduce, subsequence`

    - ### Methods inherited from interface net.sf.saxon.om.Sequence

      `makeRepeatable`

- - ### 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