Interface IFunction

All Superinterfaces:
ICollectionValue, IItem
All Known Subinterfaces:
IArrayItem<ITEM>, IMapItem<VALUE>
All Known Implementing Classes:
dev.metaschema.core.metapath.function.impl.AbstractFunction, DefaultFunction

public interface IFunction extends IItem
A common interface for all Metapath functions.
  • Method Details

    • type

      @NonNull static IItemType type()
      Get the type information for this item.
      Returns:
      the type information
    • getType

      default IItemType getType()
      Description copied from interface: IItem
      Get the type information for the item.
      Specified by:
      getType in interface IItem
      Returns:
      the item's type information
    • getName

      @NonNull default String getName()
      Retrieve the name of the function.
      Returns:
      the function's name
    • getQName

      @NonNull IEnhancedQName getQName()
      Retrieve the namespace qualified name of the function.
      Returns:
      the namespace qualified name
    • getProperties

      @NonNull Set<IFunction.FunctionProperty> getProperties()
      Retrieve the set of assigned function properties.
      Returns:
      the set of properties or an empty set
    • getArguments

      @NonNull List<IArgument> getArguments()
      Retrieve the list of function arguments.
      Returns:
      the function arguments or an empty list if there are none
    • arity

      int arity()
      Determine the number of arguments the function has.
      Returns:
      the number of function arguments
    • isDeterministic

      default boolean isDeterministic()
      Determines if the result of the function call will produce identical results when provided the same implicit or explicit arguments.
      Returns:
      true if function is deterministic or false otherwise
      See Also:
    • isContextDepenent

      default boolean isContextDepenent()
      Determines if the result of the function call depends on property values within the static or dynamic context and the provided arguments.
      Returns:
      true if function is context dependent or false otherwise
      See Also:
    • isFocusDependent

      default boolean isFocusDependent()
      Determines if the result of the function call depends on the current focus.
      Returns:
      true if function is focus dependent or false otherwise
      See Also:
    • isArityUnbounded

      default boolean isArityUnbounded()
      Determines if the final argument can be repeated.
      Returns:
      true if the final argument can be repeated or false otherwise
      See Also:
    • getResult

      @NonNull ISequenceType getResult()
      Retrieve the function result sequence type.
      Returns:
      the function result sequence type
    • isNamedFunction

      boolean isNamedFunction()
      Determine if the function is a named function.
      Returns:
      true if the function is named or false if the function is anonymous
    • deepEquals

      default boolean deepEquals(ICollectionValue other, DynamicContext dynamicContext)
      Description copied from interface: ICollectionValue
      Determine if this and the other value are deeply equal.

      Item equality is defined by the XPath 3.1 fn:deep-equal specification.

      Specified by:
      deepEquals in interface ICollectionValue
      Parameters:
      other - the other value to compare to this value to
      dynamicContext - used to provide evaluation information, including the implicit timezone
      Returns:
      the true if the two values are equal, or false otherwise
    • execute

      @NonNull ISequence<?> execute(@NonNull List<? extends ISequence<?>> arguments, @NonNull DynamicContext dynamicContext, @NonNull ISequence<?> focus)
      Execute the function with the provided arguments, using the provided DynamicContext and focus.
      Parameters:
      arguments - the function arguments or an empty list if there are no arguments
      dynamicContext - the dynamic evaluation context
      focus - the current focus or an empty sequence if there is no focus
      Returns:
      the function result
      Throws:
      MetapathException - if an error occurred while executing the function
    • toAtomicItem

      default IAnyAtomicItem toAtomicItem()
      Description copied from interface: IItem
      Get the atomic value for the item. This may be the same item if the item is an instance of IAnyAtomicItem.

      An implementation of item atomization.

      Specified by:
      toAtomicItem in interface IItem
      Returns:
      the atomic value or null if the item has no available value
    • toSignature

      @NonNull default String toSignature()
      Get the signature of the function as a string.
      Specified by:
      toSignature in interface ICollectionValue
      Returns:
      the signature
    • builder

      @NonNull static IFunction.Builder builder()
      Construct a new function signature builder.
      Returns:
      the new builder instance
    • builder

      @NonNull static IFunction.Builder builder(@NonNull StaticContext staticContext)
      Construct a new function signature builder.
      Parameters:
      staticContext - the static context used to lookup data types and function implementations
      Returns:
      the new builder instance