JAPI 0_6-alpha-2
Yet another Java API
API Documentation

net.sf.japi.xml
Class NodeListIterator<T extends Node>

java.lang.Object
  extended by net.sf.japi.xml.NodeListIterator<T>
All Implemented Interfaces:
Iterable<T>, Iterator<T>

public class NodeListIterator<T extends Node>
extends Object
implements Iterable<T>, Iterator<T>

A combined iterable / iterator implementation for iterating over NodeLists.

Author:
Christian Hujer

Constructor Summary
NodeListIterator(Element item, short nodeType)
          Create a NodeListIterator.
NodeListIterator(Element item, String childName)
          Create a NodeListIterator.
NodeListIterator(NodeList nodeList)
          Create a NodeListIterator.
NodeListIterator(XPath xpath, Element item, String expression)
          Create a NodeListIterator.
 
Method Summary
static Element getFirstChild(Element el, String childName)
          Convenience helper method for getting the first child of an element that is an element with a specific name.
 boolean hasNext()
          
 Iterator<T> iterator()
          
 T next()
          
 void remove()
          
 int size()
          Get the number of elements this iterator would iterate over all.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NodeListIterator

public NodeListIterator(NodeList nodeList)
Create a NodeListIterator.

Parameters:
nodeList - NodeList to iterate over

NodeListIterator

public NodeListIterator(Element item,
                        short nodeType)
Create a NodeListIterator.

Parameters:
item - Element to evaluate against
nodeType - node type of children

NodeListIterator

public NodeListIterator(Element item,
                        String childName)
Create a NodeListIterator.

Parameters:
item - Element to evaluate against
childName - name of child element

NodeListIterator

public NodeListIterator(XPath xpath,
                        Element item,
                        String expression)
                 throws XPathExpressionException
Create a NodeListIterator.

Parameters:
xpath - XPath to evaulate against
item - Object to evaluate against
expression - XPath expression to evaluate
Throws:
XPathExpressionException - in case of xpath errors
Method Detail

getFirstChild

public static Element getFirstChild(Element el,
                                    String childName)
Convenience helper method for getting the first child of an element that is an element with a specific name.

Parameters:
el - element to get child of
childName - name of child element to get
Returns:
child element or null if no such child element

iterator

public Iterator<T> iterator()

Specified by:
iterator in interface Iterable<T extends Node>

hasNext

public boolean hasNext()

Specified by:
hasNext in interface Iterator<T extends Node>

next

public T next()
                    throws NoSuchElementException

Specified by:
next in interface Iterator<T extends Node>
Throws:
NoSuchElementException

remove

public void remove()

Specified by:
remove in interface Iterator<T extends Node>

size

public int size()
Get the number of elements this iterator would iterate over all.

Returns:
number of elements

JAPI
Yet another Java API
API Documentation

© 2005-2006 Christian Hujer. All rights reserved. See copyright