Class AbstractFunction

java.lang.Object
net.sf.saxon.functions.AbstractFunction
All Implemented Interfaces:
Callable, Function, GroundedValue, Item, Sequence
Direct Known Subclasses:
AtomicConstructorFunction, CallableFunction, CoercedFunction, CurriedFunction, ListConstructorFunction, OriginalFunction, SystemFunction, SystemFunctionWithBoundContextItem, UnionConstructorFunction, UnresolvedXQueryFunctionItem, UserFunctionReference.BoundUserFunction

public abstract class AbstractFunction extends Object implements Function
Abstract superclass (and factory class) for implementations of Function
  • Constructor Details

    • AbstractFunction

      public AbstractFunction()
  • Method Details

    • getSerialNumber

      public long getSerialNumber()
      Description copied from interface: Function
      Allocate a unique serial number.

      Introduced on the 11.x branch for bug #5887, so that function items, arrays, and maps can be used as keys for memo functions. This is not needed for 12.x, which uses a different design.

      Specified by:
      getSerialNumber in interface Function
    • getOperandRoles

      public OperandRole[] getOperandRoles()
      Get the roles of the arguments, for the purposes of streaming
      Specified by:
      getOperandRoles in interface Function
      Returns:
      an array of OperandRole objects, one for each argument
    • atomize

      public AtomicSequence atomize() throws XPathException
      Atomize the item.
      Specified by:
      atomize in interface Item
      Returns:
      the result of atomization
      Throws:
      XPathException - if atomization is not allowed for this kind of item
    • isArray

      public boolean isArray()
      Ask whether this function is an array
      Specified by:
      isArray in interface Function
      Returns:
      true if this function item is an array, otherwise false
    • isMap

      public boolean isMap()
      Ask whether this function is a map
      Specified by:
      isMap in interface Function
      Returns:
      true if this function item is a map, otherwise false
    • getUnicodeStringValue

      public UnicodeString getUnicodeStringValue()
      Get the string value of the function
      Specified by:
      getUnicodeStringValue in interface GroundedValue
      Specified by:
      getUnicodeStringValue in interface Item
      Returns:
      nothing; this method always throws an exception
      Throws:
      UnsupportedOperationException - (the string value of a function is not defined)
    • getAnnotations

      public AnnotationList getAnnotations()
      Description copied from interface: Function
      Get the function annotations (as defined in XQuery). Returns an empty list if there are no function annotations.
      Specified by:
      getAnnotations in interface Function
      Returns:
      the function annotations
    • effectiveBooleanValue

      public boolean effectiveBooleanValue() throws XPathException
      Get the effective boolean value of the function item
      Specified by:
      effectiveBooleanValue in interface GroundedValue
      Returns:
      the effective boolean value
      Throws:
      XPathException - (the EBVof a function item is not defined)
    • simplify

      public void simplify() throws XPathException
      Throws:
      XPathException
    • typeCheck

      public void typeCheck(ExpressionVisitor visitor, ContextItemStaticInfo contextItemType) throws XPathException
      Type check the function (may modify it by adding code for converting the arguments)
      Parameters:
      visitor - the expression visitor, supplies context information
      contextItemType - the context item type at the point where the function definition appears
      Throws:
      XPathException - if any failure (e.g. a type checking failure) occurs
    • makeNewContext

      public XPathContext makeNewContext(XPathContext callingContext, ContextOriginator originator)
      Prepare an XPathContext object for evaluating the function
      Specified by:
      makeNewContext in interface Function
      Parameters:
      callingContext - the XPathContext of the function calling expression
      originator - the originator of the new context
      Returns:
      a suitable context for evaluating the function (which may or may not be the same as the caller's context)
    • deepEquals

      public 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
      Specified by:
      deepEquals in interface 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
    • export

      public void export(ExpressionPresenter out) throws XPathException
      Output information about this function item to the diagnostic explain() output
      Specified by:
      export in interface Function
      Parameters:
      out - the destination for the information
      Throws:
      XPathException - if things go wrong
    • isTrustedResultType

      public boolean isTrustedResultType()
      Check that result type is SystemFunction or AtomicConstructorFunction
      Specified by:
      isTrustedResultType in interface Function
      Returns:
      true if the implementation can be trusted
    • toShortString

      public String toShortString()
      Description copied from interface: Function
      Provide a short string showing the contents of the item, suitable for use in error messages
      Specified by:
      toShortString in interface Function
      Specified by:
      toShortString in interface GroundedValue
      Specified by:
      toShortString in interface Item
      Returns:
      a depiction of the item suitable for use in error messages