XmlUtil cleanup
[jpim.git] / src / de / j32 / util / XmlUtil.java
index 693e402..0bc9ebc 100644 (file)
@@ -10,7 +10,6 @@ import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.parsers.ParserConfigurationException;
 
 import org.w3c.dom.Document;
-import org.w3c.dom.Element;
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
 import org.xml.sax.EntityResolver;
@@ -40,24 +39,24 @@ public class XmlUtil
                }
        }
        
-       public static Iterable<Element> iterateElements(final NodeList nodes)
+       public static <E extends Node> Iterable<E> iterate(final NodeList nodes, final Class<E> type)
        {
-               return new Iterable<Element>() {
-                       public Iterator<Element> iterator() {
-                               return new NodeListIterator<Element>(nodes, Element.class);
+               return new Iterable<E>() {
+                       public Iterator<E> iterator() {
+                               return new NodeListIterator<E>(nodes, type);
                        }
                };
        }
-
+       
        static class NodeListIterator<E extends Node>
                implements Iterator<E>
        {
-               Class<?> nodeType_;
+               Class<E> nodeType_;
                NodeList nodes_;
                int i_ = 0;
                E next_;
                
-               public NodeListIterator(NodeList nodes, Class<?> nodeType)
+               public NodeListIterator(NodeList nodes, Class<E> nodeType)
                {
                        nodes_ = nodes;
                        nodeType_ = nodeType;