Class LabeledFunctionItem

java.lang.Object
com.saxonica.functions.qt4.pin.LabeledFunctionItem
All Implemented Interfaces:
LabeledItem, Callable, FunctionItem, GroundedValue, Item, Sequence

public class LabeledFunctionItem extends Object implements FunctionItem, LabeledItem
n A LabeledMapItem represents an XDM map together with a label, which is a map: the map typically contains retained information about how the map was selected within a JSON-like tree.
  • Constructor Details

    • LabeledFunctionItem

      public LabeledFunctionItem(FunctionItem subject, MapItem label)
      Create a LabeledFunctionItem with a supplied label
      Parameters:
      subject - the subject function item
      label - the label
  • Method Details

    • getSubject

      public Item getSubject()
      Get the subject item without its label
      Specified by:
      getSubject in interface LabeledItem
      Returns:
      the subject item
    • getLabel

      public MapItem getLabel()
      Get the label of this value, typically, information about the containing maps and arrays in the containing tree
      Specified by:
      getLabel in interface Item
      Specified by:
      getLabel in interface LabeledItem
      Returns:
      the associated Pedigree.
    • call

      public Sequence call(XPathContext context, Sequence[] arguments) throws XPathException
      Call the Callable.
      Specified by:
      call in interface Callable
      Parameters:
      context - the dynamic evaluation context
      arguments - the values of the arguments, supplied as Sequences.

      Generally it is advisable, if calling iterate() to process a supplied sequence, to call it only once; if the value is required more than once, it should first be converted to a GroundedValue by calling the utility method SequenceTool.toGroundedValue().

      If the expected value is a single item, the item should be obtained by calling Sequence.head(): it cannot be assumed that the item will be passed as an instance of Item or AtomicValue.

      It is the caller's responsibility to perform any type conversions required to convert arguments to the type expected by the callee. An exception is where this Callable is explicitly an argument-converting wrapper around the original Callable.

      Returns:
      the result of the evaluation, in the form of a Sequence. It is the responsibility of the callee to ensure that the type of result conforms to the expected result type.
      Throws:
      XPathException - if a dynamic error occurs during the evaluation of the expression
    • isMap

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

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

      public FunctionItemType getFunctionItemType()
      Get the item type of the function item
      Specified by:
      getFunctionItemType in interface FunctionItem
      Returns:
      the function item's type
    • getFunctionName

      public StructuredQName getFunctionName()
      Get the name of the function, or null if it is anonymous
      Specified by:
      getFunctionName in interface FunctionItem
      Returns:
      the function name, or null for an anonymous inline function
    • getArity

      public int getArity()
      Get the arity of the function
      Specified by:
      getArity in interface FunctionItem
      Returns:
      the number of arguments in the function signature
    • getOperandRoles

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

      public AnnotationList getAnnotations()
      Get the function annotations (as defined in XQuery). Returns an empty list if there are no function annotations.
      Specified by:
      getAnnotations in interface FunctionItem
      Returns:
      the function annotations
    • makeNewContext

      public XPathContext makeNewContext(XPathContext callingContext, ContextOriginator originator)
      Prepare an XPathContext object for evaluating the function
      Specified by:
      makeNewContext in interface FunctionItem
      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

      public boolean deepEquals(FunctionItem other, XPathContext context, AtomicMatcher 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 FunctionItem
      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

      public boolean deepEqual40(FunctionItem other, XPathContext context, DeepEqual.DeepEqualOptions options) throws XPathException
      Description copied from interface: FunctionItem
      Test whether this FunctionItem is deep-equal to another function item, under the rules of the deep-equal function in XPath 4.0
      Specified by:
      deepEqual40 in interface FunctionItem
      Parameters:
      other - the other function item
      context - the dynamic evaluation context
      options - the options supplied to the deep-equal function
      Returns:
      true if the two function items are deep-equal
      Throws:
      XPathException - if the comparison cannot be performed
    • getDescription

      public 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".
      Specified by:
      getDescription in interface FunctionItem
      Returns:
      a description of the function for use in error messages
    • export

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

      public boolean isTrustedResultType()
      Ask if the function can be trusted to return a result of the correct type
      Specified by:
      isTrustedResultType in interface FunctionItem
      Returns:
      true if the implementation can be trusted
    • getUnicodeStringValue

      public UnicodeString getUnicodeStringValue()
      Get the value of the item as a Unicode string. For nodes, this is the string value of the node as defined in the XPath 2.0 data model, except that all nodes are treated as being untyped: it is not an error to get the string value of a node with a complex type. For atomic values, the method returns the result of casting the atomic value to a string.
      Specified by:
      getUnicodeStringValue in interface GroundedValue
      Specified by:
      getUnicodeStringValue in interface Item
      Returns:
      the string value of the item
      Throws:
      UnsupportedOperationException - if the item is a function item (an unchecked exception is used here to avoid introducing exception handling to a large number of paths where it is not needed)
      Since:
      8.4
    • 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