org.jaxen
Class JaxenHandler

java.lang.Object
  extended byorg.jaxen.JaxenHandler
All Implemented Interfaces:
XPathHandler
Direct Known 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  java.util.LinkedList stack
           
 
Constructor Summary
JaxenHandler()
          Construct.
 
Method Summary
protected  void addParameters(FunctionCallExpr function, java.util.Iterator paramIter)
           
protected  void addPredicates(Predicated obj, java.util.Iterator predIter)
           
protected  void addSteps(LocationPath locationPath, java.util.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(java.lang.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  java.util.LinkedList peekFrame()
           
protected  java.lang.Object pop()
           
protected  java.util.LinkedList popFrame()
           
protected  void push(java.lang.Object obj)
           
protected  void pushFrame()
           
protected  void returnExpr()
           
 void setXPathFactory(XPathFactory xpathFactory)
          Set the Jaxen XPathFactory to use during the parse to construct the XPath expression tree.
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(java.lang.String prefix, java.lang.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, java.lang.String prefix, java.lang.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, java.lang.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(java.lang.String prefix, java.lang.String variableName)
          Receive notification of a variable-reference expression.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

simplified

protected boolean simplified

stack

protected java.util.LinkedList stack
Constructor Detail

JaxenHandler

public JaxenHandler()
Construct.

Method Detail

setXPathFactory

public void setXPathFactory(XPathFactory xpathFactory)
Set the Jaxen XPathFactory to use during the parse to construct the XPath expression tree.

Parameters:
xpathFactory - the factory to use during the parse

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.

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.

Returns:
the XPath expression tree

startXPath

public void startXPath()
                throws JaxenException
Description copied from interface: XPathHandler
Receive notification of the start of an XPath expression parse.

Specified by:
startXPath in interface XPathHandler
Throws:
JaxenException

endXPath

public void endXPath()
              throws JaxenException
Description copied from interface: XPathHandler
Receive notification of the end of an XPath expression parse.

Specified by:
endXPath in interface XPathHandler
Throws:
JaxenException

startPathExpr

public void startPathExpr()
                   throws JaxenException
Description copied from interface: XPathHandler
Receive notification of the start of a path expression.

Specified by:
startPathExpr in interface XPathHandler
Throws:
JaxenException

endPathExpr

public void endPathExpr()
                 throws JaxenException
Description copied from interface: XPathHandler
Receive notification of the end of a path expression.

Specified by:
endPathExpr in interface XPathHandler
Throws:
JaxenException

startAbsoluteLocationPath

public void startAbsoluteLocationPath()
                               throws JaxenException
Description copied from interface: XPathHandler
Receive notification of the start of an absolute location path expression.

Specified by:
startAbsoluteLocationPath in interface XPathHandler
Throws:
JaxenException

endAbsoluteLocationPath

public void endAbsoluteLocationPath()
                             throws JaxenException
Description copied from interface: XPathHandler
Receive notification of the end of an absolute location path expression.

Specified by:
endAbsoluteLocationPath in interface XPathHandler
Throws:
JaxenException

startRelativeLocationPath

public void startRelativeLocationPath()
                               throws JaxenException
Description copied from interface: XPathHandler
Receive notification of the start of a relative location path expression.

Specified by:
startRelativeLocationPath in interface XPathHandler
Throws:
JaxenException

endRelativeLocationPath

public void endRelativeLocationPath()
                             throws JaxenException
Description copied from interface: XPathHandler
Receive notification of the end of a relative location path expression.

Specified by:
endRelativeLocationPath in interface XPathHandler
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 JaxenException
Description copied from interface: XPathHandler
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
Throws:
JaxenException

endNameStep

public void endNameStep()
                 throws JaxenException
Description copied from interface: XPathHandler
Receive notification of the end of a NameStep

Specified by:
endNameStep in interface XPathHandler
Throws:
JaxenException

startTextNodeStep

public void startTextNodeStep(int axis)
                       throws JaxenException
Description copied from interface: XPathHandler
Receive notification of the start of a text() step.

Specified by:
startTextNodeStep in interface XPathHandler
Parameters:
axis - the axis of this step
Throws:
JaxenException

endTextNodeStep

public void endTextNodeStep()
                     throws JaxenException
Description copied from interface: XPathHandler
Receive notification of the end of a text() step.

Specified by:
endTextNodeStep in interface XPathHandler
Throws:
JaxenException

startCommentNodeStep

public void startCommentNodeStep(int axis)
                          throws JaxenException
Description copied from interface: XPathHandler
Receive notification of the start of a comment() step.

Specified by:
startCommentNodeStep in interface XPathHandler
Parameters:
axis - the axis of this step
Throws:
JaxenException

endCommentNodeStep

public void endCommentNodeStep()
                        throws JaxenException
Description copied from interface: XPathHandler
Receive notification of the end of a comment() step.

Specified by:
endCommentNodeStep in interface XPathHandler
Throws:
JaxenException

startAllNodeStep

public void startAllNodeStep(int axis)
                      throws JaxenException
Description copied from interface: XPathHandler
Receive notification of the start of a node() step.

Specified by:
startAllNodeStep in interface XPathHandler
Parameters:
axis - the axis of this step
Throws:
JaxenException

endAllNodeStep

public void endAllNodeStep()
                    throws JaxenException
Description copied from interface: XPathHandler
Receive notification of the end of a node() step.

Specified by:
endAllNodeStep in interface XPathHandler
Throws:
JaxenException

startProcessingInstructionNodeStep

public void startProcessingInstructionNodeStep(int axis,
                                               java.lang.String name)
                                        throws JaxenException
Description copied from interface: XPathHandler
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
Throws:
JaxenException

endProcessingInstructionNodeStep

public void endProcessingInstructionNodeStep()
                                      throws JaxenException
Description copied from interface: XPathHandler
Receive notification of the end of a processing-instruction(...) step.

Specified by:
endProcessingInstructionNodeStep in interface XPathHandler
Throws:
JaxenException

endStep

protected void endStep()

startPredicate

public void startPredicate()
                    throws JaxenException
Description copied from interface: XPathHandler
Receive notification of the start of a predicate.

Specified by:
startPredicate in interface XPathHandler
Throws:
JaxenException

endPredicate

public void endPredicate()
                  throws JaxenException
Description copied from interface: XPathHandler
Receive notification of the end of a predicate.

Specified by:
endPredicate in interface XPathHandler
Throws:
JaxenException

startFilterExpr

public void startFilterExpr()
                     throws JaxenException
Description copied from interface: XPathHandler
Receive notification of the start of a filter expression.

Specified by:
startFilterExpr in interface XPathHandler
Throws:
JaxenException

endFilterExpr

public void endFilterExpr()
                   throws JaxenException
Description copied from interface: XPathHandler
Receive notification of the end of a filter expression.

Specified by:
endFilterExpr in interface XPathHandler
Throws:
JaxenException

addPredicates

protected void addPredicates(Predicated obj,
                             java.util.Iterator predIter)

returnExpr

protected void returnExpr()

startOrExpr

public void startOrExpr()
                 throws JaxenException
Description copied from interface: XPathHandler
Receive notification of the start of an 'or' expression.

Specified by:
startOrExpr in interface XPathHandler
Throws:
JaxenException

endOrExpr

public void endOrExpr(boolean create)
               throws JaxenException
Description copied from interface: XPathHandler
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
Throws:
JaxenException

startAndExpr

public void startAndExpr()
                  throws JaxenException
Description copied from interface: XPathHandler
Receive notification of the start of an 'and' expression.

Specified by:
startAndExpr in interface XPathHandler
Throws:
JaxenException

endAndExpr

public void endAndExpr(boolean create)
                throws JaxenException
Description copied from interface: XPathHandler
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
Throws:
JaxenException

startEqualityExpr

public void startEqualityExpr()
                       throws JaxenException
Description copied from interface: XPathHandler
Receive notification of the start of an equality ('=' or '!=') expression.

Specified by:
startEqualityExpr in interface XPathHandler
Throws:
JaxenException

endEqualityExpr

public void endEqualityExpr(int operator)
                     throws JaxenException
Description copied from interface: XPathHandler
Receive notification of the end of an equality ('=' or '!=') expression.

Specified by:
endEqualityExpr in interface XPathHandler
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()
                         throws JaxenException
Description copied from interface: XPathHandler
Receive notification of the start of a relational ('<', '>', '<=', or '>=') expression.

Specified by:
startRelationalExpr in interface XPathHandler
Throws:
JaxenException

endRelationalExpr

public void endRelationalExpr(int operator)
                       throws JaxenException
Description copied from interface: XPathHandler
Receive notification of the start of a relational ('<', '>', '<=', or '>=') expression.

Specified by:
endRelationalExpr in interface XPathHandler
Parameters:
operator - the operator specific to this particular relational expression. If null, this expression is only a pass-through, and should not actually be instantiated.
Throws:
JaxenException

startAdditiveExpr

public void startAdditiveExpr()
                       throws JaxenException
Description copied from interface: XPathHandler
Receive notification of the start of an additive ('+' or '-') expression.

Specified by:
startAdditiveExpr in interface XPathHandler
Throws:
JaxenException

endAdditiveExpr

public void endAdditiveExpr(int operator)
                     throws JaxenException
Description copied from interface: XPathHandler
Receive notification of the end of an additive ('+' or '-') expression.

Specified by:
endAdditiveExpr in interface XPathHandler
Parameters:
operator - the operator specific to this particular additive expression. If null, this expression is only a pass-through, and should not actually be instantiated.
Throws:
JaxenException

startMultiplicativeExpr

public void startMultiplicativeExpr()
                             throws JaxenException
Description copied from interface: XPathHandler
Receive notification of the start of a multiplicative ('*', 'div' or 'mod') expression.

Specified by:
startMultiplicativeExpr in interface XPathHandler
Throws:
JaxenException

endMultiplicativeExpr

public void endMultiplicativeExpr(int operator)
                           throws JaxenException
Description copied from interface: XPathHandler
Receive notification of the start of a multiplicative ('*', 'div' or 'mod') expression.

Specified by:
endMultiplicativeExpr in interface XPathHandler
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()
                    throws JaxenException
Description copied from interface: XPathHandler
Receive notification of the start of a unary ('+' or '-') expression.

Specified by:
startUnaryExpr in interface XPathHandler
Throws:
JaxenException

endUnaryExpr

public void endUnaryExpr(int operator)
                  throws JaxenException
Description copied from interface: XPathHandler
Receive notification of the end of a unary ('+' or '-') expression.

Specified by:
endUnaryExpr in interface XPathHandler
Parameters:
operator - the operator specific to this particular unary expression. If null, this expression is only a pass-through, and should not actually be instantiated. If not Operator.NO_OP, it will always be Operator.NEGATIVE.
Throws:
JaxenException

startUnionExpr

public void startUnionExpr()
                    throws JaxenException
Description copied from interface: XPathHandler
Receive notification of the start of a union ('|') expression.

Specified by:
startUnionExpr in interface XPathHandler
Throws:
JaxenException

endUnionExpr

public void endUnionExpr(boolean create)
                  throws JaxenException
Description copied from interface: XPathHandler
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
Throws:
JaxenException

number

public void number(int number)
            throws JaxenException
Description copied from interface: XPathHandler
Receive notification of a number expression.

Specified by:
number in interface XPathHandler
Parameters:
number - the number value
Throws:
JaxenException

number

public void number(double number)
            throws JaxenException
Description copied from interface: XPathHandler
Receive notification of a number expression.

Specified by:
number in interface XPathHandler
Parameters:
number - the number value
Throws:
JaxenException

literal

public void literal(java.lang.String literal)
             throws JaxenException
Description copied from interface: XPathHandler
Receive notification of a literal expression.

Specified by:
literal in interface XPathHandler
Parameters:
literal - the string literal value
Throws:
JaxenException

variableReference

public void variableReference(java.lang.String prefix,
                              java.lang.String variableName)
                       throws JaxenException
Description copied from interface: XPathHandler
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
Throws:
JaxenException

startFunction

public void startFunction(java.lang.String prefix,
                          java.lang.String functionName)
                   throws JaxenException
Description copied from interface: XPathHandler
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
Throws:
JaxenException

endFunction

public void endFunction()
                 throws JaxenException
Description copied from interface: XPathHandler
Receive notification of the end of a function call

Specified by:
endFunction in interface XPathHandler
Throws:
JaxenException

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()


Copyright © 2001-2005 Codehaus. All Rights Reserved.