Package org.jaxen
Class JaxenHandler
- java.lang.Object
-
- org.jaxen.JaxenHandler
-
- All Implemented Interfaces:
XPathHandler
- Direct Known Subclasses:
PatternHandler
public class JaxenHandler extends java.lang.Object implements XPathHandler
SAXPathXPathHandlerimplementation capable of building Jaxen expression trees which can walk various different object models.- Author:
- bob mcwhirter (bob@werken.com)
-
-
Field Summary
Fields Modifier and Type Field Description protected booleansimplified????protected java.util.LinkedListstackThis may be changed to an ArrayList in the future (i.e.
-
Constructor Summary
Constructors Constructor Description JaxenHandler()Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddParameters(FunctionCallExpr function, java.util.Iterator paramIter)protected voidaddPredicates(Predicated obj, java.util.Iterator predIter)protected voidaddSteps(LocationPath locationPath, java.util.Iterator stepIter)protected booleancanPop()voidendAbsoluteLocationPath()Receive notification of the end of an absolute location path expression.voidendAdditiveExpr(int operator)Receive notification of the end of an additive ('+' or '-') expression.voidendAllNodeStep()Receive notification of the end of a node() step.voidendAndExpr(boolean create)Receive notification of the end of an 'and' expression.voidendCommentNodeStep()Receive notification of the end of a comment() step.voidendEqualityExpr(int operator)Receive notification of the end of an equality ('=' or '!=') expression.voidendFilterExpr()Receive notification of the end of a filter expression.voidendFunction()Receive notification of the end of a function callprotected voidendLocationPath()voidendMultiplicativeExpr(int operator)Receive notification of the start of a multiplicative ('*', 'div' or 'mod') expression.voidendNameStep()Receive notification of the end of a NameStepvoidendOrExpr(boolean create)Receive notification of the end of an 'or' expression.voidendPathExpr()Receive notification of the end of a path expression.voidendPredicate()Receive notification of the end of a predicate.voidendProcessingInstructionNodeStep()Receive notification of the end of a processing-instruction(...) step.voidendRelationalExpr(int operator)Receive notification of the start of a relational ('<', '>', '<=', or '>=') expression.voidendRelativeLocationPath()Receive notification of the end of a relative location path expression.protected voidendStep()voidendTextNodeStep()Receive notification of the end of a text() step.voidendUnaryExpr(int operator)Receive notification of the end of a unary ('+' or '-') expression.voidendUnionExpr(boolean create)Receive notification of the end of a union ('|') expression.voidendXPath()Receive notification of the end of an XPath expression parse.XPathExprgetXPathExpr()Retrieve the simplified Jaxen XPath expression tree.XPathExprgetXPathExpr(boolean shouldSimplify)Retrieve the Jaxen XPath expression tree, optionally simplified.XPathFactorygetXPathFactory()Retrieve the JaxenXPathFactoryused during the parse to construct the XPath expression tree.voidliteral(java.lang.String literal)Receive notification of a literal expression.voidnumber(double number)Receive notification of a number expression.voidnumber(int number)Receive notification of a number expression.protected java.util.LinkedListpeekFrame()protected java.lang.Objectpop()protected java.util.LinkedListpopFrame()protected voidpush(java.lang.Object obj)protected voidpushFrame()protected voidreturnExpr()voidsetXPathFactory(XPathFactory xpathFactory)Set the JaxenXPathFactorythat constructs the XPath expression tree during the parse.protected intstackSize()voidstartAbsoluteLocationPath()Receive notification of the start of an absolute location path expression.voidstartAdditiveExpr()Receive notification of the start of an additive ('+' or '-') expression.voidstartAllNodeStep(int axis)Receive notification of the start of a node() step.voidstartAndExpr()Receive notification of the start of an 'and' expression.voidstartCommentNodeStep(int axis)Receive notification of the start of a comment() step.voidstartEqualityExpr()Receive notification of the start of an equality ('=' or '!=') expression.voidstartFilterExpr()Receive notification of the start of a filter expression.voidstartFunction(java.lang.String prefix, java.lang.String functionName)Receive notification of a function call.voidstartMultiplicativeExpr()Receive notification of the start of a multiplicative ('*', 'div' or 'mod') expression.voidstartNameStep(int axis, java.lang.String prefix, java.lang.String localName)Receive notification of the start of a name step.voidstartOrExpr()Receive notification of the start of an 'or' expression.voidstartPathExpr()Receive notification of the start of a path expression.voidstartPredicate()Receive notification of the start of a predicate.voidstartProcessingInstructionNodeStep(int axis, java.lang.String name)Receive notification of the start of a processing-instruction(...) step.voidstartRelationalExpr()Receive notification of the start of a relational ('<', '>', '<=', or '>=') expression.voidstartRelativeLocationPath()Receive notification of the start of a relative location path expression.voidstartTextNodeStep(int axis)Receive notification of the start of a text() step.voidstartUnaryExpr()Receive notification of the start of a unary ('+' or '-') expression.voidstartUnionExpr()Receive notification of the start of a union ('|') expression.voidstartXPath()Receive notification of the start of an XPath expression parse.voidvariableReference(java.lang.String prefix, java.lang.String variableName)Receive notification of a variable-reference expression.
-
-
-
Field Detail
-
simplified
protected boolean simplified
????
-
stack
protected java.util.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.
-
-
Method Detail
-
setXPathFactory
public void setXPathFactory(XPathFactory xpathFactory)
Set the JaxenXPathFactorythat constructs the XPath expression tree during the parse.- Parameters:
xpathFactory- the factory to use during the parse
-
getXPathFactory
public XPathFactory getXPathFactory()
Retrieve the JaxenXPathFactoryused during the parse to construct the XPath expression tree.- Returns:
- the
XPathFactoryused during the parse.
-
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
-
startXPath
public void startXPath()
Description copied from interface:XPathHandlerReceive notification of the start of an XPath expression parse.- Specified by:
startXPathin interfaceXPathHandler
-
endXPath
public void endXPath() throws JaxenExceptionDescription copied from interface:XPathHandlerReceive notification of the end of an XPath expression parse.- Specified by:
endXPathin interfaceXPathHandler- Throws:
JaxenException
-
startPathExpr
public void startPathExpr()
Description copied from interface:XPathHandlerReceive notification of the start of a path expression.- Specified by:
startPathExprin interfaceXPathHandler
-
endPathExpr
public void endPathExpr() throws JaxenExceptionDescription copied from interface:XPathHandlerReceive notification of the end of a path expression.- Specified by:
endPathExprin interfaceXPathHandler- Throws:
JaxenException
-
startAbsoluteLocationPath
public void startAbsoluteLocationPath() throws JaxenExceptionDescription copied from interface:XPathHandlerReceive notification of the start of an absolute location path expression.- Specified by:
startAbsoluteLocationPathin interfaceXPathHandler- Throws:
JaxenException
-
endAbsoluteLocationPath
public void endAbsoluteLocationPath() throws JaxenExceptionDescription copied from interface:XPathHandlerReceive notification of the end of an absolute location path expression.- Specified by:
endAbsoluteLocationPathin interfaceXPathHandler- Throws:
JaxenException
-
startRelativeLocationPath
public void startRelativeLocationPath() throws JaxenExceptionDescription copied from interface:XPathHandlerReceive notification of the start of a relative location path expression.- Specified by:
startRelativeLocationPathin interfaceXPathHandler- Throws:
JaxenException
-
endRelativeLocationPath
public void endRelativeLocationPath() throws JaxenExceptionDescription copied from interface:XPathHandlerReceive notification of the end of a relative location path expression.- Specified by:
endRelativeLocationPathin interfaceXPathHandler- Throws:
JaxenException
-
endLocationPath
protected void endLocationPath() throws JaxenException- Throws:
JaxenException
-
addSteps
protected void addSteps(LocationPath locationPath, java.util.Iterator stepIter)
-
startNameStep
public void startNameStep(int axis, java.lang.String prefix, java.lang.String localName) throws JaxenExceptionDescription copied from interface:XPathHandlerReceive notification of the start of a name step.- Specified by:
startNameStepin interfaceXPathHandler- Parameters:
axis- the axis of this stepprefix- the namespace prefix for the name to test, or the empty string if no prefix is specifiedlocalName- the local part of the name to test- Throws:
JaxenException
-
endNameStep
public void endNameStep()
Description copied from interface:XPathHandlerReceive notification of the end of a NameStep- Specified by:
endNameStepin interfaceXPathHandler
-
startTextNodeStep
public void startTextNodeStep(int axis) throws JaxenExceptionDescription copied from interface:XPathHandlerReceive notification of the start of a text() step.- Specified by:
startTextNodeStepin interfaceXPathHandler- Parameters:
axis- the axis of this step- Throws:
JaxenException
-
endTextNodeStep
public void endTextNodeStep()
Description copied from interface:XPathHandlerReceive notification of the end of a text() step.- Specified by:
endTextNodeStepin interfaceXPathHandler
-
startCommentNodeStep
public void startCommentNodeStep(int axis) throws JaxenExceptionDescription copied from interface:XPathHandlerReceive notification of the start of a comment() step.- Specified by:
startCommentNodeStepin interfaceXPathHandler- Parameters:
axis- the axis of this step- Throws:
JaxenException
-
endCommentNodeStep
public void endCommentNodeStep()
Description copied from interface:XPathHandlerReceive notification of the end of a comment() step.- Specified by:
endCommentNodeStepin interfaceXPathHandler
-
startAllNodeStep
public void startAllNodeStep(int axis) throws JaxenExceptionDescription copied from interface:XPathHandlerReceive notification of the start of a node() step.- Specified by:
startAllNodeStepin interfaceXPathHandler- Parameters:
axis- the axis of this step- Throws:
JaxenException
-
endAllNodeStep
public void endAllNodeStep()
Description copied from interface:XPathHandlerReceive notification of the end of a node() step.- Specified by:
endAllNodeStepin interfaceXPathHandler
-
startProcessingInstructionNodeStep
public void startProcessingInstructionNodeStep(int axis, java.lang.String name) throws JaxenExceptionDescription copied from interface:XPathHandlerReceive notification of the start of a processing-instruction(...) step.- Specified by:
startProcessingInstructionNodeStepin interfaceXPathHandler- Parameters:
axis- the axis of this stepname- the name of the processing-instruction, or the empty string if none is specified- Throws:
JaxenException
-
endProcessingInstructionNodeStep
public void endProcessingInstructionNodeStep()
Description copied from interface:XPathHandlerReceive notification of the end of a processing-instruction(...) step.- Specified by:
endProcessingInstructionNodeStepin interfaceXPathHandler
-
endStep
protected void endStep()
-
startPredicate
public void startPredicate()
Description copied from interface:XPathHandlerReceive notification of the start of a predicate.- Specified by:
startPredicatein interfaceXPathHandler
-
endPredicate
public void endPredicate() throws JaxenExceptionDescription copied from interface:XPathHandlerReceive notification of the end of a predicate.- Specified by:
endPredicatein interfaceXPathHandler- Throws:
JaxenException
-
startFilterExpr
public void startFilterExpr()
Description copied from interface:XPathHandlerReceive notification of the start of a filter expression.- Specified by:
startFilterExprin interfaceXPathHandler
-
endFilterExpr
public void endFilterExpr() throws JaxenExceptionDescription copied from interface:XPathHandlerReceive notification of the end of a filter expression.- Specified by:
endFilterExprin interfaceXPathHandler- Throws:
JaxenException
-
addPredicates
protected void addPredicates(Predicated obj, java.util.Iterator predIter)
-
returnExpr
protected void returnExpr()
-
startOrExpr
public void startOrExpr()
Description copied from interface:XPathHandlerReceive notification of the start of an 'or' expression.- Specified by:
startOrExprin interfaceXPathHandler
-
endOrExpr
public void endOrExpr(boolean create) throws JaxenExceptionDescription copied from interface:XPathHandlerReceive notification of the end of an 'or' expression.- Specified by:
endOrExprin interfaceXPathHandler- 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- Throws:
JaxenException
-
startAndExpr
public void startAndExpr()
Description copied from interface:XPathHandlerReceive notification of the start of an 'and' expression.- Specified by:
startAndExprin interfaceXPathHandler
-
endAndExpr
public void endAndExpr(boolean create) throws JaxenExceptionDescription copied from interface:XPathHandlerReceive notification of the end of an 'and' expression.- Specified by:
endAndExprin interfaceXPathHandler- 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- Throws:
JaxenException
-
startEqualityExpr
public void startEqualityExpr()
Description copied from interface:XPathHandlerReceive notification of the start of an equality ('=' or '!=') expression.- Specified by:
startEqualityExprin interfaceXPathHandler
-
endEqualityExpr
public void endEqualityExpr(int operator) throws JaxenExceptionDescription copied from interface:XPathHandlerReceive notification of the end of an equality ('=' or '!=') expression.- Specified by:
endEqualityExprin interfaceXPathHandler- Parameters:
operator- the operator specific to this particular equality expression. If null, this expression is only a pass-through, and should not actually be instantiated.- Throws:
JaxenException
-
startRelationalExpr
public void startRelationalExpr()
Description copied from interface:XPathHandlerReceive notification of the start of a relational ('<', '>', '<=', or '>=') expression.- Specified by:
startRelationalExprin interfaceXPathHandler
-
endRelationalExpr
public void endRelationalExpr(int operator) throws JaxenExceptionDescription copied from interface:XPathHandlerReceive notification of the start of a relational ('<', '>', '<=', or '>=') expression.- Specified by:
endRelationalExprin interfaceXPathHandler- Parameters:
operator- the operator specific to this particular relational expression. If NO_OP, this expression is only a pass-through, and should not actually be instantiated.- Throws:
JaxenException
-
startAdditiveExpr
public void startAdditiveExpr()
Description copied from interface:XPathHandlerReceive notification of the start of an additive ('+' or '-') expression.- Specified by:
startAdditiveExprin interfaceXPathHandler
-
endAdditiveExpr
public void endAdditiveExpr(int operator) throws JaxenExceptionDescription copied from interface:XPathHandlerReceive notification of the end of an additive ('+' or '-') expression.- Specified by:
endAdditiveExprin interfaceXPathHandler- Parameters:
operator- the operator specific to this particular additive expression. If NO_OP, this expression is only a pass-through, and should not actually be instantiated.- Throws:
JaxenException
-
startMultiplicativeExpr
public void startMultiplicativeExpr()
Description copied from interface:XPathHandlerReceive notification of the start of a multiplicative ('*', 'div' or 'mod') expression.- Specified by:
startMultiplicativeExprin interfaceXPathHandler
-
endMultiplicativeExpr
public void endMultiplicativeExpr(int operator) throws JaxenExceptionDescription copied from interface:XPathHandlerReceive notification of the start of a multiplicative ('*', 'div' or 'mod') expression.- Specified by:
endMultiplicativeExprin interfaceXPathHandler- Parameters:
operator- the operator specific to this particular multiplicative expression. If null, this expression is only a pass-through, and should not actually be instantiated.- Throws:
JaxenException
-
startUnaryExpr
public void startUnaryExpr()
Description copied from interface:XPathHandlerReceive notification of the start of a unary ('+' or '-') expression.- Specified by:
startUnaryExprin interfaceXPathHandler
-
endUnaryExpr
public void endUnaryExpr(int operator) throws JaxenExceptionDescription copied from interface:XPathHandlerReceive notification of the end of a unary ('+' or '-') expression.- Specified by:
endUnaryExprin interfaceXPathHandler- Parameters:
operator- the operator specific to this particular unary expression. If NO_OP, this expression is only a pass-through, and should not actually be instantiated. If notOperator.NO_OP, it will always beOperator.NEGATIVE.- Throws:
JaxenException
-
startUnionExpr
public void startUnionExpr()
Description copied from interface:XPathHandlerReceive notification of the start of a union ('|') expression.- Specified by:
startUnionExprin interfaceXPathHandler
-
endUnionExpr
public void endUnionExpr(boolean create) throws JaxenExceptionDescription copied from interface:XPathHandlerReceive notification of the end of a union ('|') expression.- Specified by:
endUnionExprin interfaceXPathHandler- 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- Throws:
JaxenException
-
number
public void number(int number) throws JaxenExceptionDescription copied from interface:XPathHandlerReceive notification of a number expression.- Specified by:
numberin interfaceXPathHandler- Parameters:
number- the number value- Throws:
JaxenException
-
number
public void number(double number) throws JaxenExceptionDescription copied from interface:XPathHandlerReceive notification of a number expression.- Specified by:
numberin interfaceXPathHandler- Parameters:
number- the number value- Throws:
JaxenException
-
literal
public void literal(java.lang.String literal) throws JaxenExceptionDescription copied from interface:XPathHandlerReceive notification of a literal expression.- Specified by:
literalin interfaceXPathHandler- Parameters:
literal- the string literal value- Throws:
JaxenException
-
variableReference
public void variableReference(java.lang.String prefix, java.lang.String variableName) throws JaxenExceptionDescription copied from interface:XPathHandlerReceive notification of a variable-reference expression.- Specified by:
variableReferencein interfaceXPathHandler- Parameters:
prefix- the namespace prefix of the variablevariableName- the local name of the variable- Throws:
JaxenException
-
startFunction
public void startFunction(java.lang.String prefix, java.lang.String functionName) throws JaxenExceptionDescription copied from interface:XPathHandlerReceive notification of a function call.- Specified by:
startFunctionin interfaceXPathHandler- Parameters:
prefix- the namespace prefix of the functionfunctionName- the local name of the function- Throws:
JaxenException
-
endFunction
public void endFunction()
Description copied from interface:XPathHandlerReceive notification of the end of a function call- Specified by:
endFunctionin interfaceXPathHandler
-
addParameters
protected void addParameters(FunctionCallExpr function, java.util.Iterator paramIter)
-
stackSize
protected int stackSize()
-
push
protected void push(java.lang.Object obj)
-
pop
protected java.lang.Object pop()
-
canPop
protected boolean canPop()
-
pushFrame
protected void pushFrame()
-
popFrame
protected java.util.LinkedList popFrame()
-
peekFrame
protected java.util.LinkedList peekFrame()
-
-