org.apache.commons.jxpath.ri.compiler
Class TreeCompiler

java.lang.Object
  extended byorg.apache.commons.jxpath.ri.compiler.TreeCompiler
All Implemented Interfaces:
Compiler

public class TreeCompiler
extends java.lang.Object
implements Compiler

Version:
$Revision: 1.10 $ $Date: 2004/02/29 14:17:39 $
Author:
Dmitri Plotnikov

Field Summary
private static QName QNAME_NAME
           
 
Fields inherited from interface org.apache.commons.jxpath.ri.Compiler
AXIS_ANCESTOR, AXIS_ANCESTOR_OR_SELF, AXIS_ATTRIBUTE, AXIS_CHILD, AXIS_DESCENDANT, AXIS_DESCENDANT_OR_SELF, AXIS_FOLLOWING, AXIS_FOLLOWING_SIBLING, AXIS_NAMESPACE, AXIS_PARENT, AXIS_PRECEDING, AXIS_PRECEDING_SIBLING, AXIS_SELF, FUNCTION_BOOLEAN, FUNCTION_CEILING, FUNCTION_CONCAT, FUNCTION_CONTAINS, FUNCTION_COUNT, FUNCTION_FALSE, FUNCTION_FLOOR, FUNCTION_FORMAT_NUMBER, FUNCTION_ID, FUNCTION_KEY, FUNCTION_LANG, FUNCTION_LAST, FUNCTION_LOCAL_NAME, FUNCTION_NAME, FUNCTION_NAMESPACE_URI, FUNCTION_NORMALIZE_SPACE, FUNCTION_NOT, FUNCTION_NULL, FUNCTION_NUMBER, FUNCTION_POSITION, FUNCTION_ROUND, FUNCTION_STARTS_WITH, FUNCTION_STRING, FUNCTION_STRING_LENGTH, FUNCTION_SUBSTRING, FUNCTION_SUBSTRING_AFTER, FUNCTION_SUBSTRING_BEFORE, FUNCTION_SUM, FUNCTION_TRANSLATE, FUNCTION_TRUE, NODE_TYPE_COMMENT, NODE_TYPE_NODE, NODE_TYPE_PI, NODE_TYPE_TEXT
 
Constructor Summary
TreeCompiler()
           
 
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
private  boolean isNameAttributeTest(Expression arg)
           
 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
private  Expression[] toExpressionArray(java.lang.Object[] array)
           
private  Step[] toStepArray(java.lang.Object[] array)
           
 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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

QNAME_NAME

private static final QName QNAME_NAME
Constructor Detail

TreeCompiler

public TreeCompiler()
Method Detail

number

public java.lang.Object number(java.lang.String value)
Description copied from interface: Compiler
Produces an EXPRESSION object that represents a numeric constant.

Specified by:
number in interface Compiler

literal

public java.lang.Object literal(java.lang.String value)
Description copied from interface: Compiler
Produces an EXPRESSION object that represents a string constant.

Specified by:
literal in interface Compiler

qname

public java.lang.Object qname(java.lang.String prefix,
                              java.lang.String name)
Description copied from interface: Compiler
Produces an QNAME that represents a name with an optional prefix.

Specified by:
qname in interface Compiler

sum

public java.lang.Object sum(java.lang.Object[] arguments)
Description copied from interface: Compiler
Produces an EXPRESSION object representing the sum of all argumens

Specified by:
sum in interface Compiler
Parameters:
arguments - are EXPRESSION objects

minus

public java.lang.Object minus(java.lang.Object left,
                              java.lang.Object right)
Description copied from interface: Compiler
Produces an EXPRESSION object representing left minus right

Specified by:
minus in interface Compiler
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)
Description copied from interface: Compiler
Produces an EXPRESSION object representing left multiplied by right

Specified by:
multiply in interface Compiler
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)
Description copied from interface: Compiler
Produces an EXPRESSION object representing left divided by right

Specified by:
divide in interface Compiler
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)
Description copied from interface: Compiler
Produces an EXPRESSION object representing left modulo right

Specified by:
mod in interface Compiler
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)
Description copied from interface: Compiler
Produces an EXPRESSION object representing the comparison: left less than right

Specified by:
lessThan in interface Compiler
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)
Description copied from interface: Compiler
Produces an EXPRESSION object representing the comparison: left less than or equal to right

