org.apache.commons.jxpath.ri.axes

Class AncestorContext

Implemented Interfaces:
ExpressionContext, Iterator

public class AncestorContext
extends EvalContext

EvalContext that walks the "ancestor::" and "ancestor-or-self::" axes.
Version:
$Revision: 1.15 $ $Date: 2004/03/25 03:49:50 $
Author:
Dmitri Plotnikov

Field Summary

Fields inherited from class org.apache.commons.jxpath.ri.EvalContext

parentContext, position, rootContext

Constructor Summary

AncestorContext(EvalContext parentContext, boolean includeSelf, NodeTest nodeTest)

Method Summary

NodePointer
getCurrentNodePointer()
Returns the current context node.
int
getDocumentOrder()
Determines the document order for this context.
boolean
nextNode()
Returns true if there is another object in the current set.
void
reset()
Sets current position = 0, which is the pre-iteration state.
boolean
setPosition(int position)
Moves the current position to the specified index.

Methods inherited from class org.apache.commons.jxpath.ri.EvalContext

getContextNodeList, getContextNodePointer, getCurrentNodePointer, getCurrentPosition, getDocumentOrder, getJXPathContext, getNodeSet, getPosition, getRootContext, getSingleNodePointer, getValue, hasNext, isChildOrderingRequired, next, nextNode, nextSet, remove, reset, setPosition, toString

Constructor Details

AncestorContext

public AncestorContext(EvalContext parentContext,
                       boolean includeSelf,
                       NodeTest nodeTest)
Parameters:
parentContext - represents the previous step on the path
includeSelf - differentiates between "ancestor::" and "ancestor- or-self::" axes

Method Details

getCurrentNodePointer

public NodePointer getCurrentNodePointer()
Returns the current context node. Undefined before the beginning of the iteration.
Overrides:
getCurrentNodePointer in interface EvalContext

getDocumentOrder

public int getDocumentOrder()
Determines the document order for this context.
Overrides:
getDocumentOrder in interface EvalContext
Returns:
1 ascending order, -1 descending order, 0 - does not require ordering

nextNode

public boolean nextNode()
Returns true if there is another object in the current set. Switches the current position and node to the next object.
Overrides:
nextNode in interface EvalContext

reset

public void reset()
Sets current position = 0, which is the pre-iteration state.
Overrides:
reset in interface EvalContext

setPosition

public boolean setPosition(int position)
Moves the current position to the specified index. Used with integer predicates to quickly get to the n'th element of the node set. Returns false if the position is out of the node set range. You can call it with 0 as the position argument to restart the iteration.
Overrides:
setPosition in interface EvalContext