Class ContextItemAccessorFunction

  • All Implemented Interfaces:
    Callable, Function, 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 Detail

      • ContextItemAccessorFunction

        public ContextItemAccessorFunction()
    • Method Detail

      • bindContext

        public Function 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
        context - the context to which the function applies. Must not be null.
      • 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.
        item - the context item
        context - XPath dynamic context (not normally used)
        the result of the function
        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
        call in class ContextAccessorFunction
        context - the dynamic evaluation context
        arguments - the values of the arguments, supplied as Sequences
        the result of the evaluation, in the form of a Sequence
        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.
        makeFunctionCall in class SystemFunction
        arguments - the supplied arguments to the function call. This will always be an empty array, since this is a zero-arity function.
        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
        an equivalent function call in which the context item is supplied explicitly.