Package net.sf.saxon.om

## Interface Function

- All Superinterfaces:
    `Callable`, `GroundedValue`, `Item`, `Sequence`
  All Known Subinterfaces:
    `ArrayItem`, `MapItem`
  All Known Implementing Classes:
    `Abs`, `AbstractArrayItem`, `AbstractFunction`, `AccessorFn`, `AccessorFn.DayFromDate`, `AccessorFn.DayFromDateTime`, `AccessorFn.DaysFromDuration`, `AccessorFn.HoursFromDateTime`, `AccessorFn.HoursFromDuration`, `AccessorFn.HoursFromTime`, `AccessorFn.LocalNameFromQName`, `AccessorFn.MinutesFromDateTime`, `AccessorFn.MinutesFromDuration`, `AccessorFn.MinutesFromTime`, `AccessorFn.MonthFromDate`, `AccessorFn.MonthFromDateTime`, `AccessorFn.MonthsFromDuration`, `AccessorFn.NamespaceUriFromQName`, `AccessorFn.PrefixFromQName`, `AccessorFn.SecondsFromDateTime`, `AccessorFn.SecondsFromDuration`, `AccessorFn.SecondsFromTime`, `AccessorFn.TimezoneFromDate`, `AccessorFn.TimezoneFromDateTime`, `AccessorFn.TimezoneFromTime`, `AccessorFn.YearFromDate`, `AccessorFn.YearFromDateTime`, `AccessorFn.YearsFromDuration`, `AccumulatorFn`, `AccumulatorFn.AccumulatorAfter`, `AccumulatorFn.AccumulatorBefore`, `Adjust_1`, `Adjust_2`, `Aggregate`, `AnalyzeStringFn`, `AnalyzeUri`, `ApplyFn`, `ArrayFunctionSet.ArrayAppend`, `ArrayFunctionSet.ArrayFilter`, `ArrayFunctionSet.ArrayFlatten`, `ArrayFunctionSet.ArrayFoldLeft`, `ArrayFunctionSet.ArrayFoldRight`, `ArrayFunctionSet.ArrayForEach`, `ArrayFunctionSet.ArrayForEachPair`, `ArrayFunctionSet.ArrayFromSequence`, `ArrayFunctionSet.ArrayGet`, `ArrayFunctionSet.ArrayHead`, `ArrayFunctionSet.ArrayInsertBefore`, `ArrayFunctionSet.ArrayJoin`, `ArrayFunctionSet.ArrayPut`, `ArrayFunctionSet.ArrayRemove`, `ArrayFunctionSet.ArrayReverse`, `ArrayFunctionSet.ArraySize`, `ArrayFunctionSet.ArraySubarray`, `ArrayFunctionSet.ArrayTail`, `ArrayFunctionSet.ArrayToSequence`, `ArrayMember`, `ArraySort`, `AtomicConstructorFunction`, `AvailableEnvironmentVariables`, `AvailableSystemProperties`, `Average`, `BaseUri_1`, `BooleanFn`, `CallableFunction`, `Ceiling`, `CharactersFn`, `CodepointEqual`, `CodepointsToString`, `CoercedFunction`, `CollatingFunctionFixed`, `CollatingFunctionFree`, `CollationKeyFn`, `CollectionFn`, `Compare`, `CompileQuery`, `CompileStylesheet`, `CompileXPath`, `Concat`, `ConstantFunction`, `ConstantFunction.False`, `ConstantFunction.True`, `Contains`, `ContainsToken`, `ContextAccessorFunction`, `ContextItemAccessorFunction`, `ContextItemAccessorFunction.Number_0`, `ContextItemAccessorFunction.StringAccessor`, `CopyOfFn`, `Count`, `Current`, `CurrentGroup`, `CurrentGroupingKey`, `CurrentMergeGroup`, `CurrentMergeKey`, `CurrentOutputUri`, `CurriedFunction`, `Data_1`, `DateTimeConstructor`, `DecimalDivide`, `DeepEqual`, `DeepEqual`, `DelegatingArrayItem`, `DelegatingMapItem`, `DictionaryMap`, `DistinctValues`, `Doc`, `Doc_2`, `DocAvailable`, `DocumentFn`, `DocumentUri_1`, `DynamicContextAccessor`, `DynamicContextAccessor.CurrentDate`, `DynamicContextAccessor.CurrentDateTime`, `DynamicContextAccessor.CurrentTime`, `DynamicContextAccessor.DefaultLanguage`, `DynamicContextAccessor.ImplicitTimezone`, `ElementAvailable`, `Empty`, `EncodeForUri`, `Ending`, `Ending.ItemsBefore`, `Ending.ItemsUntil`, `EndsWith`, `EnvironmentVariable`, `EQName`, `Error`, `EscapeHtmlUri`, `Eval`, `Evaluate`, `Exists`, `EXPathFileFunctionSet.BaseDir`, `ExpressionFn`, `ExsltCommonFunctionSet.NodeSetFn`, `ExsltCommonFunctionSet.ObjectTypeFn`, `FilterFn`, `Floor`, `FoldingFunction`, `FoldLeftFn`, `FoldRightFn`, `ForEachFn`, `ForEachPairFn`, `FormatDate`, `FormatInteger`, `FormatNumber`, `FunctionAnnotations`, `FunctionArity`, `FunctionAvailable`, `FunctionLookup`, `FunctionName`, `GenerateId_1`, `GroupStarting`, `HasChildren_1`, `HashTrieMap`, `HeadFn`, `HighestOrLowest`, `Idref`, `ImmutableArrayItem`, `Index`, `IndexOf`, `IndexWhere`, `Innermost`, `InScopeNamespacesFn`, `InScopePrefixes`, `InsertBefore`, `IriToUri`, `IsNaN`, `IXSLFunctionSet.Call`, `IXSLFunctionSet.Eval`, `IXSLFunctionSet.ScheduleActionFn`, `IXSLFunctionSet.Source`, `IXSLFunctionSet.Stub`, `JsonDoc`, `JsonToXMLFn`, `KeyFn`, `KeyMap`, `Lang`, `LastModified`, `Leading`, `ListCastableFunction`, `ListConstructorFunction`, `LoadXqueryModule`, `LocalName_1`, `LowerCase`, `MapCreate`, `MapFunctionSet.MapContains`, `MapFunctionSet.MapEntry`, `MapFunctionSet.MapFind`, `MapFunctionSet.MapForEach`, `MapFunctionSet.MapGet`, `MapFunctionSet.MapKeys`, `MapFunctionSet.MapMerge`, `MapFunctionSet.MapPut`, `MapFunctionSet.MapRemove`, `MapFunctionSet.MapSize`, `MapSearch`, `MapUntypedContains`, `Matches`, `MathFunctionSet.AcosFn`, `MathFunctionSet.AsinFn`, `MathFunctionSet.Atan2Fn`, `MathFunctionSet.AtanFn`, `MathFunctionSet.CosFn`, `MathFunctionSet.Exp10Fn`, `MathFunctionSet.ExpFn`, `MathFunctionSet.Log10Fn`, `MathFunctionSet.LogFn`, `MathFunctionSet.PiFn`, `MathFunctionSet.PowFn`, `MathFunctionSet.SinFn`, `MathFunctionSet.SqrtFn`, `MathFunctionSet.TanFn`, `MemoFunction`, `MessageCount`, `Minimax`, `Minimax.Max`, `Minimax.Min`, `Name_1`, `NamespaceForPrefix`, `NamespaceUri_1`, `NewAttribute`, `NewComment`, `NewDocument`, `NewElement`, `NewNamespace`, `NewProcessingInstruction`, `NewText`, `Nilled_1`, `NodeName_1`, `NormalizeSpace_1`, `NormalizeUnicode`, `NotFn`, `Number_1`, `ObjectMap`, `OriginalFunction`, `Outermost`, `Parse`, `ParseHtml`, `ParseIetfDate`, `ParseJsonFn`, `ParseXml`, `ParseXmlFragment`, `ParseXPath`, `Path_1`, `PedigreeArrayItem`, `PedigreeFn`, `PedigreeMapItem`, `PositionAndLast`, `PositionAndLast.Last`, `PositionAndLast.Position`, `Put`, `QNameFn`, `QueryFn`, `RandomNumberGenerator`, `RangeKey`, `RegexFunction`, `RegexFunctionSansFlags`, `RegexGroup`, `Remove`, `Replace`, `ReplaceWith`, `ResolveQName`, `ResolveURI`, `Reverse`, `Root_1`, `Round`, `RoundHalfToEven`, `ScalarSystemFunction`, `SchemaFn`, `SendMail`, `Serialize`, `Serialize`, `SimpleArrayItem`, `SingleEntryMap`, `SnapshotFn`, `Sort_1`, `Sort_2`, `Sort_3`, `SQLConnectFn`, `SQLDeleteFn`, `SQLExecuteFn`, `SQLInsertFn`, `SQLPreparedQueryFn`, `SQLPreparedStatementFn`, `SQLQueryFn`, `SQLTableFn`, `SQLUpdateFn`, `Starting`, `Starting.ItemsAfter`, `Starting.ItemsFrom`, `StartsWith`, `StaticBaseUri`, `StaticContextAccessor`, `StaticContextAccessor.DefaultCollation`, `StreamableUserFunction`, `StreamAvailable`, `StreamFn`, `String_1`, `StringJoin`, `StringLength_1`, `StringToCodepoints`, `Subsequence_2`, `Subsequence_3`, `Substring`, `SubstringAfter`, `SubstringBefore`, `Sum`, `SuperId`, `SuperId.ElementWithId`, `SuperId.Id`, `SystemFunction`, `SystemFunctionWithBoundContextItem`, `SystemProperty`, `TailFn`, `TimestampFn`, `Tokenize_1`, `Tokenize_3`, `Trace`, `TransformFn`, `TransformFn`, `Translate`, `TreatFn`, `TreatFn.ExactlyOne`, `TreatFn.OneOrMore`, `TreatFn.ZeroOrOne`, `TypeAvailable`, `UnionCastableFunction`, `UnionConstructorFunction`, `Unordered`, `UnparsedEntity`, `UnparsedEntity.UnparsedEntityPublicId`, `UnparsedEntity.UnparsedEntityUri`, `UnparsedText`, `UnparsedTextAvailable`, `UnparsedTextFunction`, `UnparsedTextLines`, `UnresolvedXQueryFunctionItem`, `UpperCase`, `UriCollection`, `UserFunction`, `UserFunctionReference.BoundUserFunction`, `ValidateFn`, `VendorFunctionSetHE.DynamicErrorInfoFn`, `VendorFunctionSetHE.HasLocalNamespaces`, `VendorFunctionSetHE.HasUniformNamespaces`, `VendorFunctionSetHE.IsWholeNumberFn`, `WithPedigree`, `XMLToJsonFn`

      public interface Function
      extends Item, Callable, GroundedValue

  XDM 3.0 introduces a third kind of item, beyond nodes and atomic values: the function. Functions implement this interface.

- - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods Default Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `static Sequence[]` | `argumentArray​(Sequence... args)` |
    `Sequence` | `call​(XPathContext context, Sequence[] args)` | Invoke the function
    `boolean` | `deepEquals​(Function other, XPathContext context, AtomicComparer comparer, int flags)` | Test whether this FunctionItem is deep-equal to another function item, under the rules of the deep-equal function
    `void` | `export​(ExpressionPresenter out)` | Output information about this function item to the diagnostic explain() output
    `AnnotationList` | `getAnnotations()` | Get the function annotations (as defined in XQuery).
    `int` | `getArity()` | Get the arity of the function
    `java.lang.String` | `getDescription()` | Get a description of this function for use in error messages.
    `FunctionItemType` | `getFunctionItemType()` | Get the item type of the function item
    `StructuredQName` | `getFunctionName()` | Get the name of the function, or null if it is anonymous
    `default Genre` | `getGenre()` | Get the genre of this item
    `OperandRole[]` | `getOperandRoles()` | Get the roles of the arguments, for the purposes of streaming
    `boolean` | `isArray()` | Ask whether this function item is an array
    `boolean` | `isMap()` | Ask whether this function item is a map
    `boolean` | `isTrustedResultType()` | Check that result type is of the trusted system functions to return a result of the correct type
    `XPathContext` | `makeNewContext​(XPathContext callingContext, ContextOriginator originator)` | Prepare an XPathContext object for evaluating the function
    `default java.lang.String` | `toShortString()` | Provide a short string showing the contents of the item, suitable for use in error messages

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

      `asIterable, concatenate, containsNode, effectiveBooleanValue, materialize`

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

      `atomize, getLength, getStringValue, getStringValueCS, head, isStreamed, itemAt, iterate, reduce, subsequence`

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

      `makeRepeatable`

