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