Class PrecedingAxisIterator
- java.lang.Object
-
- org.jaxen.util.PrecedingAxisIterator
-
- All Implemented Interfaces:
java.util.Iterator
public class PrecedingAxisIterator extends java.lang.Object implements java.util.IteratorRepresents the XPath
precedingaxis. The "precedingaxis contains all nodes in the same document as the context node that are before the context node in document order, excluding any ancestors and excluding attribute nodes and namespace nodes."This implementation of '
preceding' works like so: theprecedingaxis includes preceding siblings of this node and their descendants. Also, for each ancestor node of this node, it includes all preceding siblings of that ancestor, and their descendants. Finally, it includes the ancestor nodes themselves.The reversed
descendant-or-selfaxes that are required are calculated using a stack of reversed 'child-or-self' axes. When asked for a node, it is always taken from a child-or-self axis. If it was the last node on that axis, the node is returned. Otherwise, this axis is pushed on the stack, and the process is repeated with the child-or-self of the node. Eventually this recurses down to the last descendant of any node, then works back up to the root.Most object models could provide a faster implementation of the reversed 'children-or-self' used here.
- Version:
- 1.2b12
-
-
Constructor Summary
Constructors Constructor Description PrecedingAxisIterator(java.lang.Object contextNode, Navigator navigator)Create a newprecedingaxis iterator.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanhasNext()Returns true if there are any preceding nodes remaining; false otherwise.java.lang.Objectnext()Returns the next preceding node.voidremove()This operation is not supported.
-
-
-
Constructor Detail
-
PrecedingAxisIterator
public PrecedingAxisIterator(java.lang.Object contextNode, Navigator navigator) throws UnsupportedAxisExceptionCreate a newprecedingaxis iterator.- Parameters:
contextNode- the node to start fromnavigator- the object model specific navigator- Throws:
UnsupportedAxisException
-
-
Method Detail
-
hasNext
public boolean hasNext()
Returns true if there are any preceding nodes remaining; false otherwise.- Specified by:
hasNextin interfacejava.util.Iterator- Returns:
- true if any preceding nodes remain; false otherwise
- See Also:
Iterator.hasNext()
-
next
public java.lang.Object next() throws java.util.NoSuchElementExceptionReturns the next preceding node.- Specified by:
nextin interfacejava.util.Iterator- Returns:
- the next preceding node
- Throws:
java.util.NoSuchElementException- if no preceding nodes remain- See Also:
Iterator.next()
-
remove
public void remove() throws java.lang.UnsupportedOperationExceptionThis operation is not supported.- Specified by:
removein interfacejava.util.Iterator- Throws:
java.lang.UnsupportedOperationException- always
-
-