- - ### Method Detail

    - #### isMap

          boolean isMap()

      Ask whether this function item is a map
      Returns:
        true if this function item is a map, otherwise false

    - #### isArray

          boolean isArray()

      Ask whether this function item is an array
      Returns:
        true if this function item is an array, otherwise false

    - #### getFunctionItemType

          FunctionItemType getFunctionItemType()

      Get the item type of the function item
      Returns:
        the function item's type

    - #### getFunctionName

          StructuredQName getFunctionName()

      Get the name of the function, or null if it is anonymous
      Returns:
        the function name, or null for an anonymous inline function

    - #### getArity

          int getArity()

      Get the arity of the function
      Returns:
        the number of arguments in the function signature

    - #### getOperandRoles

          OperandRole[] getOperandRoles()

      Get the roles of the arguments, for the purposes of streaming
      Returns:
        an array of OperandRole objects, one for each argument

    - #### getAnnotations

          AnnotationList getAnnotations()

      Get the function annotations (as defined in XQuery). Returns an empty list if there are no function annotations.
      Returns:
        the function annotations

    - #### makeNewContext

          XPathContext makeNewContext​(XPathContext callingContext,
                                      ContextOriginator originator)

      Prepare an XPathContext object for evaluating the function
      Parameters:
        `callingContext` - the XPathContext of the function calling expression
        `originator` - identifies the location of the caller for diagnostics
      Returns:
        a suitable context for evaluating the function (which may or may not be the same as the caller's context)

    - #### call

          Sequence call​(XPathContext context,
                        Sequence[] args)
                 throws XPathException

      Invoke the function
      Specified by:
        `call` in interface `Callable`
      Parameters:
        `context` - the XPath dynamic evaluation context
        `args` - the actual arguments to be supplied
      Returns:
        the result of invoking the function
      Throws:
        `XPathException` - if a dynamic error occurs within the function

    - #### deepEquals

          boolean deepEquals​(Function other,
                             XPathContext context,
                             AtomicComparer comparer,
                             int flags)
                      throws XPathException

      Test whether this FunctionItem is deep-equal to another function item, under the rules of the deep-equal function
      Parameters:
        `other` - the other function item
        `context` - the dynamic evaluation context
        `comparer` - the object to perform the comparison
        `flags` - options for how the comparison is performed
      Returns:
        true if the two function items are deep-equal
      Throws:
        `XPathException` - if the comparison cannot be performed

    - #### getDescription

          java.lang.String getDescription()

      Get a description of this function for use in error messages. For named functions, the description is the function name (as a lexical QName). For others, it might be, for example, "inline function", or "partially-applied ends-with function".
      Returns:
        a description of the function for use in error messages

    - #### export

          void export​(ExpressionPresenter out)
               throws XPathException

      Output information about this function item to the diagnostic explain() output
      Throws:
        `XPathException`

    - #### isTrustedResultType

          boolean isTrustedResultType()

      Check that result type is of the trusted system functions to return a result of the correct type

    - #### toShortString

          default java.lang.String toShortString()

      Provide a short string showing the contents of the item, suitable for use in error messages
      Specified by:
        `toShortString` in interface `GroundedValue`
      Specified by:
        `toShortString` in interface `Item`
      Returns:
        a depiction of the item suitable for use in error messages

    - #### getGenre

          default Genre getGenre()

      Get the genre of this item
      Specified by:
        `getGenre` in interface `Item`
      Returns:
        the genre: specifically, `Genre.FUNCTION`. Overridden for maps and arrays.

    - #### argumentArray

          @SafeVarargs
          static Sequence[] argumentArray​(Sequence... args)