|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectca.infoway.messagebuilder.util.iterator.NodeListIterator
public class NodeListIterator
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)) {
...
}
}
...
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 |
---|
public NodeListIterator()
Method Detail |
---|
public static Iterable<Node> nodeIterable(NodeList list)
Return an Iterable instance that iterates over all nodes.
list
- - the node list that contains all the nodes
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.
list
- - the node list
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.
list
- - the node list
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |