Interface FunctionItem

All Superinterfaces:
Callable, GroundedValue, Item, Sequence
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, ApplyFn, ArrayFunctionSet.ArrayAppend, ArrayFunctionSet.ArrayEmpty, ArrayFunctionSet.ArrayExists, ArrayFunctionSet.ArrayFilter, ArrayFunctionSet.ArrayFlatten, ArrayFunctionSet.ArrayFoldLeft, ArrayFunctionSet.ArrayFoldRight, ArrayFunctionSet.ArrayFoot, ArrayFunctionSet.ArrayForEach, ArrayFunctionSet.ArrayForEachPair, ArrayFunctionSet.ArrayFromSequence, ArrayFunctionSet.ArrayGeneratingFunction, ArrayFunctionSet.ArrayGet, ArrayFunctionSet.ArrayHead, ArrayFunctionSet.ArrayInsertBefore, ArrayFunctionSet.ArrayJoin, ArrayFunctionSet.ArrayPut, ArrayFunctionSet.ArrayRemove, ArrayFunctionSet.ArrayReplace, ArrayFunctionSet.ArrayReverse, ArrayFunctionSet.ArraySize, ArrayFunctionSet.ArraySubarray, ArrayFunctionSet.ArrayTail, ArrayFunctionSet.ArrayToSequence, ArrayItem, ArraySort, AtomicConstructorFunction, AtomicEqual, AvailableEnvironmentVariables, AvailableSystemProperties, Average, BaseUri_1, BooleanFn, CallableFunction, Ceiling, CodepointEqual, CodepointsToString, CoercedFunction, CollatingFunctionFixed, CollatingFunctionFree, CollationKeyFn, CollectionFn, Compare, Concat, Concat31, 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, DeepEqual, DictionaryMap, DistinctValues, Doc, Doc_2, DocAvailable, DocumentFn, DocumentUri_1, DynamicContextAccessor, DynamicContextAccessor.CurrentDate, DynamicContextAccessor.CurrentDateTime, DynamicContextAccessor.CurrentTime, DynamicContextAccessor.DefaultLanguage, DynamicContextAccessor.ImplicitTimezone, ElementAvailable, Empty, EncodeForUri, EndsWith, EnvironmentVariable, Error, EscapeHtmlUri, Exists, ExsltCommonFunctionSet.NodeSetFn, ExsltCommonFunctionSet.ObjectTypeFn, FilterFn, Floor, FoldingFunction, FoldLeftFn, FoldRightFn, ForEachFn, ForEachPairFn, FormatDate, FormatInteger, FormatNumber, FunctionArity, FunctionAvailable, FunctionLookup, FunctionName, GenerateId_1, HasChildren_1, HashTrieMap, HeadFn, Idref, ImmutableArrayItem, IndexOf, Innermost, InScopePrefixes, InsertBefore, IriToUri, JsonDoc, JsonToXMLFn, KeyFn, Lang, ListCastableFunction, ListConstructorFunction, LoadXqueryModule, LocalName_1, LowerCase, MapCreate, MapFunctionSet.MapBuild, MapFunctionSet.MapContains, MapFunctionSet.MapEntries, MapFunctionSet.MapEntry, MapFunctionSet.MapFilter, MapFunctionSet.MapFind, MapFunctionSet.MapForEach, MapFunctionSet.MapGet, MapFunctionSet.MapKeys, MapFunctionSet.MapMerge, MapFunctionSet.MapOfPairs, MapFunctionSet.MapPair, MapFunctionSet.MapPairs, MapFunctionSet.MapPut, MapFunctionSet.MapRemove, MapFunctionSet.MapSize, MapItem, MapUntypedContains, Matches, MathFunctionSet.Atan2Fn, MathFunctionSet.PiFn, MathFunctionSet.PowFn, MathFunctionSet.TrigFn1, MemoFunction, Minimax, Minimax.Max, Minimax.Min, Name_1, NamespaceForPrefix, NamespaceUriFn_1, Nilled_1, NodeName_1, NormalizeSpace_1, NormalizeUnicode, NotFn, Number_1, OriginalFunction, Outermost, Parcel, ParseIetfDate, ParseJsonFn, ParseXml, ParseXmlFragment, Path_1, PositionAndLast, PositionAndLast.Last, PositionAndLast.Position, Put, QNameFn, RandomNumberGenerator, RangeKey, RegexFunction, RegexFunctionSansFlags, RegexGroup, Remove, Replace, ResolveQName, ResolveURI, Reverse, Root_1, Round, RoundHalfToEven, SaxonDeepEqual, ScalarSystemFunction, Serialize, SimpleArrayItem, SingleEntryMap, SnapshotFn, Sort_1, Sort_2, Sort_3, StartsWith, StaticBaseUri, StaticContextAccessor, StaticContextAccessor.DefaultCollation, StreamAvailable, String_1, StringJoin, StringLength_1, StringToCodepoints, Subsequence_2, Subsequence_3, Substring, SubstringAfter, SubstringBefore, Sum, SuperId, SuperId.ElementWithId, SuperId.Id, SystemFunction, SystemFunctionWithBoundContextItem, SystemProperty, TailFn, Tokenize_1, Tokenize_3, Trace, 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, VendorFunctionSetHE.ArrayAsSequenceOfMaps, VendorFunctionSetHE.ConcatenateSequences, VendorFunctionSetHE.DynamicErrorInfoFn, VendorFunctionSetHE.HasLocalNamespaces, VendorFunctionSetHE.HasUniformNamespaces, VendorFunctionSetHE.IsWholeNumberFn, VendorFunctionSetHE.MapAsSequenceOfMaps, VendorFunctionSetHE.YesNoBoolean, XMLToJsonFn

public interface FunctionItem extends Item, Callable, GroundedValue
XDM 3.0 introduces a third kind of item, beyond nodes and atomic values: the function. Functions implement this interface.
Since:
12.0; previously named Function.
  • Method Details

    • 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
    • isSequenceVariadic

      default boolean isSequenceVariadic()
      Ask whether the function is sequence-variadic (accepts a variable number of arguments)
      Returns:
      true if the function is sequence-variadic; default is false
    • 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)
    • deepEquals

      boolean deepEquals(FunctionItem 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
    • deepEqual40

      boolean deepEqual40(FunctionItem other, XPathContext context, DeepEqual.DeepEqualOptions options) throws XPathException
      Throws:
      XPathException
    • getDescription

      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
      Parameters:
      out - the destination for the information
      Throws:
      XPathException - if things go wrong
    • isTrustedResultType

      boolean isTrustedResultType()
      Ask if the function can be trusted to return a result of the correct type
      Returns:
      true if the implementation can be trusted
    • toShortString

      default 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.