org.apache.commons.jxpath.ri
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: 1.7 $ $Date: 2003/03/11 00:59:18 $
Author:
Dmitri Plotnikov

Field Summary
static int AXIS_ANCESTOR
           
static int AXIS_ANCESTOR_OR_SELF
           
static int AXIS_ATTRIBUTE
           
static int AXIS_CHILD
           
static int AXIS_DESCENDANT
           
static int AXIS_DESCENDANT_OR_SELF
           
static int AXIS_FOLLOWING
           
static int AXIS_FOLLOWING_SIBLING
           
static int AXIS_NAMESPACE
           
static int AXIS_PARENT
           
static int AXIS_PRECEDING
           
static int AXIS_PRECEDING_SIBLING
           
static int AXIS_SELF
           
static int FUNCTION_BOOLEAN
           
static int FUNCTION_CEILING
           
static int FUNCTION_CONCAT
           
static int FUNCTION_CONTAINS
           
static int FUNCTION_COUNT
           
static int FUNCTION_FALSE
           
static int FUNCTION_FLOOR
           
static int FUNCTION_FORMAT_NUMBER
           
static int FUNCTION_ID
           
static int FUNCTION_KEY
           
static int FUNCTION_LANG
           
static int FUNCTION_LAST
           
static int FUNCTION_LOCAL_NAME
           
static int FUNCTION_NAME
           
static int FUNCTION_NAMESPACE_URI
           
static int FUNCTION_NORMALIZE_SPACE
           
static int FUNCTION_NOT
           
static int FUNCTION_NULL
           
static int FUNCTION_NUMBER
           
static int FUNCTION_POSITION
           
static int FUNCTION_ROUND
           
static int FUNCTION_STARTS_WITH
           
static int FUNCTION_STRING
           
static int FUNCTION_STRING_LENGTH
           
static int FUNCTION_SUBSTRING
           
static int FUNCTION_SUBSTRING_AFTER
           
static int FUNCTION_SUBSTRING_BEFORE
           
static int FUNCTION_SUM
           
static int FUNCTION_TRANSLATE
           
static int FUNCTION_TRUE
           
static int NODE_TYPE_COMMENT
           
static int NODE_TYPE_NODE
           
static int NODE_TYPE_PI
           
static int NODE_TYPE_TEXT
           
 
Method Summary
 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
 

Field Detail

NODE_TYPE_NODE

public static final int NODE_TYPE_NODE

NODE_TYPE_TEXT

public static final int NODE_TYPE_TEXT

NODE_TYPE_COMMENT

public static final int NODE_TYPE_COMMENT

NODE_TYPE_PI

public static final int NODE_TYPE_PI

AXIS_SELF

public static final int AXIS_SELF

AXIS_CHILD

public static final int AXIS_CHILD

AXIS_PARENT

public static final int AXIS_PARENT

AXIS_ANCESTOR

public static final int AXIS_ANCESTOR

AXIS_ATTRIBUTE

public static final int AXIS_ATTRIBUTE

AXIS_NAMESPACE

public static final int AXIS_NAMESPACE

AXIS_PRECEDING

public static final int AXIS_PRECEDING

AXIS_FOLLOWING

public static final int AXIS_FOLLOWING

AXIS_DESCENDANT

public static final int AXIS_DESCENDANT

AXIS_ANCESTOR_OR_SELF

public static final int AXIS_ANCESTOR_OR_SELF

AXIS_FOLLOWING_SIBLING

public static final int AXIS_FOLLOWING_SIBLING

AXIS_PRECEDING_SIBLING

public static final int AXIS_PRECEDING_SIBLING

AXIS_DESCENDANT_OR_SELF

public static final int AXIS_DESCENDANT_OR_SELF

FUNCTION_LAST

public static final int FUNCTION_LAST

FUNCTION_POSITION

public static final int FUNCTION_POSITION

FUNCTION_COUNT

public static final int FUNCTION_COUNT

FUNCTION_ID

public static final int FUNCTION_ID

FUNCTION_LOCAL_NAME

public static final int FUNCTION_LOCAL_NAME

FUNCTION_NAMESPACE_URI

public static final int FUNCTION_NAMESPACE_URI

FUNCTION_NAME

public static final int FUNCTION_NAME

FUNCTION_STRING

public static final int FUNCTION_STRING

FUNCTION_CONCAT

public static final int FUNCTION_CONCAT

FUNCTION_STARTS_WITH

public static final int FUNCTION_STARTS_WITH

FUNCTION_CONTAINS

public static final int FUNCTION_CONTAINS

FUNCTION_SUBSTRING_BEFORE

public static final int FUNCTION_SUBSTRING_BEFORE

FUNCTION_SUBSTRING_AFTER

public static final int FUNCTION_SUBSTRING_AFTER

FUNCTION_SUBSTRING

public static final int FUNCTION_SUBSTRING

FUNCTION_STRING_LENGTH

public static final int FUNCTION_STRING_LENGTH

FUNCTION_NORMALIZE_SPACE

public static final int FUNCTION_NORMALIZE_SPACE

FUNCTION_TRANSLATE

public static final int FUNCTION_TRANSLATE

FUNCTION_BOOLEAN

public static final int FUNCTION_BOOLEAN

FUNCTION_NOT

public static final int FUNCTION_NOT

FUNCTION_TRUE

public static final int FUNCTION_TRUE

FUNCTION_FALSE

public static final int FUNCTION_FALSE

FUNCTION_LANG

public static final int FUNCTION_LANG

FUNCTION_NUMBER

public static final int FUNCTION_NUMBER

FUNCTION_SUM

public static final int FUNCTION_SUM

FUNCTION_FLOOR

public static final int FUNCTION_FLOOR

FUNCTION_CEILING

public static final int FUNCTION_CEILING

FUNCTION_ROUND

public static final int FUNCTION_ROUND

FUNCTION_NULL

public static final int FUNCTION_NULL

FUNCTION_KEY

public static final int FUNCTION_KEY

FUNCTION_FORMAT_NUMBER

public static final int FUNCTION_FORMAT_NUMBER
Method Detail

number

public java.lang.Object number(java.lang.String value)
Produces an EXPRESSION object that represents a numeric constant.

literal

public java.lang.Object literal(java.lang.String value)
Produces an EXPRESSION object that represents a string constant.

qname

public java.lang.Object qname(java.lang.String prefix,
                              java.lang.String name)
Produces an QNAME that represents a name with an optional prefix.

sum

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

minus

public 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

multiply

public 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

divide

public 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

mod

public 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

lessThan

public 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

lessThanOrEqual

public 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

greaterThan

public 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

greaterThanOrEqual

public 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

equal

public 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

notEqual

public 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

minus

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

variableReference

public java.lang.Object variableReference(java.lang.Object qName)
Produces an EXPRESSION object representing variable reference
Parameters:
qname - is a QNAME object

function

public 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

function

public 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

and

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

or

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

union

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

nodeNameTest

public 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

nodeTypeTest

public java.lang.Object nodeTypeTest(int nodeType)
Produces a NODE_TEST object that represents a node type test.
Parameters:
qname - is a QNAME object

processingInstructionTest

public java.lang.Object processingInstructionTest(java.lang.String instruction)
Produces a NODE_TEST object that represents a processing instruction test.
Parameters:
qname - is a QNAME object

step

public 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

locationPath

public 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

expressionPath

public 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


Copyright © 2001-2003 Apache Software Foundation. All Rights Reserved.