org.jaxen

Class JaxenHandler

Implemented Interfaces:
XPathHandler
Known Direct Subclasses:
PatternHandler

public class JaxenHandler
extends java.lang.Object
implements XPathHandler

SAXPath XPathHandler implementation capable of building Jaxen expression trees which can walk various different object models.
Author:
bob mcwhirter (bob@werken.com)

Field Summary

protected boolean
simplified
????
protected LinkedList
stack
This may be changed to an ArrayList in the future (i.e.
private XPathExpr
xpath
private XPathFactory
xpathFactory

Constructor Summary

JaxenHandler()
Constructor

Method Summary

protected void
addParameters(FunctionCallExpr function, Iterator paramIter)
protected void
addPredicates(Predicated obj, Iterator predIter)
protected void
addSteps(LocationPath locationPath, Iterator stepIter)
protected boolean
canPop()
void
endAbsoluteLocationPath()
Receive notification of the end of an absolute location path expression.
void
endAdditiveExpr(int operator)
Receive notification of the end of an additive ('+' or '-') expression.
void
endAllNodeStep()
Receive notification of the end of a node() step.
void
endAndExpr(boolean create)
Receive notification of the end of an 'and' expression.
void
endCommentNodeStep()
Receive notification of the end of a comment() step.
void
endEqualityExpr(int operator)
Receive notification of the end of an equality ('=' or '!=') expression.
void
endFilterExpr()
Receive notification of the end of a filter expression.
void
endFunction()
Receive notification of the end of a function call
protected void
endLocationPath()
void
endMultiplicativeExpr(int operator)
Receive notification of the start of a multiplicative ('*', 'div' or 'mod') expression.
void
endNameStep()
Receive notification of the end of a NameStep
void
endOrExpr(boolean create)
Receive notification of the end of an 'or' expression.
void
endPathExpr()
Receive notification of the end of a path expression.
void
endPredicate()
Receive notification of the end of a predicate.
void
endProcessingInstructionNodeStep()
Receive notification of the end of a processing-instruction(...) step.
void
endRelationalExpr(int operator)
Receive notification of the start of a relational ('<', '>', '<=', or '>=') expression.
void
endRelativeLocationPath()
Receive notification of the end of a relative location path expression.
protected void
endStep()
void
endTextNodeStep()
Receive notification of the end of a text() step.
void
endUnaryExpr(int operator)
Receive notification of the end of a unary ('+' or '-') expression.
void
endUnionExpr(boolean create)
Receive notification of the end of a union ('|') expression.
void
endXPath()
Receive notification of the end of an XPath expression parse.
XPathExpr
getXPathExpr()
Retrieve the simplified Jaxen XPath expression tree.
XPathExpr
getXPathExpr(boolean shouldSimplify)
Retrieve the Jaxen XPath expression tree, optionally simplified.
XPathFactory
getXPathFactory()
Retrieve the Jaxen XPathFactory used during the parse to construct the XPath expression tree.
void
literal(String literal)
Receive notification of a literal expression.
void
number(double number)
Receive notification of a number expression.
void
number(int number)
Receive notification of a number expression.
protected LinkedList
peekFrame()
protected Object
pop()
protected LinkedList
popFrame()
protected void
push(Object obj)
protected void
pushFrame()
protected void
returnExpr()
void
setXPathFactory(XPathFactory xpathFactory)
Set the Jaxen XPathFactory that constructs the XPath expression tree during the parse.
protected int
stackSize()
void
startAbsoluteLocationPath()
Receive notification of the start of an absolute location path expression.
void
startAdditiveExpr()
Receive notification of the start of an additive ('+' or '-') expression.
void
startAllNodeStep(int axis)
Receive notification of the start of a node() step.
void
startAndExpr()
Receive notification of the start of an 'and' expression.
void
startCommentNodeStep(int axis)
Receive notification of the start of a comment() step.
void
startEqualityExpr()
Receive notification of the start of an equality ('=' or '!=') expression.
void
startFilterExpr()
Receive notification of the start of a filter expression.
void
startFunction(String prefix, String functionName)
Receive notification of a function call.
void
startMultiplicativeExpr()
Receive notification of the start of a multiplicative ('*', 'div' or 'mod') expression.
void
startNameStep(int axis, String prefix, String localName)
Receive notification of the start of a name step.
void
startOrExpr()
Receive notification of the start of an 'or' expression.
void
startPathExpr()
Receive notification of the start of a path expression.
void
startPredicate()
Receive notification of the start of a predicate.
void
startProcessingInstructionNodeStep(int axis, String name)
Receive notification of the start of a processing-instruction(...) step.
void
startRelationalExpr()
Receive notification of the start of a relational ('<', '>', '<=', or '>=') expression.
void
startRelativeLocationPath()
Receive notification of the start of a relative location path expression.
void
startTextNodeStep(int axis)
Receive notification of the start of a text() step.
void
startUnaryExpr()
Receive notification of the start of a unary ('+' or '-') expression.
void
startUnionExpr()
Receive notification of the start of a union ('|') expression.
void
startXPath()
Receive notification of the start of an XPath expression parse.
void
variableReference(String prefix, String variableName)
Receive notification of a variable-reference expression.

Field Details

simplified

protected boolean simplified
????

stack

protected LinkedList stack
This may be changed to an ArrayList in the future (i.e. version >= 1.2). You really shouldn't be accessing this field directly, but if you are please try to use it as a generic List. Don't use the methods that are only available in LinkedList.

xpath

private XPathExpr xpath

xpathFactory

private XPathFactory xpathFactory

Constructor Details

JaxenHandler

public JaxenHandler()
Constructor

Method Details

addParameters

protected void addParameters(FunctionCallExpr function,
                             Iterator paramIter)

addPredicates

protected void addPredicates(Predicated obj,
                             Iterator predIter)

addSteps

protected void addSteps(LocationPath locationPath,
                        Iterator stepIter)

canPop

protected boolean canPop()

endAbsoluteLocationPath

public void endAbsoluteLocationPath()
            throws JaxenException
Receive notification of the end of an absolute location path expression.
Specified by:
endAbsoluteLocationPath in interface XPathHandler

endAdditiveExpr

public void endAdditiveExpr(int operator)
            throws JaxenException
Receive notification of the end of an additive ('+' or '-') expression.
Specified by:
endAdditiveExpr in interface XPathHandler
Parameters:

endAllNodeStep

public void endAllNodeStep()
Receive notification of the end of a node() step.
Specified by:
endAllNodeStep in interface XPathHandler

endAndExpr

public void endAndExpr(boolean create)
            throws JaxenException
Receive notification of the end of an 'and' expression.
Specified by:
endAndExpr in interface XPathHandler
Parameters:
create - flag that indicates if this expression should truly be instantiated, or if it was just a pass-through, based upon the grammar productions

endCommentNodeStep

public void endCommentNodeStep()
Receive notification of the end of a comment() step.
Specified by:
endCommentNodeStep in interface XPathHandler

endEqualityExpr

public void endEqualityExpr(int operator)
            throws JaxenException
Receive notification of the end of an equality ('=' or '!=') expression.
Specified by:
endEqualityExpr in interface XPathHandler
Parameters:

endFilterExpr

public void endFilterExpr()
            throws JaxenException
Receive notification of the end of a filter expression.
Specified by:
endFilterExpr in interface XPathHandler

endFunction

public void endFunction()
Receive notification of the end of a function call
Specified by:
endFunction in interface XPathHandler

endLocationPath

protected void endLocationPath()
            throws JaxenException

endMultiplicativeExpr

public void endMultiplicativeExpr(int operator)
            throws JaxenException
Receive notification of the start of a multiplicative ('*', 'div' or 'mod') expression.
Specified by:
endMultiplicativeExpr in interface XPathHandler
Parameters:

endNameStep

public void endNameStep()
Receive notification of the end of a NameStep
Specified by:
endNameStep in interface XPathHandler

endOrExpr

public void endOrExpr(boolean create)
            throws JaxenException
Receive notification of the end of an 'or' expression.
Specified by:
endOrExpr in interface XPathHandler
Parameters:
create - flag that indicates if this expression should truly be instantiated, or if it was just a pass-through, based upon the grammar productions

endPathExpr

public void endPathExpr()
            throws JaxenException
Receive notification of the end of a path expression.
Specified by:
endPathExpr in interface XPathHandler

endPredicate

public void endPredicate()
            throws JaxenException
Receive notification of the end of a predicate.
Specified by:
endPredicate in interface XPathHandler

endProcessingInstructionNodeStep

public void endProcessingInstructionNodeStep()
Receive notification of the end of a processing-instruction(...) step.
Specified by:
endProcessingInstructionNodeStep in interface XPathHandler

endRelationalExpr

public void endRelationalExpr(int operator)
            throws JaxenException
Receive notification of the start of a relational ('<', '>', '<=', or '>=') expression.
Specified by:
endRelationalExpr in interface XPathHandler
Parameters:

endRelativeLocationPath

public void endRelativeLocationPath()
            throws JaxenException
Receive notification of the end of a relative location path expression.
Specified by:
endRelativeLocationPath in interface XPathHandler

endStep

protected void endStep()

endTextNodeStep

public void endTextNodeStep()
Receive notification of the end of a text() step.
Specified by:
endTextNodeStep in interface XPathHandler

endUnaryExpr

public void endUnaryExpr(int operator)
            throws JaxenException
Receive notification of the end of a unary ('+' or '-') expression.
Specified by:
endUnaryExpr in interface XPathHandler
Parameters:

endUnionExpr

public void endUnionExpr(boolean create)
            throws JaxenException
Receive notification of the end of a union ('|') expression.
Specified by:
endUnionExpr in interface XPathHandler
Parameters:
create - flag that indicates if this expression should truly be instantiated, or if it was just a pass-through, based upon the grammar productions

endXPath

public void endXPath()
            throws JaxenException
Receive notification of the end of an XPath expression parse.
Specified by:
endXPath in interface XPathHandler

getXPathExpr

public XPathExpr getXPathExpr()
Retrieve the simplified Jaxen XPath expression tree.

This method is only valid once XPathReader.parse(...) successfully returned.

Returns:
the XPath expression tree

getXPathExpr

public XPathExpr getXPathExpr(boolean shouldSimplify)
Retrieve the Jaxen XPath expression tree, optionally simplified.

This method is only valid once XPathReader.parse(...) successfully returned.

Parameters:
shouldSimplify - ????
Returns:
the XPath expression tree

getXPathFactory

public XPathFactory getXPathFactory()
Retrieve the Jaxen XPathFactory used during the parse to construct the XPath expression tree.
Returns:
the XPathFactory used during the parse.

literal

public void literal(String literal)
            throws JaxenException
Receive notification of a literal expression.
Specified by:
literal in interface XPathHandler
Parameters:
literal - the string literal value

number

public void number(double number)
            throws JaxenException
Receive notification of a number expression.
Specified by:
number in interface XPathHandler
Parameters:
number - the number value

number

public void number(int number)
            throws JaxenException
Receive notification of a number expression.
Specified by:
number in interface XPathHandler
Parameters:
number - the number value

peekFrame

protected LinkedList peekFrame()

pop

protected Object pop()

popFrame

protected LinkedList popFrame()

push

protected void push(Object obj)

pushFrame

protected void pushFrame()

returnExpr

protected void returnExpr()

setXPathFactory

public void setXPathFactory(XPathFactory xpathFactory)
Set the Jaxen XPathFactory that constructs the XPath expression tree during the parse.
Parameters:
xpathFactory - the factory to use during the parse

stackSize

protected int stackSize()

startAbsoluteLocationPath

public void startAbsoluteLocationPath()
            throws JaxenException
Receive notification of the start of an absolute location path expression.
Specified by:
startAbsoluteLocationPath in interface XPathHandler

startAdditiveExpr

public void startAdditiveExpr()
Receive notification of the start of an additive ('+' or '-') expression.
Specified by:
startAdditiveExpr in interface XPathHandler

startAllNodeStep

public void startAllNodeStep(int axis)
            throws JaxenException
Receive notification of the start of a node() step.
Specified by:
startAllNodeStep in interface XPathHandler
Parameters:
axis - the axis of this step

startAndExpr

public void startAndExpr()
Receive notification of the start of an 'and' expression.
Specified by:
startAndExpr in interface XPathHandler

startCommentNodeStep

public void startCommentNodeStep(int axis)
            throws JaxenException
Receive notification of the start of a comment() step.
Specified by:
startCommentNodeStep in interface XPathHandler
Parameters:
axis - the axis of this step

startEqualityExpr

public void startEqualityExpr()
Receive notification of the start of an equality ('=' or '!=') expression.
Specified by:
startEqualityExpr in interface XPathHandler

startFilterExpr

public void startFilterExpr()
Receive notification of the start of a filter expression.
Specified by:
startFilterExpr in interface XPathHandler

startFunction

public void startFunction(String prefix,
                          String functionName)
            throws JaxenException
Receive notification of a function call.
Specified by:
startFunction in interface XPathHandler
Parameters:
prefix - the namespace prefix of the function
functionName - the local name of the function

startMultiplicativeExpr

public void startMultiplicativeExpr()
Receive notification of the start of a multiplicative ('*', 'div' or 'mod') expression.
Specified by:
startMultiplicativeExpr in interface XPathHandler

startNameStep

public void startNameStep(int axis,
                          String prefix,
                          String localName)
            throws JaxenException
Receive notification of the start of a name step.
Specified by:
startNameStep in interface XPathHandler
Parameters:
axis - the axis of this step
prefix - the namespace prefix for the name to test, or the empty string if no prefix is specified
localName - the local part of the name to test

startOrExpr

public void startOrExpr()
Receive notification of the start of an 'or' expression.
Specified by:
startOrExpr in interface XPathHandler

startPathExpr

public void startPathExpr()
Receive notification of the start of a path expression.
Specified by:
startPathExpr in interface XPathHandler

startPredicate

public void startPredicate()
Receive notification of the start of a predicate.
Specified by:
startPredicate in interface XPathHandler

startProcessingInstructionNodeStep

public void startProcessingInstructionNodeStep(int axis,
                                               String name)
            throws JaxenException
Receive notification of the start of a processing-instruction(...) step.
Specified by:
startProcessingInstructionNodeStep in interface XPathHandler
Parameters:
axis - the axis of this step
name - the name of the processing-instruction, or the empty string if none is specified

startRelationalExpr

public void startRelationalExpr()
Receive notification of the start of a relational ('<', '>', '<=', or '>=') expression.
Specified by:
startRelationalExpr in interface XPathHandler

startRelativeLocationPath

public void startRelativeLocationPath()
            throws JaxenException
Receive notification of the start of a relative location path expression.
Specified by:
startRelativeLocationPath in interface XPathHandler

startTextNodeStep

public void startTextNodeStep(int axis)
            throws JaxenException
Receive notification of the start of a text() step.
Specified by:
startTextNodeStep in interface XPathHandler
Parameters:
axis - the axis of this step

startUnaryExpr

public void startUnaryExpr()
Receive notification of the start of a unary ('+' or '-') expression.
Specified by:
startUnaryExpr in interface XPathHandler

startUnionExpr

public void startUnionExpr()
Receive notification of the start of a union ('|') expression.
Specified by:
startUnionExpr in interface XPathHandler

startXPath

public void startXPath()
Receive notification of the start of an XPath expression parse.
Specified by:
startXPath in interface XPathHandler

variableReference

public void variableReference(String prefix,
                              String variableName)
            throws JaxenException
Receive notification of a variable-reference expression.
Specified by:
variableReference in interface XPathHandler
Parameters:
prefix - the namespace prefix of the variable
variableName - the local name of the variable