1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51 package org.jaxen.test;
52
53 import java.util.Iterator;
54 import java.util.LinkedList;
55 import java.util.List;
56
57 import org.jaxen.saxpath.XPathHandler;
58
59 class ConformanceXPathHandler implements XPathHandler
60 {
61 private List events;
62
63 ConformanceXPathHandler()
64 {
65 this.events = new LinkedList();
66 }
67
68 public void startXPath()
69 {
70 addEvent( "startXPath()" );
71 }
72
73 public void endXPath()
74 {
75 addEvent( "endXPath()" );
76 }
77
78 public void startPathExpr()
79 {
80 addEvent( "startPathExpr()" );
81 }
82
83 public void endPathExpr()
84 {
85 addEvent( "endPathExpr()" );
86 }
87
88 public void startAbsoluteLocationPath()
89 {
90 addEvent( "startAbsoluteLocationPath()" );
91 }
92 public void endAbsoluteLocationPath()
93 {
94 addEvent( "endAbsoluteLocationPath()" );
95 }
96
97 public void startRelativeLocationPath()
98 {
99 addEvent( "startRelativeLocationPath()" );
100 }
101
102 public void endRelativeLocationPath()
103 {
104 addEvent( "endRelativeLocationPath()" );
105 }
106
107 public void startNameStep(int axis,
108 String prefix,
109 String localName)
110 {
111 addEvent( "startNameStep(" + axis + ", \"" + prefix + "\", \"" + localName + "\")" );
112 }
113
114 public void endNameStep()
115 {
116 addEvent( "endNameStep()" );
117 }
118
119 public void startTextNodeStep(int axis)
120 {
121 addEvent( "startTextNodeStep(" + axis + ")" );
122 }
123 public void endTextNodeStep()
124 {
125 addEvent( "endTextNodeStep()" );
126 }
127
128 public void startCommentNodeStep(int axis)
129 {
130 addEvent( "startCommentNodeStep(" + axis + ")" );
131 }
132
133 public void endCommentNodeStep()
134 {
135 addEvent( "endCommentNodeStep()" );
136 }
137
138 public void startAllNodeStep(int axis)
139 {
140 addEvent( "startAllNodeStep(" + axis + ")" );
141 }
142
143 public void endAllNodeStep()
144 {
145 addEvent( "endAllNodeStep()" );
146 }
147
148 public void startProcessingInstructionNodeStep(int axis,
149 String name)
150 {
151 addEvent( "startProcessingInstructionNodeStep(" + axis + ", \"" + name + "\")" );
152 }
153 public void endProcessingInstructionNodeStep()
154 {
155 addEvent( "endProcessingInstructionNodeStep()" );
156 }
157
158 public void startPredicate()
159 {
160 addEvent( "startPredicate()" );
161 }
162
163 public void endPredicate()
164 {
165 addEvent( "endPredicate()" );
166 }
167
168 public void startFilterExpr()
169 {
170 addEvent( "startFilterExpr()" );
171 }
172
173 public void endFilterExpr()
174 {
175 addEvent( "endFilterExpr()" );
176 }
177
178 public void startOrExpr()
179 {
180 addEvent( "startOrExpr()" );
181 }
182
183 public void endOrExpr(boolean create)
184 {
185 addEvent( "endOrExpr(" + create + ")" );
186 }
187
188 public void startAndExpr()
189 {
190 addEvent( "startAndExpr()" );
191 }
192
193 public void endAndExpr(boolean create)
194 {
195 addEvent( "endAndExpr(" + create + ")" );
196 }
197
198 public void startEqualityExpr()
199 {
200 addEvent( "startEqualityExpr()" );
201 }
202
203 public void endEqualityExpr(int operator)
204 {
205 addEvent( "endEqualityExpr(" + operator + ")" );
206 }
207
208 public void startRelationalExpr()
209 {
210 addEvent( "startRelationalExpr()" );
211 }
212
213 public void endRelationalExpr(int operator)
214 {
215 addEvent( "endRelationalExpr(" + operator + ")" );
216 }
217
218 public void startAdditiveExpr()
219 {
220 addEvent( "startAdditiveExpr()" );
221 }
222
223 public void endAdditiveExpr(int operator)
224 {
225 addEvent( "endAdditiveExpr(" + operator + ")" );
226 }
227
228 public void startMultiplicativeExpr()
229 {
230 addEvent( "startMultiplicativeExpr()" );
231 }
232
233 public void endMultiplicativeExpr(int operator)
234 {
235 addEvent( "endMultiplicativeExpr(" + operator + ")" );
236 }
237
238 public void startUnaryExpr()
239 {
240 addEvent( "startUnaryExpr()" );
241 }
242
243 public void endUnaryExpr(int operator)
244 {
245 addEvent( "endUnaryExpr(" + operator + ")" );
246 }
247
248 public void startUnionExpr()
249 {
250 addEvent( "startUnionExpr()" );
251 }
252
253 public void endUnionExpr(boolean create)
254 {
255 addEvent( "endUnionExpr(" + create + ")" );
256 }
257
258 public void number(int number)
259 {
260 addEvent( "number(" + number + ")" );
261 }
262
263 public void number(double number)
264 {
265 addEvent( "number(" + number + ")" );
266 }
267
268 public void literal(String literal)
269 {
270 addEvent( "literal(\"" + literal + "\")" );
271 }
272
273 public void variableReference(String prefix,
274 String variableName)
275 {
276 addEvent( "variableReference(\"" + prefix + ":" + variableName + "\")" );
277 }
278
279 public void startFunction(String prefix,
280 String functionName)
281 {
282 addEvent( "startFunction(\"" + prefix + ":" + functionName + "\")" );
283 }
284
285 public void endFunction()
286 {
287 addEvent( "endFunction()" );
288 }
289
290 private void addEvent(String eventStr)
291 {
292 this.events.add( eventStr );
293 }
294
295 public boolean equals(Object thatObj)
296 {
297 if ( thatObj instanceof ConformanceXPathHandler )
298 {
299 ConformanceXPathHandler that = (ConformanceXPathHandler) thatObj;
300
301 return ( this.events.equals( that.events ) );
302 }
303
304 return false;
305 }
306
307 public int hashCode() {
308 return this.events.hashCode();
309 }
310
311
312 public String toString()
313 {
314 Iterator eventIter = this.events.iterator();
315 int i = 0;
316
317 StringBuffer buf = new StringBuffer();
318
319 while( eventIter.hasNext() )
320 {
321 buf.append("(").append(i).append(") ").append( eventIter.next().toString() ).append("\n");
322 ++i;
323 }
324
325 return buf.toString();
326 }
327 }