1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package groovy.util.slurpersupport;
19
20 import groovy.lang.Closure;
21 import groovy.lang.GroovyObject;
22 import groovy.lang.GroovyRuntimeException;
23
24 import java.io.IOException;
25 import java.io.Writer;
26 import java.util.Iterator;
27 import java.util.Map;
28
29 /***
30 * @author John Wilson
31 *
32 */
33
34 public class NoChildren extends GPathResult {
35 /***
36 * @param parent
37 * @param name
38 * @param namespacePrefix
39 */
40 public NoChildren(final GPathResult parent, final String name, final Map namespaceTagHints) {
41 super(parent, name, "*", namespaceTagHints);
42 }
43
44
45
46
47 public int size() {
48 return 0;
49 }
50
51
52
53
54 public String text() {
55 return "";
56 }
57
58
59
60
61 public GPathResult parents() {
62
63 throw new GroovyRuntimeException("parents() not implemented yet");
64 }
65
66
67
68
69 public Iterator childNodes() {
70 return iterator();
71 }
72
73
74
75
76 public Iterator iterator() {
77 return new Iterator() {
78 public boolean hasNext() {
79 return false;
80 }
81
82 public Object next() {
83 return null;
84 }
85
86 public void remove() {
87 throw new UnsupportedOperationException();
88 }
89 };
90 }
91
92
93
94
95 public GPathResult find(final Closure closure) {
96 return this;
97 }
98
99
100
101
102 public GPathResult findAll(final Closure closure) {
103 return this;
104 }
105
106
107
108
109 public Iterator nodeIterator() {
110 return iterator();
111 }
112
113
114
115
116 public Writer writeTo(final Writer out) throws IOException {
117 return out;
118 }
119
120
121
122
123 public void build(final GroovyObject builder) {
124 }
125
126 }