Package org.apache.xpath.axes
Class AxesWalker
java.lang.Object
org.apache.xpath.Expression
org.apache.xpath.patterns.NodeTest
org.apache.xpath.axes.PredicatedNodeTest
org.apache.xpath.axes.AxesWalker
- All Implemented Interfaces:
Serializable,Cloneable,SourceLocator,PathComponent,SubContextList,ExpressionNode,ExpressionOwner,XPathVisitable
- Direct Known Subclasses:
FilterExprWalker,ReverseAxesWalker
public class AxesWalker extends PredicatedNodeTest implements Cloneable, PathComponent, ExpressionOwner
Serves as common interface for axes Walkers, and stores common
state variables.
- See Also:
- Serialized Form
-
Field Summary
Fields Modifier and Type Field Description protected intm_axisThe traversal axis from where the nodes will be filtered.protected AxesWalkerm_nextWalkerThe next walker in the location step chain.protected DTMAxisTraverserm_traverserThe DTM inner traversal class, that corresponds to the super axis.Fields inherited from class org.apache.xpath.axes.PredicatedNodeTest
m_foundLast, m_lpi, m_predCount, m_proximityPositionsFields inherited from class org.apache.xpath.patterns.NodeTest
m_name, m_whatToShow, SCORE_NODETEST, SCORE_NONE, SCORE_NSWILD, SCORE_OTHER, SCORE_QNAME, SHOW_BYFUNCTION, SUPPORTS_PRE_STRIPPING, WILD -
Constructor Summary
Constructors Constructor Description AxesWalker(LocPathIterator locPathIterator, int axis)Construct an AxesWalker using a LocPathIterator. -
Method Summary
Modifier and Type Method Description voidcallVisitors(ExpressionOwner owner, XPathVisitor visitor)This will traverse the heararchy, calling the visitor for each member.Objectclone()Get a cloned AxesWalker.booleandeepEquals(Expression expr)Compare this object with another object and see if they are equal, include the sub heararchy.voiddetach()Detaches the walker from the set which it iterated over, releasing any computational resources and placing the iterator in the INVALID state.intgetAnalysisBits()Get the analysis bits for this walker, as defined in the WalkerFactory.intgetAxis()Returns the axis being iterated, if it is known.intgetCurrentNode()The node at which the TreeWalker is currently positioned.DTMgetDTM(int node)Get the DTM for this walker.ExpressiongetExpression()Get the raw Expression object that this class wraps.intgetLastPos(XPathContext xctxt)Get the index of the last node that can be itterated to.protected intgetNextNode()Get the next node in document order on the axes.AxesWalkergetNextWalker()Get the next walker in the location step chain.AxesWalkergetPrevWalker()Get the previous walker reference in the location step chain.intgetRoot()The root node of the TreeWalker, as specified in setRoot(int root).voidinit(Compiler compiler, int opPos, int stepType)Initialize an AxesWalker during the parse of the XPath expression.booleanisDocOrdered()Returns true if all the nodes in the iteration well be returned in document order.intnextNode()Moves theTreeWalkerto the next visible node in document order relative to the current node, and returns the new node.voidsetDefaultDTM(DTM dtm)Set the DTM for this walker.voidsetExpression(Expression exp)Set the raw expression object for this object.voidsetNextWalker(AxesWalker walker)Set the next walker in the location step chain.voidsetPrevWalker(AxesWalker walker)Set or clear the previous walker reference in the location step chain.voidsetRoot(int root)Set the root node of the TreeWalker.WalkingIteratorwi()Methods inherited from class org.apache.xpath.axes.PredicatedNodeTest
acceptNode, callPredicateVisitors, canTraverseOutsideSubtree, countProximityPosition, fixupVariables, getLocPathIterator, getPredicate, getPredicateCount, getPredicateIndex, getProximityPosition, getProximityPosition, getProximityPosition, initPredicateInfo, initProximityPosition, isReverseAxes, nodeToString, resetProximityPositions, setLocPathIterator, setPredicateCountMethods inherited from class org.apache.xpath.patterns.NodeTest
calcScore, debugWhatToShow, execute, execute, execute, getDefaultScore, getLocalName, getNamespace, getNodeTypeTest, getStaticScore, getWhatToShow, initNodeTest, initNodeTest, setLocalName, setNamespace, setStaticScore, setWhatToShowMethods inherited from class org.apache.xpath.Expression
asIterator, asIteratorRaw, asNode, assertion, bool, error, execute, executeCharsToContentHandler, exprAddChild, exprGetChild, exprGetNumChildren, exprGetParent, exprSetParent, getColumnNumber, getExpressionOwner, getLineNumber, getPublicId, getSystemId, isNodesetExpr, isSameClass, isStableNumber, num, warn, xstr
-
Field Details
-
m_nextWalker
The next walker in the location step chain. -
m_axis
protected int m_axisThe traversal axis from where the nodes will be filtered. -
m_traverser
The DTM inner traversal class, that corresponds to the super axis.
-
-
Constructor Details
-
AxesWalker
Construct an AxesWalker using a LocPathIterator.- Parameters:
locPathIterator- non-null reference to the parent iterator.
-
-
Method Details
-
wi
-
init
Initialize an AxesWalker during the parse of the XPath expression.- Parameters:
compiler- The Compiler object that has information about this walker in the op map.opPos- The op code position of this location step.stepType- The type of location step.- Throws:
TransformerException
-
clone
Get a cloned AxesWalker.- Overrides:
clonein classPredicatedNodeTest- Returns:
- A new AxesWalker that can be used without mutating this one.
- Throws:
CloneNotSupportedException
-
detach
public void detach()Detaches the walker from the set which it iterated over, releasing any computational resources and placing the iterator in the INVALID state. -
getRoot
public int getRoot()The root node of the TreeWalker, as specified in setRoot(int root). Note that this may actually be below the current node.- Returns:
- The context node of the step.
-
getAnalysisBits
public int getAnalysisBits()Get the analysis bits for this walker, as defined in the WalkerFactory.- Specified by:
getAnalysisBitsin interfacePathComponent- Returns:
- One of WalkerFactory#BIT_DESCENDANT, etc.
-
setRoot
public void setRoot(int root)Set the root node of the TreeWalker. (Not part of the DOM2 TreeWalker interface).- Parameters:
root- The context node of this step.
-
getCurrentNode
public final int getCurrentNode()The node at which the TreeWalker is currently positioned.
The value must not be null. Alterations to the DOM tree may cause the current node to no longer be accepted by the TreeWalker's associated filter. currentNode may also be explicitly set to any node, whether or not it is within the subtree specified by the root node or would be accepted by the filter and whatToShow flags. Further traversal occurs relative to currentNode even if it is not part of the current view by applying the filters in the requested direction (not changing currentNode where no traversal is possible).- Returns:
- The node at which the TreeWalker is currently positioned, only null if setRoot has not yet been called.
-
setNextWalker
Set the next walker in the location step chain.- Parameters:
walker- Reference to AxesWalker derivative, or may be null.
-
getNextWalker
Get the next walker in the location step chain.- Returns:
- Reference to AxesWalker derivative, or null.
-
setPrevWalker
Set or clear the previous walker reference in the location step chain.- Parameters:
walker- Reference to previous walker reference in the location step chain, or null.
-
getPrevWalker
Get the previous walker reference in the location step chain.- Returns:
- Reference to previous walker reference in the location step chain, or null.
-
getNextNode
protected int getNextNode()Get the next node in document order on the axes.- Returns:
- the next node in document order on the axes, or null.
-
nextNode
public int nextNode()Moves theTreeWalkerto the next visible node in document order relative to the current node, and returns the new node. If the current node has no next node, or if the search for nextNode attempts to step upward from the TreeWalker's root node, returnsnull, and retains the current node.- Returns:
- The new node, or
nullif the current node has no next node in the TreeWalker's logical view.
-
getLastPos
Get the index of the last node that can be itterated to.- Specified by:
getLastPosin interfaceSubContextList- Specified by:
getLastPosin classPredicatedNodeTest- Parameters:
xctxt- XPath runtime context.- Returns:
- the index of the last node that can be itterated to.
-
setDefaultDTM
Set the DTM for this walker.- Parameters:
dtm- Non-null reference to a DTM.
-
getDTM
Get the DTM for this walker.- Returns:
- Non-null reference to a DTM.
-
isDocOrdered
public boolean isDocOrdered()Returns true if all the nodes in the iteration well be returned in document order. Warning: This can only be called after setRoot has been called!- Returns:
- true as a default.
-
getAxis
public int getAxis()Returns the axis being iterated, if it is known.- Returns:
- Axis.CHILD, etc., or -1 if the axis is not known or is of multiple types.
-
callVisitors
This will traverse the heararchy, calling the visitor for each member. If the called visitor method returns false, the subtree should not be called.- Specified by:
callVisitorsin interfaceXPathVisitable- Overrides:
callVisitorsin classNodeTest- Parameters:
owner- The owner of the visitor, where that path may be rewritten if needed.visitor- The visitor whose appropriate method will be called.- See Also:
XPathVisitable.callVisitors(ExpressionOwner, XPathVisitor)
-
getExpression
Description copied from interface:ExpressionOwnerGet the raw Expression object that this class wraps.- Specified by:
getExpressionin interfaceExpressionOwner- Returns:
- the raw Expression object, which should not normally be null.
- See Also:
ExpressionOwner.getExpression()
-
setExpression
Description copied from interface:ExpressionOwnerSet the raw expression object for this object.- Specified by:
setExpressionin interfaceExpressionOwner- Parameters:
exp- the raw Expression object, which should not normally be null.- See Also:
ExpressionOwner.setExpression(Expression)
-
deepEquals
Description copied from class:ExpressionCompare this object with another object and see if they are equal, include the sub heararchy.- Overrides:
deepEqualsin classPredicatedNodeTest- Parameters:
expr- Another expression object.- Returns:
- true if this objects class and the expr object's class are the same, and the data contained within both objects are considered equal.
- See Also:
Expression.deepEquals(Expression)
-