31 lines
693 B
Java
31 lines
693 B
Java
package io.gitlab.jfronny.inceptum.common.dom;
|
|
|
|
import org.w3c.dom.Node;
|
|
import org.w3c.dom.NodeList;
|
|
|
|
import java.util.Iterator;
|
|
import java.util.NoSuchElementException;
|
|
|
|
public class NodeListIterator implements Iterator<Node> {
|
|
private final NodeList list;
|
|
private int index = 0;
|
|
|
|
public NodeListIterator(NodeList list) {
|
|
this.list = list;
|
|
}
|
|
|
|
@Override
|
|
public boolean hasNext() {
|
|
while (index < list.length && list[index].isWhitespace()) {
|
|
index++;
|
|
}
|
|
return index < list.length;
|
|
}
|
|
|
|
@Override
|
|
public Node next() {
|
|
if (!hasNext()) throw new NoSuchElementException();
|
|
return list[index++];
|
|
}
|
|
}
|