Specified by:
lessThanOrEqual in interface Compiler
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)
Description copied from interface: Compiler
Produces an EXPRESSION object representing the comparison: left greater than right

Specified by:
greaterThan in interface Compiler
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)
Description copied from interface: Compiler
Produces an EXPRESSION object representing the comparison: left greater than or equal to right

Specified by:
greaterThanOrEqual in interface Compiler
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)
Description copied from interface: Compiler
Produces an EXPRESSION object representing the comparison: left equals to right

Specified by:
equal in interface Compiler
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)
Description copied from interface: Compiler
Produces an EXPRESSION object representing the comparison: left is not equal to right

Specified by:
notEqual in interface Compiler
Parameters:
left - is an EXPRESSION object
right - is an EXPRESSION object

minus

public java.lang.Object minus(java.lang.Object argument)
Description copied from interface: Compiler
Produces an EXPRESSION object representing unary negation of the argument

Specified by:
minus in interface Compiler
Parameters:
argument - is an EXPRESSION object

variableReference

public java.lang.Object variableReference(java.lang.Object qName)
Description copied from interface: Compiler
Produces an EXPRESSION object representing variable reference

Specified by:
variableReference in interface Compiler

function

public java.lang.Object function(int code,
                                 java.lang.Object[] args)
Description copied from interface: Compiler
Produces an EXPRESSION object representing the computation of a core function with the supplied arguments.

Specified by:
function in interface Compiler
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)
Description copied from interface: Compiler
Produces an EXPRESSION object representing the computation of a library function with the supplied arguments.

Specified by:
function in interface Compiler
Parameters:
name - is a QNAME object (function name)
args - are EXPRESSION objects

and

public java.lang.Object and(java.lang.Object[] arguments)
Description copied from interface: Compiler
Produces an EXPRESSION object representing logical conjunction of all arguments

Specified by:
and in interface Compiler
Parameters:
arguments - are EXPRESSION objects

or

public java.lang.Object or(java.lang.Object[] arguments)
Description copied from interface: Compiler
Produces an EXPRESSION object representing logical disjunction of all arguments

Specified by:
or in interface Compiler
Parameters:
arguments - are EXPRESSION objects

union

public java.lang.Object union(java.lang.Object[] arguments)
Description copied from interface: Compiler
Produces an EXPRESSION object representing union of all node sets

Specified by:
union in interface Compiler
Parameters:
arguments - are EXPRESSION objects

locationPath

public java.lang.Object locationPath(boolean absolute,
                                     java.lang.Object[] steps)
Description copied from interface: Compiler
Produces an EXPRESSION object representing a location path

Specified by:
locationPath in interface Compiler
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)
Description copied from interface: Compiler
Produces an EXPRESSION object representing a filter expression

Specified by:
expressionPath in interface Compiler
Parameters:
expression - is an EXPRESSION object
predicates - are EXPRESSION objects
steps - are STEP objects

nodeNameTest

public java.lang.Object nodeNameTest(java.lang.Object qname)
Description copied from interface: Compiler
Produces a NODE_TEST object that represents a node name test.

Specified by:
nodeNameTest in interface Compiler
Parameters:
qname - is a QNAME object

nodeTypeTest

public java.lang.Object nodeTypeTest(int nodeType)
Description copied from interface: Compiler
Produces a NODE_TEST object that represents a node type test.

Specified by:
nodeTypeTest in interface Compiler

processingInstructionTest

public java.lang.Object processingInstructionTest(java.lang.String instruction)
Description copied from interface: Compiler
Produces a NODE_TEST object that represents a processing instruction test.

Specified by:
processingInstructionTest in interface Compiler

step

public java.lang.Object step(int axis,
                             java.lang.Object nodeTest,
                             java.lang.Object[] predicates)
Description copied from interface: Compiler
Produces a STEP object that represents a node test.

Specified by:
step in interface Compiler
Parameters:
axis - is one of the AXIS_... constants
nodeTest - is a NODE_TEST object
predicates - are EXPRESSION objects

toExpressionArray

private Expression[] toExpressionArray(java.lang.Object[] array)

toStepArray

private Step[] toStepArray(java.lang.Object[] array)

isNameAttributeTest

private boolean isNameAttributeTest(Expression arg)