Class ContextItemAccessorFunction

All Implemented Interfaces:
Callable, FunctionItem, GroundedValue, Item, Sequence
Direct Known Subclasses:
ContextItemAccessorFunction.Number_0, ContextItemAccessorFunction.StringAccessor

public class ContextItemAccessorFunction extends ContextAccessorFunction
A ContextItemAccessorFunction is a function that takes no arguments, but operates implicitly on the context item. In the case of a dynamic call, the context item that is used is the one at the point where the function item is created. Because these functions depend on the context only, with no additional arguments, the function can be evaluated as soon as the context is bound. The function is therefore replaced at this stage with a constant function, that is, one that always returns the same value.
  • Constructor Details

    • ContextItemAccessorFunction

      public ContextItemAccessorFunction()
  • Method Details

    • bindContext

      public FunctionItem bindContext(XPathContext context) throws XPathException
      Bind a context item to appear as part of the function's closure. If this method has been called, the supplied context item will be used in preference to the context item at the point where the function is actually called.
      Specified by:
      bindContext in class ContextAccessorFunction
      Parameters:
      context - the context to which the function applies. Must not be null.
      Throws:
      XPathException
    • evaluate

      public GroundedValue evaluate(Item item, XPathContext context) throws XPathException
      Evaluate the function. This is done by creating a function of the same name, with the context item as an explicit argument, and evaluating that.
      Parameters:
      item - the context item
      context - XPath dynamic context (not normally used)
      Returns:
      the result of the function
      Throws:
      XPathException - in the event of a dynamic error
    • call

      public Sequence call(XPathContext context, Sequence[] arguments) throws XPathException
      Evaluate the expression. This method is not normally used, but is provided to satisfy the interface.
      Specified by:
      call in interface Callable
      Overrides:
      call in class ContextAccessorFunction
      Parameters:
      context - the dynamic evaluation context
      arguments - the values of the arguments, supplied as Sequences
      Returns:
      the result of the evaluation, in the form of a Sequence
      Throws:
      XPathException - if a dynamic error occurs during the evaluation of the expression
    • makeFunctionCall

      public Expression makeFunctionCall(Expression[] arguments)
      Make a static call on this function, with specified arguments.
      Overrides:
      makeFunctionCall in class SystemFunction
      Parameters:
      arguments - the supplied arguments to the function call. This will always be an empty array, since this is a zero-arity function.
      Returns:
      This implementation returns a call on the equivalent arity-1 version of the function, supplying "." as an explicit argument.
    • makeContextItemExplicit

      public Expression makeContextItemExplicit()
      Create a system function call on this function in which the context item is supplied as an explicit argument
      Returns:
      an equivalent function call in which the context item is supplied explicitly.