ca.infoway.messagebuilder.util.iterator
Class NodeListIterator

Package class diagram package NodeListIterator
java.lang.Object
  extended by ca.infoway.messagebuilder.util.iterator.NodeListIterator

public class NodeListIterator
extends Object

A utility to translate the NodeList API into the easier-to-use Interable API.

A typical usage would be: import static ca.infoway.messagebuilder.util.iterator.NodeListIterator.elementIterable; ... public void doMethod() { NodeList list = getAllReleventElementsFromDocument(); for (Element element : elementIterable(list)) { ... } } ...

Author:
Intelliware Development NodeListIterator only used from maven-chi-plugin, so adding to sharpern ignore list

Constructor Summary
NodeListIterator()
           
 
Method Summary
static Iterable<List<Element>> collatedElements(NodeList list)
          Return an Iterable instance that collates the elements in the iterator into individual contiguous lists that happen to have the same tag name.
static Iterable<Element> elementIterable(NodeList list)
          Return an Iterable instance that iterates over only the elements.
static Iterable<Node> nodeIterable(NodeList list)
          Return an Iterable instance that iterates over all nodes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NodeListIterator

public NodeListIterator()
Method Detail

nodeIterable

public static Iterable<Node> nodeIterable(NodeList list)

Return an Iterable instance that iterates over all nodes.

Parameters:
list - - the node list that contains all the nodes
Returns:
- the iterator

elementIterable

public static Iterable<Element> elementIterable(NodeList list)

Return an Iterable instance that iterates over only the elements. Non-element nodes in the original NodeList are ignored.

Parameters:
list - - the node list
Returns:
- the iterator

collatedElements

public static Iterable<List<Element>> collatedElements(NodeList list)

Return an Iterable instance that collates the elements in the iterator into individual contiguous lists that happen to have the same tag name. Thus, if the original list had five elements -- "<purple>", "<purple>", "<red>", "<red>", "<purple>") -- the resulting iterable would have three items to iterate over. The first result is a list of two purple elements, the next is a list of two red elements, and the final result is a single purple element.

Parameters:
list - - the node list
Returns:
- the iterator


Copyright © 2013. All Rights Reserved.