Interface Compiler

  • All Known Implementing Classes:
    TreeCompiler

    public interface Compiler
    The Compiler APIs are completely agnostic to the actual types of objects produced and consumed by the APIs. Arguments and return values are declared as java.lang.Object.

    Since objects returned by Compiler methods are passed as arguments to other Compiler methods, the descriptions of these methods use virtual types. There are four virtual object types: EXPRESSION, QNAME, STEP and NODE_TEST.

    The following example illustrates this notion. This sequence compiles the xpath "foo[round(1 div 2)]/text()":

          Object qname1 = compiler.qname(null, "foo")
          Object expr1 = compiler.number("1");
          Object expr2 = compiler.number("2");
          Object expr3 = compiler.div(expr1, expr2);
          Object expr4 = compiler.
                  coreFunction(Compiler.FUNCTION_ROUND, new Object[]{expr3});
          Object test1 = compiler.nodeNameTest(qname1);
          Object step1 = compiler.
                  step(Compiler.AXIS_CHILD, test1, new Object[]{expr4});
          Object test2 = compiler.nodeTypeTest(Compiler.NODE_TYPE_TEXT);
          Object step2 = compiler.nodeTypeTest(Compiler.AXIS_CHILD, test2, null);
          Object expr5 = compiler.locationPath(false, new Object[]{step1, step2});
     
    Version:
    $Revision: 652845 $ $Date: 2008-05-02 12:46:46 -0500 (Fri, 02 May 2008) $
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      java.lang.Object and​(java.lang.Object[] arguments)
      Produces an EXPRESSION object representing logical conjunction of all arguments
      java.lang.Object divide​(java.lang.Object left, java.lang.Object right)
      Produces an EXPRESSION object representing left divided by right
      java.lang.Object equal​(java.lang.Object left, java.lang.Object right)
      Produces an EXPRESSION object representing the comparison: left equals to right
      java.lang.Object expressionPath​(java.lang.Object expression, java.lang.Object[] predicates, java.lang.Object[] steps)
      Produces an EXPRESSION object representing a filter expression
      java.lang.Object function​(int code, java.lang.Object[] args)
      Produces an EXPRESSION object representing the computation of a core function with the supplied arguments.
      java.lang.Object function​(java.lang.Object name, java.lang.Object[] args)
      Produces an EXPRESSION object representing the computation of a library function with the supplied arguments.
      java.lang.Object greaterThan​(java.lang.Object left, java.lang.Object right)
      Produces an EXPRESSION object representing the comparison: left greater than right
      java.lang.Object greaterThanOrEqual​(java.lang.Object left, java.lang.Object right)
      Produces an EXPRESSION object representing the comparison: left greater than or equal to right
      java.lang.Object lessThan​(java.lang.Object left, java.lang.Object right)
      Produces an EXPRESSION object representing the comparison: left less than right
      java.lang.Object lessThanOrEqual​(java.lang.Object left, java.lang.Object right)
      Produces an EXPRESSION object representing the comparison: left less than or equal to right
      java.lang.Object literal​(java.lang.String value)
      Produces an EXPRESSION object that represents a string constant.
      java.lang.Object locationPath​(boolean absolute, java.lang.Object[] steps)
      Produces an EXPRESSION object representing a location path
      java.lang.Object minus​(java.lang.Object argument)
      Produces an EXPRESSION object representing unary negation of the argument
      java.lang.Object minus​(java.lang.Object left, java.lang.Object right)
      Produces an EXPRESSION object representing left minus right
      java.lang.Object mod​(java.lang.Object left, java.lang.Object right)
      Produces an EXPRESSION object representing left modulo right
      java.lang.Object multiply​(java.lang.Object left, java.lang.Object right)
      Produces an EXPRESSION object representing left multiplied by right
      java.lang.Object nodeNameTest​(java.lang.Object qname)
      Produces a NODE_TEST object that represents a node name test.
      java.lang.Object nodeTypeTest​(int nodeType)
      Produces a NODE_TEST object that represents a node type test.
      java.lang.Object notEqual​(java.lang.Object left, java.lang.Object right)
      Produces an EXPRESSION object representing the comparison: left is not equal to right
      java.lang.Object number​(java.lang.String value)
      Produces an EXPRESSION object that represents a numeric constant.
      java.lang.Object or​(java.lang.Object[] arguments)
      Produces an EXPRESSION object representing logical disjunction of all arguments
      java.lang.Object processingInstructionTest​(java.lang.String instruction)
      Produces a NODE_TEST object that represents a processing instruction test.
      java.lang.Object qname​(java.lang.String prefix, java.lang.String name)
      Produces an QNAME that represents a name with an optional prefix.
      java.lang.Object step​(int axis, java.lang.Object nodeTest, java.lang.Object[] predicates)
      Produces a STEP object that represents a node test.
      java.lang.Object sum​(java.lang.Object[] arguments)
      Produces an EXPRESSION object representing the sum of all argumens
      java.lang.Object union​(java.lang.Object[] arguments)
      Produces an EXPRESSION object representing union of all node sets
      java.lang.Object variableReference​(java.lang.Object qname)
      Produces an EXPRESSION object representing variable reference
    • Method Detail

      • number

        java.lang.Object number​(java.lang.String value)
        Produces an EXPRESSION object that represents a numeric constant.
        Parameters:
        value - numeric String
        Returns:
        Object
      • literal

        java.lang.Object literal​(java.lang.String value)
        Produces an EXPRESSION object that represents a string constant.
        Parameters:
        value - String literal
        Returns:
        Object
      • qname

        java.lang.Object qname​(java.lang.String prefix,
                               java.lang.String name)
        Produces an QNAME that represents a name with an optional prefix.
        Parameters:
        prefix - String prefix
        name - String name
        Returns:
        Object
      • sum

        java.lang.Object sum​(java.lang.Object[] arguments)
        Produces an EXPRESSION object representing the sum of all argumens
        Parameters:
        arguments - are EXPRESSION objects
        Returns:
        Object
      • minus

        java.lang.Object minus​(java.lang.Object left,
                               java.lang.Object right)
        Produces an EXPRESSION object representing left minus right
        Parameters:
        left - is an EXPRESSION object
        right - is an EXPRESSION object
        Returns:
        Object
      • multiply

        java.lang.Object multiply​(java.lang.Object left,
                                  java.lang.Object right)
        Produces an EXPRESSION object representing left multiplied by right
        Parameters:
        left - is an EXPRESSION object
        right - is an EXPRESSION object
        Returns:
        Object
      • divide

        java.lang.Object divide​(java.lang.Object left,
                                java.lang.Object right)
        Produces an EXPRESSION object representing left divided by right
        Parameters:
        left - is an EXPRESSION object
        right - is an EXPRESSION object
        Returns:
        Object
      • mod

        java.lang.Object mod​(java.lang.Object left,
                             java.lang.Object right)
        Produces an EXPRESSION object representing left modulo right
        Parameters:
        left - is an EXPRESSION object
        right - is an EXPRESSION object
        Returns:
        Object
      • lessThan

        java.lang.Object lessThan​(java.lang.Object left,
                                  java.lang.Object right)
        Produces an EXPRESSION object representing the comparison: left less than right
        Parameters:
        left - is an EXPRESSION object
        right - is an EXPRESSION object
        Returns:
        Object
      • lessThanOrEqual

        java.lang.Object lessThanOrEqual​(java.lang.Object left,
                                         java.lang.Object right)
        Produces an EXPRESSION object representing the comparison: left less than or equal to right
        Parameters:
        left - is an EXPRESSION object
        right - is an EXPRESSION object
        Returns:
        Object
      • greaterThan

        java.lang.Object greaterThan​(java.lang.Object left,
                                     java.lang.Object right)
        Produces an EXPRESSION object representing the comparison: left greater than right
        Parameters:
        left - is an EXPRESSION object
        right - is an EXPRESSION object
        Returns:
        Object
      • greaterThanOrEqual

        java.lang.Object greaterThanOrEqual​(java.lang.Object left,
                                            java.lang.Object right)
        Produces an EXPRESSION object representing the comparison: left greater than or equal to right
        Parameters:
        left - is an EXPRESSION object
        right - is an EXPRESSION object
        Returns:
        Object
      • equal

        java.lang.Object equal​(java.lang.Object left,
                               java.lang.Object right)
        Produces an EXPRESSION object representing the comparison: left equals to right
        Parameters:
        left - is an EXPRESSION object
        right - is an EXPRESSION object
        Returns:
        Object
      • notEqual

        java.lang.Object notEqual​(java.lang.Object left,
                                  java.lang.Object right)
        Produces an EXPRESSION object representing the comparison: left is not equal to right
        Parameters:
        left - is an EXPRESSION object
        right - is an EXPRESSION object
        Returns:
        Object
      • minus

        java.lang.Object minus​(java.lang.Object argument)
        Produces an EXPRESSION object representing unary negation of the argument
        Parameters:
        argument - is an EXPRESSION object
        Returns:
        Object
      • variableReference

        java.lang.Object variableReference​(java.lang.Object qname)
        Produces an EXPRESSION object representing variable reference
        Parameters:
        qname - is a QNAME object
        Returns:
        Object
      • function

        java.lang.Object function​(int code,
                                  java.lang.Object[] args)
        Produces an EXPRESSION object representing the computation of a core function with the supplied arguments.
        Parameters:
        code - is one of FUNCTION_... constants
        args - are EXPRESSION objects
        Returns:
        Object
      • function

        java.lang.Object function​(java.lang.Object name,
                                  java.lang.Object[] args)
        Produces an EXPRESSION object representing the computation of a library function with the supplied arguments.
        Parameters:
        name - is a QNAME object (function name)
        args - are EXPRESSION objects
        Returns:
        Object
      • and

        java.lang.Object and​(java.lang.Object[] arguments)
        Produces an EXPRESSION object representing logical conjunction of all arguments
        Parameters:
        arguments - are EXPRESSION objects
        Returns:
        Object
      • or

        java.lang.Object or​(java.lang.Object[] arguments)
        Produces an EXPRESSION object representing logical disjunction of all arguments
        Parameters:
        arguments - are EXPRESSION objects
        Returns:
        Object
      • union

        java.lang.Object union​(java.lang.Object[] arguments)
        Produces an EXPRESSION object representing union of all node sets
        Parameters:
        arguments - are EXPRESSION objects
        Returns:
        Object
      • nodeNameTest

        java.lang.Object nodeNameTest​(java.lang.Object qname)
        Produces a NODE_TEST object that represents a node name test.
        Parameters:
        qname - is a QNAME object
        Returns:
        Object
      • nodeTypeTest

        java.lang.Object nodeTypeTest​(int nodeType)
        Produces a NODE_TEST object that represents a node type test.
        Parameters:
        nodeType - is a NODE_TEST object
        Returns:
        Object
      • processingInstructionTest

        java.lang.Object processingInstructionTest​(java.lang.String instruction)
        Produces a NODE_TEST object that represents a processing instruction test.
        Parameters:
        instruction - is a NODE_TEST object
        Returns:
        Object
      • step

        java.lang.Object step​(int axis,
                              java.lang.Object nodeTest,
                              java.lang.Object[] predicates)
        Produces a STEP object that represents a node test.
        Parameters:
        axis - is one of the AXIS_... constants
        nodeTest - is a NODE_TEST object
        predicates - are EXPRESSION objects
        Returns:
        Object
      • locationPath

        java.lang.Object locationPath​(boolean absolute,
                                      java.lang.Object[] steps)
        Produces an EXPRESSION object representing a location path
        Parameters:
        absolute - indicates whether the path is absolute
        steps - are STEP objects
        Returns:
        Object
      • expressionPath

        java.lang.Object expressionPath​(java.lang.Object expression,
                                        java.lang.Object[] predicates,
                                        java.lang.Object[] steps)
        Produces an EXPRESSION object representing a filter expression
        Parameters:
        expression - is an EXPRESSION object
        predicates - are EXPRESSION objects
        steps - are STEP objects
        Returns:
        Object