org.jopendocument.util
Class DescendantIterator

java.lang.Object
  extended by org.jopendocument.util.DescendantIterator
All Implemented Interfaces:
Iterator<org.jdom.Content>

public class DescendantIterator
extends Object
implements Iterator<org.jdom.Content>

Traverse a parent's descendants (children at any level below the parent). Element.getDescendants(Filter) allows to filter after having descended, this class allows to filter before. I.e. if the element is :

  
      foo
  
 
and the filter rejects elements named "a" ; Element.getDescendants(Filter) will return the Text "foo", while this class will return nothing.

Author:
Bradley S. Huffman, Jason Hunter, Sylvain Cuaz

Constructor Summary
DescendantIterator(org.jdom.Parent parent)
          Iterator for the descendants of the supplied object.
DescendantIterator(org.jdom.Parent parent, org.jdom.filter.Filter filter)
           
DescendantIterator(org.jdom.Parent parent, IPredicate<? super org.jdom.Content> pred)
           
 
Method Summary
 boolean hasNext()
          Returns true> if the iteration has more Content descendants.
 org.jdom.Content next()
          Returns the next Content descendant.
 void remove()
          Detaches the last Content returned by the last call to next from it's parent.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DescendantIterator

public DescendantIterator(org.jdom.Parent parent)
Iterator for the descendants of the supplied object.

Parameters:
parent - document or element whose descendants will be iterated

DescendantIterator

public DescendantIterator(org.jdom.Parent parent,
                          IPredicate<? super org.jdom.Content> pred)

DescendantIterator

public DescendantIterator(org.jdom.Parent parent,
                          org.jdom.filter.Filter filter)
Method Detail

hasNext

public boolean hasNext()
Returns true> if the iteration has more Content descendants.

Specified by:
hasNext in interface Iterator<org.jdom.Content>
Returns:
true is the iterator has more descendants

next

public org.jdom.Content next()
Returns the next Content descendant.

Specified by:
next in interface Iterator<org.jdom.Content>
Returns:
the next descendant

remove

public void remove()
Detaches the last Content returned by the last call to next from it's parent. Note: this does not affect iteration and all children, siblings, and any node following the removed node (in document order) will be visited.

Specified by:
remove in interface Iterator<org.jdom.Content>


Copyright © 2010 jOpenDocument All Rights Reserved.