Class Function

  • All Implemented Interfaces:
    javax.xml.transform.SourceLocator, ExpressionNode, XPathVisitable
    Direct Known Subclasses:
    FuncFalse, FuncLast, FuncPosition, FunctionOneArg, FuncTrue

    public abstract class Function
    extends Expression
    This is a superclass of all XPath functions. This allows two ways for the class to be called. One method is that the super class processes the arguments and hands the results to the derived class, the other method is that the derived class may process it's own arguments, which is faster since the arguments don't have to be added to an array, but causes a larger code footprint.
    • Constructor Detail

      • Function

        public Function()
    • Method Detail

      • setArg

        public void setArg​(Expression arg,
                           int argNum)
                    throws WrongNumberArgsException
        Set an argument expression for a function. This method is called by the XPath compiler.
        Parameters:
        arg - non-null expression that represents the argument.
        argNum - The argument number index.
        Throws:
        WrongNumberArgsException - If the argNum parameter is beyond what is specified for this function.
      • checkNumberArgs

        public void checkNumberArgs​(int argNum)
                             throws WrongNumberArgsException
        Check that the number of arguments passed to this function is correct. This method is meant to be overloaded by derived classes, to check for the number of arguments for a specific function type. This method is called by the compiler for static number of arguments checking.
        Parameters:
        argNum - The number of arguments that is being passed to the function.
        Throws:
        WrongNumberArgsException - if any
      • reportWrongNumberArgs

        protected void reportWrongNumberArgs()
                                      throws WrongNumberArgsException
        Constructs and throws a WrongNumberArgException with the appropriate message for this function object. This method is meant to be overloaded by derived classes so that the message will be as specific as possible.
        Throws:
        WrongNumberArgsException - if any
      • execute

        public XObject execute​(XPathContext xctxt)
                        throws javax.xml.transform.TransformerException
        Execute an expression in the XPath runtime context, and return the result of the expression.
        Specified by:
        execute in class Expression
        Parameters:
        xctxt - The XPath runtime context.
        Returns:
        The result of the expression in the form of a XObject.
        Throws:
        javax.xml.transform.TransformerException - if a runtime exception occurs.
      • callArgVisitors

        public void callArgVisitors​(XPathVisitor visitor)
        Call the visitors for the function arguments.
      • callVisitors

        public void callVisitors​(XPathVisitor visitor)
        This will traverse the hierarchy, calling the visitor for each member. If the called visitor method returns false, the subtree should not be called.
        Parameters:
        visitor - The visitor whose appropriate method will be called.
      • deepEquals

        public boolean deepEquals​(Expression expr)
        Compare this object with another object and see if they are equal, include the sub heararchy.
        Specified by:
        deepEquals in class Expression
        Parameters:
        expr - Another expression object.
        Returns:
        true if this objects class and the expr object's class are the same, and the data contained within both objects are considered equal.
      • postCompileStep

        public void postCompileStep​(Compiler compiler)
        This function is currently only being used by Position() and Last(). See respective functions for more detail.