01: package fr.aliacom.form.swt.maker;
02:
03: import java.util.Iterator;
04:
05: import org.w3c.dom.Node;
06: import org.w3c.dom.NodeList;
07:
08: /**
09: * @author tom
10: *
11: * (C) 2001, 2002 Thomas Cataldo
12: */
13: public final class ElementIterator implements Iterator {
14:
15: private Node next;
16: private NodeList nl;
17: private int cur;
18: private int len;
19:
20: public ElementIterator(NodeList nl) {
21: this .nl = nl;
22: cur = 0;
23: len = nl.getLength();
24: findNext();
25: }
26:
27: /**
28: * @see java.util.Iterator#hasNext()
29: */
30: public boolean hasNext() {
31: return next != null;
32: }
33:
34: /**
35: * @see java.util.Iterator#next()
36: */
37: public Object next() {
38: Object ret = next;
39: findNext();
40: return ret;
41: }
42:
43: /**
44: * @see java.util.Iterator#remove()
45: */
46: public void remove() {
47: }
48:
49: private void findNext() {
50: next = null;
51: while (next == null && cur < len) {
52: if (nl.item(cur).getNodeType() == Node.ELEMENT_NODE) {
53: next = nl.item(cur);
54: }
55: cur++;
56: }
57: }
58:
59: }
|