Class StaticFunctionCall

  • All Implemented Interfaces:
    Callable, ExportAgent, Locatable, IdentityComparable, Traceable
    Direct Known Subclasses:
    SystemFunctionCall

    public class StaticFunctionCall
    extends FunctionCall
    implements Callable
    A call to a function that is known statically. This is a stricter definition than "static function call" in the XPath grammar, because it excludes calls that might be re-bound to a different function as a result of XSLT overrides in a different package, calls to functions that hold dynamic context information in their closure, and so on.
    • Method Detail

      • getTargetFunction

        public FunctionItem getTargetFunction()
        Get the target function to be called
        Returns:
        the target function
      • getTargetFunction

        public FunctionItem getTargetFunction​(XPathContext context)
        Get the target function to be called
        Specified by:
        getTargetFunction in class FunctionCall
        Parameters:
        context - the dynamic evaluation context (not used in this implementation)
        Returns:
        the target function
      • isCallOn

        public boolean isCallOn​(java.lang.Class<? extends SystemFunction> function)
        Ask whether this expression is a call on a particular function
        Overrides:
        isCallOn in class Expression
        Parameters:
        function - the implementation class of the function in question
        Returns:
        true if the expression is a call on the function
      • typeCheck

        public Expression typeCheck​(ExpressionVisitor visitor,
                                    ContextItemStaticInfo contextInfo)
                             throws XPathException
        Type-check the expression. This also calls preEvaluate() to evaluate the function if all the arguments are constant; functions that do not require this behavior can override the preEvaluate method.
        Overrides:
        typeCheck in class FunctionCall
        Parameters:
        visitor - the expression visitor
        contextInfo - information about the type of the context item
        Returns:
        the original expression, rewritten to perform necessary run-time type checks, and to perform other type-related optimizations
        Throws:
        XPathException - if an error is discovered during this phase (typically a type error)
      • copy

        public Expression copy​(RebindingMap rebindings)
        Copy an expression. This makes a deep copy.
        Specified by:
        copy in class Expression
        Parameters:
        rebindings - variables that need to be re-bound
        Returns:
        the copy of the original expression
      • getItemType

        public ItemType getItemType()
        Determine the data type of the expression, if possible. All expression return sequences, in general; this method determines the type of the items within the sequence, assuming that (a) this is known in advance, and (b) it is the same for all items in the sequence.

        This method should always return a result, though it may be the best approximation that is available at the time.

        Specified by:
        getItemType in class Expression
        Returns:
        a value such as Type.STRING, Type.BOOLEAN, Type.NUMBER, Type.NODE, or Type.ITEM (meaning not known at compile time)
      • getStaticUType

        public UType getStaticUType​(UType contextItemType)
        Get the static type of the expression as a UType, following precisely the type inference rules defined in the XSLT 3.0 specification.
        Overrides:
        getStaticUType in class Expression
        Parameters:
        contextItemType - the static type of the context item
        Returns:
        the static item type of the expression according to the XSLT 3.0 defined rules
      • 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 methd 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
      • getExpressionName

        public java.lang.String getExpressionName()
        Get a name identifying the kind of expression, in terms meaningful to a user.
        Overrides:
        getExpressionName in class FunctionCall
        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.
      • export

        public void export​(ExpressionPresenter out)
                    throws XPathException
        Serialized output of expression structure. The abstract expression tree is written to the supplied output destination.
        Specified by:
        export in interface ExportAgent
        Overrides:
        export in class FunctionCall
        Parameters:
        out - destination of the SEF output
        Throws:
        XPathException - if the export fails, for example if an expression is found that won't work in the target environment.