org.apache.commons.jxpath.ri

Interface Compiler

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.9 $ $Date: 2004/02/29 14:17:45 $
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

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

Field Details

AXIS_ANCESTOR

public static final int AXIS_ANCESTOR
Field Value:
4

AXIS_ANCESTOR_OR_SELF

public static final int AXIS_ANCESTOR_OR_SELF
Field Value:
10

AXIS_ATTRIBUTE

public static final int AXIS_ATTRIBUTE
Field Value:
5

AXIS_CHILD

public static final int AXIS_CHILD
Field Value:
2

AXIS_DESCENDANT

public static final int AXIS_DESCENDANT
Field Value:
9

AXIS_DESCENDANT_OR_SELF

public static final int AXIS_DESCENDANT_OR_SELF
Field Value:
13

AXIS_FOLLOWING

public static final int AXIS_FOLLOWING
Field Value:
8

AXIS_FOLLOWING_SIBLING

public static final int AXIS_FOLLOWING_SIBLING
Field Value:
11

AXIS_NAMESPACE

public static final int AXIS_NAMESPACE
Field Value:
6

AXIS_PARENT

public static final int AXIS_PARENT
Field Value:
3

AXIS_PRECEDING

public static final int AXIS_PRECEDING
Field Value:
7

AXIS_PRECEDING_SIBLING

public static final int AXIS_PRECEDING_SIBLING
Field Value:
12

AXIS_SELF

public static final int AXIS_SELF
Field Value:
1

FUNCTION_BOOLEAN

public static final int FUNCTION_BOOLEAN
Field Value:
18

FUNCTION_CEILING

public static final int FUNCTION_CEILING
Field Value:
26

FUNCTION_CONCAT

public static final int FUNCTION_CONCAT
Field Value:
9

FUNCTION_CONTAINS

public static final int FUNCTION_CONTAINS
Field Value:
11

FUNCTION_COUNT

public static final int FUNCTION_COUNT
Field Value:
3

FUNCTION_FALSE

public static final int FUNCTION_FALSE
Field Value:
21

FUNCTION_FLOOR

public static final int FUNCTION_FLOOR
Field Value:
25

FUNCTION_FORMAT_NUMBER

public static final int FUNCTION_FORMAT_NUMBER
Field Value:
30

FUNCTION_ID

public static final int FUNCTION_ID
Field Value:
4

FUNCTION_KEY

public static final int FUNCTION_KEY
Field Value:
29

FUNCTION_LANG

public static final int FUNCTION_LANG
Field Value:
22

FUNCTION_LAST

public static final int FUNCTION_LAST
Field Value:
1

FUNCTION_LOCAL_NAME

public static final int FUNCTION_LOCAL_NAME
Field Value:
5

FUNCTION_NAME

public static final int FUNCTION_NAME
Field Value:
7

FUNCTION_NAMESPACE_URI

public static final int FUNCTION_NAMESPACE_URI
Field Value:
6

FUNCTION_NORMALIZE_SPACE

public static final int FUNCTION_NORMALIZE_SPACE
Field Value:
16

FUNCTION_NOT

public static final int FUNCTION_NOT
Field Value:
19

FUNCTION_NULL

public static final int FUNCTION_NULL
Field Value:
28

FUNCTION_NUMBER

public static final int FUNCTION_NUMBER
Field Value:
23

FUNCTION_POSITION

public static final int FUNCTION_POSITION
Field Value:
2

FUNCTION_ROUND

public static final int FUNCTION_ROUND
Field Value:
27

FUNCTION_STARTS_WITH

public static final int FUNCTION_STARTS_WITH
Field Value:
10

FUNCTION_STRING

public static final int FUNCTION_STRING
Field Value:
8

FUNCTION_STRING_LENGTH

public static final int FUNCTION_STRING_LENGTH
Field Value:
15

FUNCTION_SUBSTRING

public static final int FUNCTION_SUBSTRING
Field Value:
14

FUNCTION_SUBSTRING_AFTER

public static final int FUNCTION_SUBSTRING_AFTER
Field Value:
13

FUNCTION_SUBSTRING_BEFORE

public static final int FUNCTION_SUBSTRING_BEFORE
Field Value:
12

FUNCTION_SUM

public static final int FUNCTION_SUM
Field Value:
24

FUNCTION_TRANSLATE

public static final int FUNCTION_TRANSLATE
Field Value:
17

FUNCTION_TRUE

public static final int FUNCTION_TRUE
Field Value:
20

NODE_TYPE_COMMENT

public static final int NODE_TYPE_COMMENT
Field Value:
3

NODE_TYPE_NODE

public static final int NODE_TYPE_NODE
Field Value:
1

NODE_TYPE_PI

public static final int NODE_TYPE_PI
Field Value:
4

NODE_TYPE_TEXT

public static final int NODE_TYPE_TEXT
Field Value:
2

Method Details

and

public Object and(arguments[] )
Produces an EXPRESSION object representing logical conjunction of all arguments
Parameters:

divide

public Object divide(Object left,
                     Object right)
Produces an EXPRESSION object representing left divided by right
Parameters:
left - is an EXPRESSION object
right - is an EXPRESSION object

equal

public Object equal(Object left,
                    Object right)
Produces an EXPRESSION object representing the comparison: left equals to right
Parameters:
left - is an EXPRESSION object
right - is an EXPRESSION object

expressionPath

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

function

public Object function(Object name,
                       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

function

public Object function(int code,
                       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

greaterThan

public Object greaterThan(Object left,
                          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 Object greaterThanOrEqual(Object left,
                                 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

lessThan

public Object lessThan(Object left,
                       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 Object lessThanOrEqual(Object left,
                              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

literal

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

locationPath

public Object locationPath(boolean absolute,
                           Object[] steps)
Produces an EXPRESSION object representing a location path
Parameters:
absolute - indicates whether the path is absolute
steps - are STEP objects

minus

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

minus

public Object minus(Object left,
                    Object right)
Produces an EXPRESSION object representing left minus right
Parameters:
left - is an EXPRESSION object
right - is an EXPRESSION object

mod

public Object mod(Object left,
                  Object right)
Produces an EXPRESSION object representing left modulo right
Parameters:
left - is an EXPRESSION object
right - is an EXPRESSION object

multiply

public Object multiply(Object left,
                       Object right)
Produces an EXPRESSION object representing left multiplied by right
Parameters:
left - is an EXPRESSION object
right - is an EXPRESSION object

nodeNameTest

public Object nodeNameTest(Object qname)
Produces a NODE_TEST object that represents a node name test.
Parameters:
qname - is a QNAME object

nodeTypeTest

public Object nodeTypeTest(int nodeType)
Produces a NODE_TEST object that represents a node type test.
Parameters:

notEqual

public Object notEqual(Object left,
                       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

number

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

or

public Object or(arguments[] )
Produces an EXPRESSION object representing logical disjunction of all arguments
Parameters:

processingInstructionTest

public Object processingInstructionTest(String instruction)
Produces a NODE_TEST object that represents a processing instruction test.
Parameters:

qname

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

step

public Object step(int axis,
                   Object nodeTest,
                   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

sum

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

union

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

variableReference

public Object variableReference(Object qName)
Produces an EXPRESSION object representing variable reference
Parameters: