Class DraftFunctionCall

All Implemented Interfaces:
ExportAgent, Locatable, IdentityComparable, Traceable

public class DraftFunctionCall extends DraftExpression
This class represents a call to a function in its raw lexical form, before it has been resolved to an actual function. Used in XQuery only, where function references can be forwards references to functions not yet declared.
  • Constructor Details

    • DraftFunctionCall

      public DraftFunctionCall(String lexicalName, QueryModule queryModule, Expression[] arguments, Map<StructuredQName,Integer> keywordArgs)
      Create a function call to a user-written function in a query
      Parameters:
      lexicalName - The name of the function as written in the source query
      queryModule - The query module containing the function definition
      arguments - The argument expressions, in order, representing any "?" place marker by a PlaceHolder pseudo-expression
      keywordArgs - Mapping from argument keywords (where used) to the zero-based position where the keyword is used
  • Method Details

    • operands

      public Iterable<Operand> operands()
      Description copied from class: Expression
      Get the immediate sub-expressions of this expression, with information about the relationship of each expression to its parent expression.

      If the expression is a Callable, then it is required that the order of the operands returned by this function is the same as the order of arguments supplied to the corresponding call() method.

      Overrides:
      operands in class Expression
      Returns:
      an iterator containing the sub-expressions of this expression
    • getIntrinsicDependencies

      public int getIntrinsicDependencies()
      Description copied from class: Expression
      Determine the intrinsic dependencies of an expression, that is, those which are not derived from the dependencies of its subexpressions. For example, position() has an intrinsic dependency on the context position, while (position()+1) does not. The default implementation of the method returns 0, indicating "no dependencies".
      Overrides:
      getIntrinsicDependencies in class Expression
      Returns:
      an integer containing bit-significant flags identifying the "intrinsic" dependencies. The flags are documented in class net.sf.saxon.value.StaticProperty
    • isUpdatingExpression

      public boolean isUpdatingExpression()
      Determine whether this is an updating expression as defined in the XQuery update specification
      Overrides:
      isUpdatingExpression in class Expression
      Returns:
      true if this is an updating expression
    • copy

      public Expression copy(RebindingMap rebindings)
      Copy an expression. This makes a deep copy.
      Specified by:
      copy in class Expression
      Parameters:
      rebindings - variable bindings that need to be changed
      Returns:
      the copy of the original expression
    • computeCardinality

      protected int computeCardinality()
      Determine the cardinality of the result
      Specified by:
      computeCardinality in class Expression
      Returns:
      the computed cardinality, as one of the values StaticProperty.ALLOWS_ZERO_OR_ONE, StaticProperty.EXACTLY_ONE, StaticProperty.ALLOWS_ONE_OR_MORE, StaticProperty.ALLOWS_ZERO_OR_MORE. May also return StaticProperty.ALLOWS_ZERO if the result is known to be an empty sequence, or StaticProperty.ALLOWS_MANY if if is known to return a sequence of length two or more.
    • evaluateItem

      public Item evaluateItem(XPathContext c) throws XPathException
      Call the function, returning the value as an item. This method will be used only when the cardinality is zero or one. If the function is tail recursive, it returns an Object representing the arguments to the next (recursive) call
      Overrides:
      evaluateItem in class Expression
      Parameters:
      c - The context in which the expression is to be evaluated
      Returns:
      the node or atomic value that results from evaluating the expression; or null to indicate that the result is an empty sequence
      Throws:
      XPathException - if any dynamic error occurs evaluating the expression
    • iterate

      public SequenceIterator iterate(XPathContext c) throws XPathException
      Call the function, returning an iterator over the results. (But if the function is tail recursive, it returns an iterator over the arguments of the recursive call)
      Overrides:
      iterate in class Expression
      Parameters:
      c - supplies the context for evaluation
      Returns:
      a SequenceIterator that can be used to iterate over the result of the expression
      Throws:
      XPathException - if any dynamic error occurs evaluating the expression
    • process

      public void process(Outputter output, XPathContext context) throws XPathException
      Process the function call in push mode
      Overrides:
      process in class Expression
      Parameters:
      output - the destination for the result
      context - the XPath dynamic context
      Throws:
      XPathException - if a dynamic error occurs
    • export

      public void export(ExpressionPresenter out) throws XPathException
      Diagnostic print of expression structure. The abstract expression tree is written to the supplied output destination.
      Specified by:
      export in interface ExportAgent
      Specified by:
      export in class Expression
      Parameters:
      out - the expression presenter used to display the structure
      Throws:
      XPathException - if the export fails, for example if an expression is found that won't work in the target environment.
    • getExpressionName

      public String getExpressionName()
      Get a name identifying the kind of expression, in terms meaningful to a user.
      Overrides:
      getExpressionName in class Expression
      Returns:
      a name identifying the kind of expression, in terms meaningful to a user. The name will always be in the form of a lexical XML QName, and should match the name used in explain() output displaying the expression.
    • getImplementationMethod

      public int getImplementationMethod()
      Description copied from class: Expression
      An implementation of Expression must provide at least one of the methods evaluateItem(), iterate(), or process(). This method indicates which of these methods is provided directly. The other methods will always be available indirectly, using an implementation that relies on one of the other methods.
      Specified by:
      getImplementationMethod in class Expression
      Returns:
      the implementation method, for example Expression.ITERATE_METHOD or Expression.EVALUATE_METHOD or Expression.PROCESS_METHOD
    • getElaborator

      public Elaborator getElaborator()
      Description copied from class: Expression
      Make an elaborator for this expression
      Overrides:
      getElaborator in class Expression
      Returns:
      an appropriate Elaborator
    • simplify

      public Expression simplify() throws XPathException
      The simplify method applied to a DraftFunctionCall when the entire query has been parsed, so all user-defined functions are now known, enabling the name to be resolved. As well as locating the target function, keyword arguments can be resolved to positional arguments.
      Overrides:
      simplify in class Expression
      Returns:
      either a FunctionCall or a CurriedFunction
      Throws:
      XPathException - if resolution fails