JAPI 0.9.0
Yet another Java API
API Documentation

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

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

public class FilteredNodeList<T extends Node>
extends Object
implements NodeList, Iterable<T>

FilteredNodeList is a NodeList implementation that allows quick iteration over an elements children. Currently there are two ways to use FilteredNodeList: iterating over all child elements with a certain name (children, not descendants), or iterating over all children of a specific node type.

Author:
Christian Hujer

Constructor Summary
FilteredNodeList(Element el, short nodeType)
          Create a FilteredNodeList.
FilteredNodeList(Element el, String childName)
          Create a FilteredNodeList.
 
Method Summary
 int getLength()
          The number of nodes in the list.
 T item(int index)
          Returns the indexth item in the collection.
 Iterator<T> iterator()
          Returns an iterator over a set of elements of type T.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FilteredNodeList

public FilteredNodeList(@NotNull
                        Element el,
                        short nodeType)
Create a FilteredNodeList.

Parameters:
el - Element to iterate on
nodeType - nodetype to find

FilteredNodeList

public FilteredNodeList(@NotNull
                        Element el,
                        @NotNull
                        String childName)
Create a FilteredNodeList.

Parameters:
el - Element to iterate on
childName - name of child elements to iterate over
Method Detail

item

@Nullable
public T item(int index)
Returns the indexth item in the collection. If index is greater than or equal to the number of nodes in the list, this returns null.

Specified by:
item in interface NodeList
Parameters:
index - Index into the collection.
Returns:
The node at the indexth position in the NodeList, or null if that is not a valid index.

getLength

public int getLength()
The number of nodes in the list. The range of valid child node indices is 0 to length-1 inclusive.

Specified by:
getLength in interface NodeList

iterator

@NotNull
public Iterator<T> iterator()
Returns an iterator over a set of elements of type T.

Specified by:
iterator in interface Iterable<T extends Node>
Returns:
an Iterator.

JAPI
Yet another Java API
API Documentation

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