org.apache.xpath.axes
Class ReverseAxesWalker

java.lang.Object
  extended by org.apache.xpath.Expression
      extended by org.apache.xpath.patterns.NodeTest
          extended by org.apache.xpath.axes.PredicatedNodeTest
              extended by org.apache.xpath.axes.AxesWalker
                  extended by org.apache.xpath.axes.ReverseAxesWalker
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, javax.xml.transform.SourceLocator, PathComponent, SubContextList, ExpressionNode, ExpressionOwner, XPathVisitable

public class ReverseAxesWalker
extends AxesWalker

Walker for a reverse axes.

See Also:
XPath 2.4 Predicates, Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class org.apache.xpath.axes.PredicatedNodeTest
PredicatedNodeTest.PredOwner
 
Field Summary
protected  DTMAxisIterator m_iterator
          The DTM inner traversal class, that corresponds to the super axis.
(package private) static long serialVersionUID
           
 
Fields inherited from class org.apache.xpath.axes.AxesWalker
m_axis, m_isFresh, m_nextWalker, m_prevWalker, m_root, m_traverser
 
Fields inherited from class org.apache.xpath.axes.PredicatedNodeTest
DEBUG_PREDICATECOUNTING, m_foundLast, m_lpi, m_predCount, m_predicateIndex, m_proximityPositions
 
Fields 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
ReverseAxesWalker(LocPathIterator locPathIterator, int axis)
          Construct an AxesWalker using a LocPathIterator.
 
Method Summary
protected  void countProximityPosition(int i)
          Count backwards one proximity position.
 void detach()
          Detaches the walker from the set which it iterated over, releasing any computational resources and placing the iterator in the INVALID state.
 int getLastPos(XPathContext xctxt)
          Get the number of nodes in this node list.
protected  int getNextNode()
          Get the next node in document order on the axes.
protected  int getProximityPosition(int predicateIndex)
          Get the current sub-context position.
 boolean isDocOrdered()
          Returns true if all the nodes in the iteration well be returned in document order.
 boolean isReverseAxes()
          Tells if this is a reverse axes.
 void setRoot(int root)
          Set the root node of the TreeWalker.
 
Methods inherited from class org.apache.xpath.axes.AxesWalker
callVisitors, clone, cloneDeep, deepEquals, findClone, getAnalysisBits, getAxis, getCurrentNode, getDTM, getExpression, getNextWalker, getPrevWalker, getRoot, init, nextNode, setDefaultDTM, setExpression, setNextWalker, setPrevWalker, wi
 
Methods inherited from class org.apache.xpath.axes.PredicatedNodeTest
acceptNode, callPredicateVisitors, canTraverseOutsideSubtree, executePredicates, fixupVariables, getLocPathIterator, getPredicate, getPredicateCount, getPredicateIndex, getProximityPosition, getProximityPosition, initPredicateInfo, initProximityPosition, nodeToString, resetProximityPositions, setLocPathIterator, setPredicateCount
 
Methods inherited from class org.apache.xpath.patterns.NodeTest
calcScore, debugWhatToShow, execute, execute, execute, getDefaultScore, getLocalName, getNamespace, getNodeTypeTest, getStaticScore, getWhatToShow, initNodeTest, initNodeTest, setLocalName, setNamespace, setStaticScore, setWhatToShow
 
Methods 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
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

static final long serialVersionUID
See Also:
Constant Field Values

m_iterator

protected DTMAxisIterator m_iterator
The DTM inner traversal class, that corresponds to the super axis.

Constructor Detail

ReverseAxesWalker

ReverseAxesWalker(LocPathIterator locPathIterator,
                  int axis)
Construct an AxesWalker using a LocPathIterator.

Parameters:
locPathIterator - The location path iterator that 'owns' this walker.
Method Detail

setRoot

public void setRoot(int root)
Set the root node of the TreeWalker. (Not part of the DOM2 TreeWalker interface).

Overrides:
setRoot in class AxesWalker
Parameters:
root - The context node of this step.

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.

Overrides:
detach in class AxesWalker

getNextNode

protected int getNextNode()
Get the next node in document order on the axes.

Overrides:
getNextNode in class AxesWalker
Returns:
the next node in document order on the axes, or null.

isReverseAxes

public boolean isReverseAxes()
Tells if this is a reverse axes. Overrides AxesWalker#isReverseAxes.

Overrides:
isReverseAxes in class PredicatedNodeTest
Returns:
true for this class.

getProximityPosition

protected int getProximityPosition(int predicateIndex)
Get the current sub-context position. In order to do the reverse axes count, for the moment this re-searches the axes up to the predicate. An optimization on this is to cache the nodes searched, but, for the moment, this case is probably rare enough that the added complexity isn't worth it.

Overrides:
getProximityPosition in class PredicatedNodeTest
Parameters:
predicateIndex - The predicate index of the proximity position.
Returns:
The pridicate index, or -1.

countProximityPosition

protected void countProximityPosition(int i)
Count backwards one proximity position.

Overrides:
countProximityPosition in class PredicatedNodeTest
Parameters:
i - The predicate index.

getLastPos

public int getLastPos(XPathContext xctxt)
Get the number of nodes in this node list. The function is probably ill named?

Specified by:
getLastPos in interface SubContextList
Overrides:
getLastPos in class AxesWalker
Parameters:
xctxt - The XPath runtime context.
Returns:
the number of nodes in this node list.

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!

Overrides:
isDocOrdered in class AxesWalker
Returns:
false.