Package net.sf.saxon.s9api

## Class XdmFunctionItem

- java.lang.Object
- - net.sf.saxon.s9api.XdmValue
  - - net.sf.saxon.s9api.XdmItem
    - - net.sf.saxon.s9api.XdmFunctionItem

- All Implemented Interfaces:
    `java.lang.Iterable<XdmItem>`
  Direct Known Subclasses:
    `XdmArray`, `XdmMap`

      public class XdmFunctionItem
      extends XdmItem

  The class XdmFunctionItem represents a function item

- - ### Constructor Summary

    Constructors
    Modifier | Constructor | Description
    --- | --- | ---
    `protected` | `XdmFunctionItem()` |
    `` | `XdmFunctionItem​(Function fi)` |

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `java.util.function.Function<? super XdmValue,​? extends XdmValue>` | `asFunction​(Processor processor)` | Get an equivalent Java Function object representing this XdmFunction.
    `Step<XdmItem>` | `asStep​(Processor processor)` | Get an equivalent Step object representing this XdmFunction.
    `XdmValue` | `call​(Processor processor, XdmValue... arguments)` | Call the function
    `int` | `getArity()` | Get the arity of the function
    `QName` | `getName()` | Get the name of the function
    `static XdmFunctionItem` | `getSystemFunction​(Processor processor, QName name, int arity)` | Get a system function.
    `boolean` | `isAtomicValue()` | Determine whether the item is an atomic value

    - ### Methods inherited from class net.sf.saxon.s9api.XdmItem

      `asMap, getStringValue, getUnderlyingValue, isNode, matches, size, stream, wrapItem, wrapItem, wrapItem`

    - ### Methods inherited from class net.sf.saxon.s9api.XdmValue

      `append, documentOrder, fromGroundedValue, isEmpty, itemAt, iterator, makeSequence, makeValue, select, setValue, toString, wrap, wrap`

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

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

    - ### Methods inherited from interface java.lang.Iterable

      `forEach, spliterator`

- - ### Constructor Detail

    - #### XdmFunctionItem

          protected XdmFunctionItem()

    - #### XdmFunctionItem

          public XdmFunctionItem​(Function fi)

  - ### Method Detail

    - #### getName

          public QName getName()

      Get the name of the function
      Returns:
        the function name, as a QName, or null for an anonymous inline function item

    - #### getArity

          public int getArity()

      Get the arity of the function
      Returns:
        the arity of the function, that is, the number of arguments in the function's signature

    - #### isAtomicValue

          public boolean isAtomicValue()

      Determine whether the item is an atomic value
      Overrides:
        `isAtomicValue` in class `XdmItem`
      Returns:
        false, the item is not an atomic value, it is a function item

    - #### getSystemFunction

          public static XdmFunctionItem getSystemFunction​(Processor processor,
                                                          QName name,
                                                          int arity)
                                                   throws SaxonApiException

      Get a system function. This can be any function defined in XPath 3.1 functions and operators, including functions in the math, map, and array namespaces. It can also be a Saxon extension function, provided a licensed Processor is used.
      Returns:
        the requested function, or null if there is no such function. Note that some functions (those with particular context dependencies) may be unsuitable for dynamic calling.
      Throws:
        `SaxonApiException` - no longer thrown, but retained in the declaration for backwards compatibility

    - #### asFunction

          public java.util.function.Function<? super XdmValue,​? extends XdmValue> asFunction​(Processor processor)

      Get an equivalent Java Function object representing this XdmFunction. This is possible only for arity-1 functions.
      Returns:
        a Java Function. This takes an XdmValue as its argument, and returns the function result in the form of an XdmValue. The Function throws an unchecked exception if evaluation fails
      Throws:
        `java.lang.IllegalStateException` - if the arity of the function is not one (1).

    - #### asStep

          public Step<XdmItem> asStep​(Processor processor)

      Get an equivalent Step object representing this XdmFunction. This is possible only for arity-1 functions.
      Returns:
        a Step. This takes an XdmItem as its argument, and returns the function result in the form of an XdmStream. The Function throws an unchecked exception if evaluation fails
      Throws:
        `java.lang.IllegalStateException` - if the arity of the function is not one (1).

    - #### call

          public XdmValue call​(Processor processor,
                               XdmValue... arguments)
                        throws SaxonApiException

      Call the function
      Parameters:
        `arguments` - the values to be supplied as arguments to the function. The "function conversion rules" will be applied to convert the arguments to the required type when necessary.
        `processor` - the s9api Processor
      Returns:
        the result of calling the function
      Throws:
        `SaxonApiException`