1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.springmodules.validation.util.xml;
18
19 import org.springmodules.validation.util.collection.FilteredIterator;
20 import org.springmodules.validation.util.condition.AbstractCondition;
21 import org.w3c.dom.Node;
22
23
24
25
26
27
28 public class SubElementsIterator extends FilteredIterator {
29
30 public SubElementsIterator(Node node) {
31 super(new ChildNodesIterator(node), new AbstractCondition() {
32 public boolean doCheck(Object object) {
33 Node node = (Node) object;
34 return node.getNodeType() == Node.ELEMENT_NODE;
35 }
36 });
37 }
38
39 public SubElementsIterator(Node node, final String elementName) {
40 super(new ChildNodesIterator(node), new AbstractCondition() {
41 public boolean doCheck(Object object) {
42 Node node = (Node) object;
43 return node.getNodeType() != Node.ELEMENT_NODE
44 && node.getLocalName().equals(elementName);
45 }
46 });
47 }
48
49 public SubElementsIterator(Node node, final String namespace, final String elementName) {
50 super(new ChildNodesIterator(node), new AbstractCondition() {
51 public boolean doCheck(Object object) {
52 Node node = (Node) object;
53 return node.getNodeType() == Node.ELEMENT_NODE
54 && node.getLocalName().equals(elementName)
55 && node.getNamespaceURI().equals(namespace);
56 }
57 });
58 }
59 }