org.apache.commons.jxpath.ri.model.jdom
Class JDOMNodeIterator

java.lang.Object
  extended by org.apache.commons.jxpath.ri.model.jdom.JDOMNodeIterator
All Implemented Interfaces:
NodeIterator

public class JDOMNodeIterator
extends java.lang.Object
implements NodeIterator

An iterator of children of a JDOM Node.

Version:
$Revision: 652845 $ $Date: 2008-05-02 12:46:46 -0500 (Fri, 02 May 2008) $
Author:
Dmitri Plotnikov

Field Summary
private  java.lang.Object child
           
private  java.util.List children
           
private  int index
           
private  NodeTest nodeTest
           
private  NodePointer parent
           
private  int position
           
private  boolean reverse
           
 
Constructor Summary
JDOMNodeIterator(NodePointer parent, NodeTest nodeTest, boolean reverse, NodePointer startWith)
          Create a new JDOMNodeIterator.
 
Method Summary
 NodePointer getNodePointer()
          Get the NodePointer at the current position.
 int getPosition()
          Get the current iterator position.
private  boolean next()
          Iterate to next pointer.
private  boolean previous()
          This is actually never invoked during the normal evaluation of xpaths - an iterator is always going forward, never backwards.
 boolean setPosition(int position)
          Set the new current position.
private  boolean testChild()
          Test a child node.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

parent

private NodePointer parent

nodeTest

private NodeTest nodeTest

reverse

private boolean reverse

position

private int position

index

private int index

children

private java.util.List children

child

private java.lang.Object child
Constructor Detail

JDOMNodeIterator

public JDOMNodeIterator(NodePointer parent,
                        NodeTest nodeTest,
                        boolean reverse,
                        NodePointer startWith)
Create a new JDOMNodeIterator.

Parameters:
parent - pointer
nodeTest - test
reverse - whether to iterate in reverse
startWith - starting pointer
Method Detail

getNodePointer

public NodePointer getNodePointer()
Description copied from interface: NodeIterator
Get the NodePointer at the current position.

Specified by:
getNodePointer in interface NodeIterator
Returns:
NodePointer

getPosition

public int getPosition()
Description copied from interface: NodeIterator
Get the current iterator position.

Specified by:
getPosition in interface NodeIterator
Returns:
int position

setPosition

public boolean setPosition(int position)
Description copied from interface: NodeIterator
Set the new current position.

Specified by:
setPosition in interface NodeIterator
Parameters:
position - the position to set
Returns:
true if there is a node at position.

previous

private boolean previous()
This is actually never invoked during the normal evaluation of xpaths - an iterator is always going forward, never backwards. So, this is implemented only for completeness and perhaps for those who use these iterators outside of XPath evaluation.

Returns:
boolean

next

private boolean next()
Iterate to next pointer.

Returns:
whether valid

testChild

private boolean testChild()
Test a child node.

Returns:
whether test passes.