|
1 |
| |
|
2 |
| |
|
3 |
| |
|
4 |
| |
|
5 |
| |
|
6 |
| |
|
7 |
| |
|
8 |
| |
|
9 |
| |
|
10 |
| |
|
11 |
| |
|
12 |
| |
|
13 |
| |
|
14 |
| |
|
15 |
| |
|
16 |
| |
|
17 |
| |
|
18 |
| package org.qedeq.kernel.xml.mapper; |
|
19 |
| |
|
20 |
| import java.util.ArrayList; |
|
21 |
| import java.util.HashMap; |
|
22 |
| import java.util.List; |
|
23 |
| import java.util.Map; |
|
24 |
| |
|
25 |
| import org.qedeq.kernel.base.list.ElementList; |
|
26 |
| import org.qedeq.kernel.base.module.Author; |
|
27 |
| import org.qedeq.kernel.base.module.AuthorList; |
|
28 |
| import org.qedeq.kernel.base.module.Axiom; |
|
29 |
| import org.qedeq.kernel.base.module.Chapter; |
|
30 |
| import org.qedeq.kernel.base.module.ChapterList; |
|
31 |
| import org.qedeq.kernel.base.module.Formula; |
|
32 |
| import org.qedeq.kernel.base.module.FunctionDefinition; |
|
33 |
| import org.qedeq.kernel.base.module.Header; |
|
34 |
| import org.qedeq.kernel.base.module.Import; |
|
35 |
| import org.qedeq.kernel.base.module.ImportList; |
|
36 |
| import org.qedeq.kernel.base.module.Latex; |
|
37 |
| import org.qedeq.kernel.base.module.LatexList; |
|
38 |
| import org.qedeq.kernel.base.module.LinkList; |
|
39 |
| import org.qedeq.kernel.base.module.LiteratureItem; |
|
40 |
| import org.qedeq.kernel.base.module.LiteratureItemList; |
|
41 |
| import org.qedeq.kernel.base.module.Location; |
|
42 |
| import org.qedeq.kernel.base.module.LocationList; |
|
43 |
| import org.qedeq.kernel.base.module.Node; |
|
44 |
| import org.qedeq.kernel.base.module.PredicateDefinition; |
|
45 |
| import org.qedeq.kernel.base.module.Proof; |
|
46 |
| import org.qedeq.kernel.base.module.ProofList; |
|
47 |
| import org.qedeq.kernel.base.module.Proposition; |
|
48 |
| import org.qedeq.kernel.base.module.Qedeq; |
|
49 |
| import org.qedeq.kernel.base.module.Rule; |
|
50 |
| import org.qedeq.kernel.base.module.Section; |
|
51 |
| import org.qedeq.kernel.base.module.SectionList; |
|
52 |
| import org.qedeq.kernel.base.module.Specification; |
|
53 |
| import org.qedeq.kernel.base.module.Subsection; |
|
54 |
| import org.qedeq.kernel.base.module.SubsectionList; |
|
55 |
| import org.qedeq.kernel.base.module.Term; |
|
56 |
| import org.qedeq.kernel.base.module.UsedByList; |
|
57 |
| import org.qedeq.kernel.base.module.VariableList; |
|
58 |
| import org.qedeq.kernel.bo.visitor.AbstractModuleVisitor; |
|
59 |
| import org.qedeq.kernel.bo.visitor.QedeqNotNullTraverser; |
|
60 |
| import org.qedeq.kernel.common.ModuleContext; |
|
61 |
| import org.qedeq.kernel.common.ModuleDataException; |
|
62 |
| import org.qedeq.kernel.trace.Trace; |
|
63 |
| import org.qedeq.kernel.utility.Enumerator; |
|
64 |
| import org.qedeq.kernel.xml.tracker.SimpleXPath; |
|
65 |
| |
|
66 |
| |
|
67 |
| |
|
68 |
| |
|
69 |
| |
|
70 |
| |
|
71 |
| |
|
72 |
| |
|
73 |
| |
|
74 |
| |
|
75 |
| |
|
76 |
| |
|
77 |
| |
|
78 |
| |
|
79 |
| |
|
80 |
| |
|
81 |
| |
|
82 |
| |
|
83 |
| |
|
84 |
| |
|
85 |
| |
|
86 |
| |
|
87 |
| public final class Context2SimpleXPath extends AbstractModuleVisitor { |
|
88 |
| |
|
89 |
| |
|
90 |
| private static final Class CLASS = Context2SimpleXPath.class; |
|
91 |
| |
|
92 |
| |
|
93 |
| private QedeqNotNullTraverser traverser; |
|
94 |
| |
|
95 |
| |
|
96 |
| private Qedeq qedeq; |
|
97 |
| |
|
98 |
| |
|
99 |
| private final ModuleContext find; |
|
100 |
| |
|
101 |
| |
|
102 |
| private SimpleXPath current; |
|
103 |
| |
|
104 |
| |
|
105 |
| private final List elements; |
|
106 |
| |
|
107 |
| |
|
108 |
| private int level; |
|
109 |
| |
|
110 |
| |
|
111 |
| private boolean matching; |
|
112 |
| |
|
113 |
| |
|
114 |
| private String matchingBegin; |
|
115 |
| |
|
116 |
| |
|
117 |
| private SimpleXPath matchingPath; |
|
118 |
| |
|
119 |
| |
|
120 |
| |
|
121 |
| |
|
122 |
| |
|
123 |
| |
|
124 |
| |
|
125 |
32356
| private Context2SimpleXPath(final ModuleContext find, final Qedeq qedeq) {
|
|
126 |
32356
| this.qedeq = qedeq;
|
|
127 |
32356
| traverser = new QedeqNotNullTraverser(find.getModuleLocation(), this);
|
|
128 |
32356
| this.find = find;
|
|
129 |
32356
| elements = new ArrayList(20);
|
|
130 |
| } |
|
131 |
| |
|
132 |
| |
|
133 |
| |
|
134 |
| |
|
135 |
| |
|
136 |
| |
|
137 |
| |
|
138 |
| |
|
139 |
| |
|
140 |
| |
|
141 |
| |
|
142 |
| |
|
143 |
| |
|
144 |
| |
|
145 |
| |
|
146 |
| |
|
147 |
| |
|
148 |
| |
|
149 |
| |
|
150 |
| |
|
151 |
| |
|
152 |
| |
|
153 |
| |
|
154 |
| |
|
155 |
| |
|
156 |
| |
|
157 |
32356
| public static SimpleXPath getXPath(final ModuleContext find, final Qedeq qedeq)
|
|
158 |
| throws ModuleDataException { |
|
159 |
32356
| final Context2SimpleXPath converter = new Context2SimpleXPath(find, qedeq);
|
|
160 |
32356
| return converter.find();
|
|
161 |
| } |
|
162 |
| |
|
163 |
32356
| private final SimpleXPath find() throws ModuleDataException {
|
|
164 |
32356
| final String method = "find()";
|
|
165 |
32356
| Trace.paramInfo(CLASS, this, method, "find", find);
|
|
166 |
32356
| elements.clear();
|
|
167 |
32356
| level = 0;
|
|
168 |
32356
| current = new SimpleXPath();
|
|
169 |
32356
| try {
|
|
170 |
32356
| traverser.accept(qedeq);
|
|
171 |
| } catch (LocationFoundException e) { |
|
172 |
32356
| Trace.paramInfo(CLASS, this, method, "location found", current);
|
|
173 |
32356
| return current;
|
|
174 |
| } |
|
175 |
0
| Trace.param(CLASS, this, method, "level", level);
|
|
176 |
0
| Trace.info(CLASS, this, method, "location was not found");
|
|
177 |
0
| throw new LocationNotFoundException(find);
|
|
178 |
| } |
|
179 |
| |
|
180 |
32356
| public final void visitEnter(final Qedeq qedeq) throws ModuleDataException {
|
|
181 |
32356
| enter("QEDEQ");
|
|
182 |
32356
| final String method = "visitEnter(Qedeq)";
|
|
183 |
32356
| Trace.param(CLASS, this, method, "current", current);
|
|
184 |
32356
| checkMatching(method);
|
|
185 |
| } |
|
186 |
| |
|
187 |
0
| public final void visitLeave(final Qedeq qedeq) {
|
|
188 |
0
| leave();
|
|
189 |
| } |
|
190 |
| |
|
191 |
32354
| public final void visitEnter(final Header header) throws ModuleDataException {
|
|
192 |
32354
| enter("HEADER");
|
|
193 |
32354
| final String method = "visitEnter(Header)";
|
|
194 |
32354
| Trace.param(CLASS, this, method, "current", current);
|
|
195 |
32354
| final String context = traverser.getCurrentContext().getLocationWithinModule();
|
|
196 |
32354
| checkMatching(method);
|
|
197 |
| |
|
198 |
32341
| traverser.setLocationWithinModule(context + ".getEmail()");
|
|
199 |
32341
| current.setAttribute("email");
|
|
200 |
32341
| checkIfFound();
|
|
201 |
| } |
|
202 |
| |
|
203 |
31849
| public final void visitLeave(final Header header) {
|
|
204 |
31849
| leave();
|
|
205 |
| } |
|
206 |
| |
|
207 |
600
| public final void visitEnter(final Specification specification) throws ModuleDataException {
|
|
208 |
600
| enter("SPECIFICATION");
|
|
209 |
600
| final String method = "visitEnter(Specification)";
|
|
210 |
600
| Trace.param(CLASS, this, method, "current", current);
|
|
211 |
600
| final String context = traverser.getCurrentContext().getLocationWithinModule();
|
|
212 |
600
| checkMatching(method);
|
|
213 |
| |
|
214 |
552
| traverser.setLocationWithinModule(context + ".getName()");
|
|
215 |
552
| current.setAttribute("name");
|
|
216 |
552
| checkIfFound();
|
|
217 |
| |
|
218 |
530
| traverser.setLocationWithinModule(context + ".getRuleVersion()");
|
|
219 |
530
| current.setAttribute("ruleVersion");
|
|
220 |
530
| checkIfFound();
|
|
221 |
| } |
|
222 |
| |
|
223 |
376
| public final void visitLeave(final Specification specification) {
|
|
224 |
376
| leave();
|
|
225 |
| } |
|
226 |
| |
|
227 |
175541
| public final void visitEnter(final LatexList latexList) throws ModuleDataException {
|
|
228 |
175541
| final String method = "visitEnter(LatexList)";
|
|
229 |
175541
| final String context = traverser.getCurrentContext().getLocationWithinModule();
|
|
230 |
175541
| final String name;
|
|
231 |
175541
| if (context.endsWith(".getTitle()")) {
|
|
232 |
74609
| name = "TITLE";
|
|
233 |
100932
| } else if (context.endsWith(".getSummary()")) {
|
|
234 |
330
| name = "ABSTRACT";
|
|
235 |
100602
| } else if (context.endsWith(".getIntroduction()")) {
|
|
236 |
61508
| name = "INTRODUCTION";
|
|
237 |
39094
| } else if (context.endsWith(".getName()")) {
|
|
238 |
12539
| name = "NAME";
|
|
239 |
26555
| } else if (context.endsWith(".getPrecedingText()")) {
|
|
240 |
25763
| name = "PRECEDING";
|
|
241 |
792
| } else if (context.endsWith(".getSucceedingText()")) {
|
|
242 |
284
| name = "SUCCEEDING";
|
|
243 |
508
| } else if (context.endsWith(".getLatex()")) {
|
|
244 |
166
| name = "TEXT";
|
|
245 |
342
| } else if (context.endsWith(".getDescription()")) {
|
|
246 |
160
| name = "DESCRIPTION";
|
|
247 |
182
| } else if (context.endsWith(".getNonFormalProof()")) {
|
|
248 |
84
| name = null;
|
|
249 |
98
| } else if (context.endsWith(".getItem()")) {
|
|
250 |
98
| name = null;
|
|
251 |
| } else { |
|
252 |
0
| throw new IllegalArgumentException("unknown LatexList " + context);
|
|
253 |
| } |
|
254 |
175541
| Trace.param(CLASS, this, method, "name", name);
|
|
255 |
175541
| if (name != null) {
|
|
256 |
175359
| enter(name);
|
|
257 |
| } |
|
258 |
175541
| Trace.param(CLASS, this, method, "current", current);
|
|
259 |
| |
|
260 |
175541
| checkMatching(method);
|
|
261 |
| } |
|
262 |
| |
|
263 |
170115
| public final void visitLeave(final LatexList latexList) {
|
|
264 |
170115
| final String context = traverser.getCurrentContext().getLocationWithinModule();
|
|
265 |
170115
| if (!context.endsWith(".getNonFormalProof()")
|
|
266 |
| && !context.endsWith(".getItem()")) { |
|
267 |
170115
| leave();
|
|
268 |
| } |
|
269 |
| } |
|
270 |
| |
|
271 |
4163
| public final void visitEnter(final Latex latex) throws ModuleDataException {
|
|
272 |
4163
| final String context = traverser.getCurrentContext().getLocationWithinModule();
|
|
273 |
4163
| if (context.indexOf(".getAuthorList().get(") >= 0) {
|
|
274 |
13
| enter("NAME");
|
|
275 |
| } |
|
276 |
4163
| enter("LATEX");
|
|
277 |
4163
| final String method = "visitEnter(Latex)";
|
|
278 |
4163
| Trace.param(CLASS, this, method, "current", current);
|
|
279 |
4163
| checkMatching(method);
|
|
280 |
| |
|
281 |
1308
| traverser.setLocationWithinModule(context + ".getLanguage()");
|
|
282 |
1308
| current.setAttribute("language");
|
|
283 |
1308
| checkIfFound();
|
|
284 |
| |
|
285 |
1308
| traverser.setLocationWithinModule(context + ".getLatex()");
|
|
286 |
1308
| current.setAttribute(null);
|
|
287 |
1308
| checkIfFound();
|
|
288 |
| } |
|
289 |
| |
|
290 |
1308
| public final void visitLeave(final Latex latex) {
|
|
291 |
| |
|
292 |
1308
| final String context = traverser.getCurrentContext().getLocationWithinModule();
|
|
293 |
1308
| if (context.indexOf(".getAuthorList().get(") >= 0) {
|
|
294 |
0
| leave();
|
|
295 |
| } |
|
296 |
1308
| leave();
|
|
297 |
| } |
|
298 |
| |
|
299 |
132
| public final void visitEnter(final LocationList locationList) throws ModuleDataException {
|
|
300 |
132
| enter("LOCATIONS");
|
|
301 |
132
| final String method = "visitEnter(LocationList)";
|
|
302 |
132
| Trace.param(CLASS, this, method, "current", current);
|
|
303 |
132
| checkMatching(method);
|
|
304 |
| |
|
305 |
| } |
|
306 |
| |
|
307 |
0
| public final void visitLeave(final LocationList locationList) {
|
|
308 |
0
| leave();
|
|
309 |
| } |
|
310 |
| |
|
311 |
98
| public final void visitEnter(final Location location) throws ModuleDataException {
|
|
312 |
98
| enter("LOCATION");
|
|
313 |
98
| final String method = "visitEnter(Location)";
|
|
314 |
98
| Trace.param(CLASS, this, method, "current", current);
|
|
315 |
98
| final String context = traverser.getCurrentContext().getLocationWithinModule();
|
|
316 |
98
| checkMatching(method);
|
|
317 |
| |
|
318 |
40
| traverser.setLocationWithinModule(context + ".getLocation()");
|
|
319 |
40
| current.setAttribute("value");
|
|
320 |
40
| checkIfFound();
|
|
321 |
| } |
|
322 |
| |
|
323 |
14
| public final void visitLeave(final Location location) {
|
|
324 |
14
| leave();
|
|
325 |
| } |
|
326 |
| |
|
327 |
284
| public final void visitEnter(final AuthorList authorList) throws ModuleDataException {
|
|
328 |
284
| enter("AUTHORS");
|
|
329 |
284
| final String method = "visitEnter(AuthorList)";
|
|
330 |
284
| Trace.param(CLASS, this, method, "current", current);
|
|
331 |
284
| checkMatching(method);
|
|
332 |
| } |
|
333 |
| |
|
334 |
212
| public final void visitLeave(final AuthorList authorList) {
|
|
335 |
212
| leave();
|
|
336 |
| } |
|
337 |
| |
|
338 |
48
| public final void visitEnter(final Author author) throws ModuleDataException {
|
|
339 |
48
| enter("AUTHOR");
|
|
340 |
48
| final String method = "visitEnter(Author)";
|
|
341 |
48
| Trace.param(CLASS, this, method, "current", current);
|
|
342 |
48
| final String context = traverser.getCurrentContext().getLocationWithinModule();
|
|
343 |
48
| checkMatching(method);
|
|
344 |
| |
|
345 |
24
| traverser.setLocationWithinModule(context + ".getEmail()");
|
|
346 |
24
| current.setAttribute("email");
|
|
347 |
24
| checkIfFound();
|
|
348 |
| } |
|
349 |
| |
|
350 |
0
| public final void visitLeave(final Author author) {
|
|
351 |
0
| leave();
|
|
352 |
| } |
|
353 |
| |
|
354 |
190
| public final void visitEnter(final ImportList importList) throws ModuleDataException {
|
|
355 |
190
| enter("IMPORTS");
|
|
356 |
190
| final String method = "visitEnter(ImportList)";
|
|
357 |
190
| Trace.param(CLASS, this, method, "current", current);
|
|
358 |
190
| checkMatching(method);
|
|
359 |
| } |
|
360 |
| |
|
361 |
33
| public final void visitLeave(final ImportList importList) {
|
|
362 |
33
| leave();
|
|
363 |
| } |
|
364 |
| |
|
365 |
179
| public final void visitEnter(final Import imp) throws ModuleDataException {
|
|
366 |
179
| enter("IMPORT");
|
|
367 |
179
| final String method = "visitEnter(Import)";
|
|
368 |
179
| Trace.param(CLASS, this, method, "current", current);
|
|
369 |
179
| final String context = traverser.getCurrentContext().getLocationWithinModule();
|
|
370 |
179
| checkMatching(method);
|
|
371 |
| |
|
372 |
114
| traverser.setLocationWithinModule(context + ".getLabel()");
|
|
373 |
114
| current.setAttribute("label");
|
|
374 |
114
| checkIfFound();
|
|
375 |
| } |
|
376 |
| |
|
377 |
34
| public final void visitLeave(final Import imp) {
|
|
378 |
34
| leave();
|
|
379 |
| } |
|
380 |
| |
|
381 |
55
| public final void visitEnter(final UsedByList usedByList) throws ModuleDataException {
|
|
382 |
55
| enter("USEDBY");
|
|
383 |
55
| final String method = "visitEnter(UsedByList)";
|
|
384 |
55
| Trace.param(CLASS, this, method, "current", current);
|
|
385 |
55
| checkMatching(method);
|
|
386 |
| } |
|
387 |
| |
|
388 |
0
| public final void visitLeave(final UsedByList usedByList) {
|
|
389 |
0
| leave();
|
|
390 |
| } |
|
391 |
| |
|
392 |
31849
| public final void visitEnter(final ChapterList chapterList) throws ModuleDataException {
|
|
393 |
31849
| final String method = "visitEnter(ChapterList)";
|
|
394 |
| |
|
395 |
| |
|
396 |
31849
| checkMatching(method);
|
|
397 |
| } |
|
398 |
| |
|
399 |
170
| public final void visitLeave(final ChapterList chapterList) {
|
|
400 |
170
| traverser.setBlocked(false);
|
|
401 |
| } |
|
402 |
| |
|
403 |
139832
| public final void visitEnter(final Chapter chapter) throws ModuleDataException {
|
|
404 |
139832
| enter("CHAPTER");
|
|
405 |
139832
| final String method = "visitEnter(Chapter)";
|
|
406 |
139832
| Trace.param(CLASS, this, method, "current", current);
|
|
407 |
139832
| final String context = traverser.getCurrentContext().getLocationWithinModule();
|
|
408 |
139832
| checkMatching(method);
|
|
409 |
| |
|
410 |
139706
| traverser.setLocationWithinModule(context + ".getNoNumber()");
|
|
411 |
139706
| current.setAttribute("noNumber");
|
|
412 |
139706
| checkIfFound();
|
|
413 |
| } |
|
414 |
| |
|
415 |
108166
| public final void visitLeave(final Chapter chapter) {
|
|
416 |
108166
| leave();
|
|
417 |
| } |
|
418 |
| |
|
419 |
31039
| public final void visitEnter(final SectionList sectionList) throws ModuleDataException {
|
|
420 |
31039
| final String method = "visitEnter(SectionList)";
|
|
421 |
| |
|
422 |
| |
|
423 |
31039
| checkMatching(method);
|
|
424 |
| } |
|
425 |
| |
|
426 |
0
| public final void visitLeave(final SectionList sectionList) {
|
|
427 |
0
| traverser.setBlocked(false);
|
|
428 |
| } |
|
429 |
| |
|
430 |
75171
| public final void visitEnter(final Section section) throws ModuleDataException {
|
|
431 |
75171
| enter("SECTION");
|
|
432 |
75171
| final String method = "visitEnter(Section)";
|
|
433 |
75171
| Trace.param(CLASS, this, method, "current", current);
|
|
434 |
75171
| final String context = traverser.getCurrentContext().getLocationWithinModule();
|
|
435 |
75171
| checkMatching(method);
|
|
436 |
| |
|
437 |
74937
| traverser.setLocationWithinModule(context + ".getNoNumber()");
|
|
438 |
74937
| current.setAttribute("noNumber");
|
|
439 |
74937
| checkIfFound();
|
|
440 |
| } |
|
441 |
| |
|
442 |
44208
| public final void visitLeave(final Section section) {
|
|
443 |
44208
| leave();
|
|
444 |
| } |
|
445 |
| |
|
446 |
29809
| public final void visitEnter(final SubsectionList subsectionList) throws ModuleDataException {
|
|
447 |
29809
| enter("SUBSECTIONS");
|
|
448 |
29809
| final String method = "visitEnter(SubsectionList)";
|
|
449 |
29809
| Trace.param(CLASS, this, method, "current", current);
|
|
450 |
29809
| checkMatching(method);
|
|
451 |
| } |
|
452 |
| |
|
453 |
0
| public final void visitLeave(final SubsectionList subsectionList) {
|
|
454 |
0
| leave();
|
|
455 |
| } |
|
456 |
| |
|
457 |
3600
| public final void visitEnter(final Subsection subsection) throws ModuleDataException {
|
|
458 |
3600
| enter("SUBSECTION");
|
|
459 |
3600
| final String method = "visitEnter(Subsection)";
|
|
460 |
3600
| Trace.param(CLASS, this, method, "current", current);
|
|
461 |
3600
| final String context = traverser.getCurrentContext().getLocationWithinModule();
|
|
462 |
3600
| checkMatching(method);
|
|
463 |
| |
|
464 |
3498
| traverser.setLocationWithinModule(context + ".getId()");
|
|
465 |
3498
| current.setAttribute("id");
|
|
466 |
3498
| checkIfFound();
|
|
467 |
| |
|
468 |
3498
| traverser.setLocationWithinModule(context + ".getLevel()");
|
|
469 |
3498
| current.setAttribute("level");
|
|
470 |
3498
| checkIfFound();
|
|
471 |
| } |
|
472 |
| |
|
473 |
3212
| public final void visitLeave(final Subsection subsection) {
|
|
474 |
3212
| leave();
|
|
475 |
| } |
|
476 |
| |
|
477 |
145595
| public final void visitEnter(final Node node) throws ModuleDataException {
|
|
478 |
145595
| enter("NODE");
|
|
479 |
145595
| final String method = "visitEnter(Node)";
|
|
480 |
145595
| Trace.param(CLASS, this, method, "current", current);
|
|
481 |
145595
| final String context = traverser.getCurrentContext().getLocationWithinModule();
|
|
482 |
145595
| checkMatching(method);
|
|
483 |
| |
|
484 |
144881
| traverser.setLocationWithinModule(context + ".getId()");
|
|
485 |
144881
| current.setAttribute("id");
|
|
486 |
144881
| checkIfFound();
|
|
487 |
| |
|
488 |
144619
| traverser.setLocationWithinModule(context + ".getLevel()");
|
|
489 |
144619
| current.setAttribute("level");
|
|
490 |
144619
| checkIfFound();
|
|
491 |
| |
|
492 |
| |
|
493 |
144468
| traverser.setLocationWithinModule(context + ".getNodeType()");
|
|
494 |
144468
| current.setAttribute(null);
|
|
495 |
144468
| checkIfFound();
|
|
496 |
| |
|
497 |
| } |
|
498 |
| |
|
499 |
116304
| public final void visitLeave(final Node node) {
|
|
500 |
116304
| leave();
|
|
501 |
| } |
|
502 |
| |
|
503 |
2429
| public final void visitEnter(final Axiom axiom) throws ModuleDataException {
|
|
504 |
2429
| enter("AXIOM");
|
|
505 |
2429
| final String method = "visitEnter(Axiom)";
|
|
506 |
2429
| Trace.param(CLASS, this, method, "current", current);
|
|
507 |
2429
| checkMatching(method);
|
|
508 |
| } |
|
509 |
| |
|
510 |
68
| public final void visitLeave(final Axiom axiom) {
|
|
511 |
68
| leave();
|
|
512 |
| } |
|
513 |
| |
|
514 |
18275
| public final void visitEnter(final Proposition proposition) throws ModuleDataException {
|
|
515 |
18275
| enter("THEOREM");
|
|
516 |
18275
| final String method = "visitEnter(Proposition)";
|
|
517 |
18275
| Trace.param(CLASS, this, method, "current", current);
|
|
518 |
18275
| checkMatching(method);
|
|
519 |
| } |
|
520 |
| |
|
521 |
56
| public final void visitLeave(final Proposition proposition) {
|
|
522 |
56
| leave();
|
|
523 |
| } |
|
524 |
| |
|
525 |
195
| public final void visitEnter(final ProofList proofList) throws ModuleDataException {
|
|
526 |
195
| final String method = "visitEnter(ProofList)";
|
|
527 |
| |
|
528 |
| |
|
529 |
195
| checkMatching(method);
|
|
530 |
| } |
|
531 |
| |
|
532 |
159
| public final void visitEnter(final Proof proof) throws ModuleDataException {
|
|
533 |
159
| enter("PROOF");
|
|
534 |
159
| final String method = "visitEnter(Proof)";
|
|
535 |
159
| Trace.param(CLASS, this, method, "current", current);
|
|
536 |
159
| final String context = traverser.getCurrentContext().getLocationWithinModule();
|
|
537 |
159
| checkMatching(method);
|
|
538 |
| |
|
539 |
110
| traverser.setLocationWithinModule(context + ".getKind()");
|
|
540 |
110
| current.setAttribute("kind");
|
|
541 |
110
| checkIfFound();
|
|
542 |
| |
|
543 |
97
| traverser.setLocationWithinModule(context + ".getLevel()");
|
|
544 |
97
| current.setAttribute("level");
|
|
545 |
97
| checkIfFound();
|
|
546 |
| } |
|
547 |
| |
|
548 |
0
| public final void visitLeave(final Proof proof) {
|
|
549 |
0
| leave();
|
|
550 |
| } |
|
551 |
| |
|
552 |
1846
| public final void visitEnter(final PredicateDefinition definition) throws ModuleDataException {
|
|
553 |
1846
| enter("DEFINITION_PREDICATE");
|
|
554 |
1846
| final String method = "visitEnter(PredicateDefinition)";
|
|
555 |
1846
| Trace.param(CLASS, this, method, "current", current);
|
|
556 |
1846
| final String context = traverser.getCurrentContext().getLocationWithinModule();
|
|
557 |
1846
| checkMatching(method);
|
|
558 |
| |
|
559 |
1752
| traverser.setLocationWithinModule(context + ".getArgumentNumber()");
|
|
560 |
1752
| current.setAttribute("arguments");
|
|
561 |
1752
| checkIfFound();
|
|
562 |
| |
|
563 |
1712
| traverser.setLocationWithinModule(context + ".getName()");
|
|
564 |
1712
| current.setAttribute("name");
|
|
565 |
1712
| checkIfFound();
|
|
566 |
| |
|
567 |
1672
| traverser.setLocationWithinModule(context + ".getLatexPattern()");
|
|
568 |
1672
| enter("LATEXPATTERN");
|
|
569 |
1672
| if (find.getLocationWithinModule().equals(traverser.getCurrentContext()
|
|
570 |
| .getLocationWithinModule())) { |
|
571 |
40
| if (definition.getLatexPattern() == null) {
|
|
572 |
0
| leave();
|
|
573 |
| } |
|
574 |
40
| throw new LocationFoundException(traverser.getCurrentContext());
|
|
575 |
| } |
|
576 |
1632
| leave();
|
|
577 |
| } |
|
578 |
| |
|
579 |
80
| public final void visitLeave(final PredicateDefinition definition) {
|
|
580 |
80
| leave();
|
|
581 |
| } |
|
582 |
| |
|
583 |
2062
| public final void visitEnter(final FunctionDefinition definition) throws ModuleDataException {
|
|
584 |
2062
| enter("DEFINITION_FUNCTION");
|
|
585 |
2062
| final String method = "visitEnter(FunctionDefinition)";
|
|
586 |
2062
| Trace.param(CLASS, this, method, "current", current);
|
|
587 |
2062
| final String context = traverser.getCurrentContext().getLocationWithinModule();
|
|
588 |
2062
| checkMatching(method);
|
|
589 |
| |
|
590 |
1966
| traverser.setLocationWithinModule(context + ".getArgumentNumber()");
|
|
591 |
1966
| current.setAttribute("arguments");
|
|
592 |
1966
| checkIfFound();
|
|
593 |
| |
|
594 |
1934
| traverser.setLocationWithinModule(context + ".getName()");
|
|
595 |
1934
| current.setAttribute("name");
|
|
596 |
1934
| checkIfFound();
|
|
597 |
| |
|
598 |
1902
| traverser.setLocationWithinModule(context + ".getLatexPattern()");
|
|
599 |
1902
| enter("LATEXPATTERN");
|
|
600 |
1902
| if (find.getLocationWithinModule().equals(traverser.getCurrentContext()
|
|
601 |
| .getLocationWithinModule())) { |
|
602 |
32
| if (definition.getLatexPattern() == null) {
|
|
603 |
0
| leave();
|
|
604 |
| } |
|
605 |
32
| throw new LocationFoundException(traverser.getCurrentContext());
|
|
606 |
| } |
|
607 |
1870
| leave();
|
|
608 |
| } |
|
609 |
| |
|
610 |
42
| public final void visitLeave(final FunctionDefinition definition) {
|
|
611 |
42
| leave();
|
|
612 |
| } |
|
613 |
| |
|
614 |
240
| public final void visitEnter(final Rule rule) throws ModuleDataException {
|
|
615 |
240
| enter("RULE");
|
|
616 |
240
| final String method = "visitEnter(Rule)";
|
|
617 |
240
| Trace.param(CLASS, this, method, "current", current);
|
|
618 |
240
| final String context = traverser.getCurrentContext().getLocationWithinModule();
|
|
619 |
240
| checkMatching(method);
|
|
620 |
| |
|
621 |
186
| traverser.setLocationWithinModule(context + ".getName()");
|
|
622 |
186
| current.setAttribute("name");
|
|
623 |
186
| checkIfFound();
|
|
624 |
| } |
|
625 |
| |
|
626 |
38
| public final void visitLeave(final Rule rule) {
|
|
627 |
38
| leave();
|
|
628 |
| } |
|
629 |
| |
|
630 |
22
| public final void visitEnter(final LinkList linkList) throws ModuleDataException {
|
|
631 |
22
| final String method = "visitEnter(LinkList)";
|
|
632 |
22
| Trace.param(CLASS, this, method, "current", current);
|
|
633 |
22
| final String context = traverser.getCurrentContext().getLocationWithinModule();
|
|
634 |
22
| checkMatching(method);
|
|
635 |
| |
|
636 |
16
| for (int i = 0; i < linkList.size(); i++) {
|
|
637 |
16
| enter("LINK");
|
|
638 |
16
| if (linkList.get(i) != null) {
|
|
639 |
16
| traverser.setLocationWithinModule(context + ".get(" + i + ")");
|
|
640 |
16
| current.setAttribute("id");
|
|
641 |
16
| checkIfFound();
|
|
642 |
| } |
|
643 |
14
| leave();
|
|
644 |
| }; |
|
645 |
| } |
|
646 |
| |
|
647 |
14
| public final void visitLeave(final LinkList linkList) {
|
|
648 |
| } |
|
649 |
| |
|
650 |
21334
| public final void visitEnter(final Formula formula) throws ModuleDataException {
|
|
651 |
21334
| enter("FORMULA");
|
|
652 |
21334
| final String method = "visitEnter(Formula)";
|
|
653 |
21334
| Trace.param(CLASS, this, method, "current", current);
|
|
654 |
21334
| checkMatching(method);
|
|
655 |
| } |
|
656 |
| |
|
657 |
263
| public final void visitLeave(final Formula formula) {
|
|
658 |
263
| leave();
|
|
659 |
| } |
|
660 |
| |
|
661 |
1576
| public final void visitEnter(final Term term) throws ModuleDataException {
|
|
662 |
1576
| enter("TERM");
|
|
663 |
1576
| final String method = "visitEnter(Term)";
|
|
664 |
1576
| Trace.param(CLASS, this, method, "current", current);
|
|
665 |
1576
| checkMatching(method);
|
|
666 |
| } |
|
667 |
| |
|
668 |
42
| public final void visitLeave(final Term term) {
|
|
669 |
42
| leave();
|
|
670 |
| } |
|
671 |
| |
|
672 |
3254
| public final void visitEnter(final VariableList variableList) throws ModuleDataException {
|
|
673 |
3254
| enter("VARLIST");
|
|
674 |
3254
| final String method = "visitEnter(VariableList)";
|
|
675 |
3254
| Trace.param(CLASS, this, method, "current", current);
|
|
676 |
3254
| checkMatching(method);
|
|
677 |
| } |
|
678 |
| |
|
679 |
2566
| public final void visitLeave(final VariableList variableList) {
|
|
680 |
2566
| leave();
|
|
681 |
| } |
|
682 |
| |
|
683 |
185851
| public final void visitEnter(final ElementList list) throws ModuleDataException {
|
|
684 |
185851
| final String operator = list.getOperator();
|
|
685 |
185851
| enter(operator);
|
|
686 |
185851
| final String method = "visitEnter(ElementList)";
|
|
687 |
185851
| Trace.param(CLASS, this, method, "current", current);
|
|
688 |
185851
| final String context = traverser.getCurrentContext().getLocationWithinModule();
|
|
689 |
| |
|
690 |
| |
|
691 |
185851
| if (context.startsWith(find.getLocationWithinModule())) {
|
|
692 |
20067
| throw new LocationFoundException(find);
|
|
693 |
| } |
|
694 |
| |
|
695 |
165784
| checkMatching(method);
|
|
696 |
| |
|
697 |
165784
| traverser.setLocationWithinModule(context + ".getOperator()");
|
|
698 |
165784
| checkIfFound();
|
|
699 |
165784
| traverser.setLocationWithinModule(context);
|
|
700 |
165784
| final boolean firstIsAtom = list.size() > 0 && list.getElement(0).isAtom();
|
|
701 |
165784
| if (firstIsAtom) {
|
|
702 |
60276
| traverser.setLocationWithinModule(context + ".getElement(0).getAtom()");
|
|
703 |
60276
| if ("VAR".equals(operator) || "PREDVAR".equals(operator)
|
|
704 |
| || "FUNVAR".equals(operator)) { |
|
705 |
14608
| current.setAttribute("id");
|
|
706 |
14608
| checkIfFound();
|
|
707 |
45668
| } else if ("PREDCON".equals(operator) || "FUNCON".equals(operator)) {
|
|
708 |
45668
| current.setAttribute("ref");
|
|
709 |
45668
| checkIfFound();
|
|
710 |
| } else { |
|
711 |
0
| current.setAttribute(null);
|
|
712 |
0
| Trace.info(CLASS, this, method, "unknown operator " + operator);
|
|
713 |
0
| throw new LocationFoundException(traverser.getCurrentContext());
|
|
714 |
| } |
|
715 |
| } |
|
716 |
| } |
|
717 |
| |
|
718 |
| |
|
719 |
| |
|
720 |
| |
|
721 |
| |
|
722 |
| |
|
723 |
| |
|
724 |
| |
|
725 |
| |
|
726 |
| |
|
727 |
104095
| public final void visitLeave(final ElementList list) {
|
|
728 |
104095
| leave();
|
|
729 |
| } |
|
730 |
| |
|
731 |
170
| public final void visitEnter(final LiteratureItemList list) throws ModuleDataException {
|
|
732 |
170
| enter("BIBLIOGRAPHY");
|
|
733 |
170
| final String method = "visitEnter(LiteratureItemList)";
|
|
734 |
170
| Trace.param(CLASS, this, method, "current", current);
|
|
735 |
170
| checkMatching(method);
|
|
736 |
| } |
|
737 |
| |
|
738 |
0
| public final void visitLeave(final LiteratureItemList list) {
|
|
739 |
0
| leave();
|
|
740 |
| } |
|
741 |
| |
|
742 |
524
| public final void visitEnter(final LiteratureItem item) throws ModuleDataException {
|
|
743 |
524
| enter("ITEM");
|
|
744 |
524
| final String method = "visitEnter(LiteratureItem)";
|
|
745 |
524
| Trace.param(CLASS, this, method, "current", current);
|
|
746 |
524
| final String context = traverser.getCurrentContext().getLocationWithinModule();
|
|
747 |
524
| checkMatching(method);
|
|
748 |
| |
|
749 |
478
| traverser.setLocationWithinModule(context + ".getLabel()");
|
|
750 |
478
| current.setAttribute("label");
|
|
751 |
478
| checkIfFound();
|
|
752 |
| } |
|
753 |
| |
|
754 |
360
| public final void visitLeave(final LiteratureItem item) {
|
|
755 |
360
| leave();
|
|
756 |
| } |
|
757 |
| |
|
758 |
| |
|
759 |
| |
|
760 |
| |
|
761 |
| |
|
762 |
| |
|
763 |
1846900
| private final void checkIfFound() throws LocationFoundException {
|
|
764 |
1846900
| if (find.getLocationWithinModule().equals(traverser.getCurrentContext()
|
|
765 |
| .getLocationWithinModule())) { |
|
766 |
12217
| throw new LocationFoundException(traverser.getCurrentContext());
|
|
767 |
| } |
|
768 |
| } |
|
769 |
| |
|
770 |
| |
|
771 |
| |
|
772 |
| |
|
773 |
| |
|
774 |
| |
|
775 |
| |
|
776 |
| |
|
777 |
| |
|
778 |
| |
|
779 |
| |
|
780 |
| |
|
781 |
920765
| private final void checkMatching(final String method)
|
|
782 |
| throws LocationNotFoundException, LocationFoundException { |
|
783 |
920765
| final String context = traverser.getCurrentContext().getLocationWithinModule();
|
|
784 |
920765
| if (find.getLocationWithinModule().startsWith(context)) {
|
|
785 |
337140
| Trace.info(CLASS, this, method, "beginning matches");
|
|
786 |
337140
| Trace.paramInfo(CLASS, this, method, "context", context);
|
|
787 |
337140
| matching = true;
|
|
788 |
337140
| matchingBegin = context;
|
|
789 |
337140
| matchingPath = new SimpleXPath(current);
|
|
790 |
| } else { |
|
791 |
583625
| if (matching) {
|
|
792 |
| |
|
793 |
| |
|
794 |
| |
|
795 |
| |
|
796 |
| |
|
797 |
| |
|
798 |
583625
| if (!context.startsWith(matchingBegin)) {
|
|
799 |
| |
|
800 |
| |
|
801 |
| |
|
802 |
| |
|
803 |
0
| Trace.info(CLASS, this, method, "matching lost");
|
|
804 |
0
| Trace.paramInfo(CLASS, this, method, "last match ", matchingBegin);
|
|
805 |
0
| Trace.paramInfo(CLASS, this, method, "current context", context);
|
|
806 |
0
| Trace.paramInfo(CLASS, this, method,
|
|
807 |
| "find context ", find.getLocationWithinModule()); |
|
808 |
| |
|
809 |
| |
|
810 |
| |
|
811 |
0
| Trace.traceStack(CLASS, this, method);
|
|
812 |
0
| Trace.info(CLASS, this, method, "changing XPath to last matching one");
|
|
813 |
| |
|
814 |
| |
|
815 |
| |
|
816 |
0
| current = matchingPath;
|
|
817 |
0
| throw new LocationFoundException(new ModuleContext(find.getModuleLocation(),
|
|
818 |
| matchingBegin)); |
|
819 |
| } |
|
820 |
| } |
|
821 |
583625
| traverser.setBlocked(true);
|
|
822 |
| } |
|
823 |
920765
| checkIfFound();
|
|
824 |
| } |
|
825 |
| |
|
826 |
| |
|
827 |
| |
|
828 |
| |
|
829 |
| |
|
830 |
| |
|
831 |
881148
| private final void enter(final String element) {
|
|
832 |
881148
| level++;
|
|
833 |
881148
| current.addElement(element, addOccurence(element));
|
|
834 |
| } |
|
835 |
| |
|
836 |
| |
|
837 |
| |
|
838 |
| |
|
839 |
| |
|
840 |
| |
|
841 |
0
| private final void enterFirst(final String element) {
|
|
842 |
0
| level++;
|
|
843 |
0
| current.addElement(element);
|
|
844 |
| } |
|
845 |
| |
|
846 |
| |
|
847 |
| |
|
848 |
| |
|
849 |
586957
| private final void leave() {
|
|
850 |
586957
| level--;
|
|
851 |
586957
| current.deleteLastElement();
|
|
852 |
586957
| traverser.setBlocked(false);
|
|
853 |
| } |
|
854 |
| |
|
855 |
| |
|
856 |
| |
|
857 |
| |
|
858 |
| |
|
859 |
| |
|
860 |
| |
|
861 |
| |
|
862 |
| |
|
863 |
| |
|
864 |
| |
|
865 |
881148
| private final int addOccurence(final String name) {
|
|
866 |
881148
| while (level < elements.size()) {
|
|
867 |
122
| elements.remove(elements.size() - 1);
|
|
868 |
| } |
|
869 |
881148
| while (level > elements.size()) {
|
|
870 |
294438
| elements.add(new HashMap());
|
|
871 |
| } |
|
872 |
881148
| final Map levelMap = (Map) elements.get(level - 1);
|
|
873 |
881148
| final Enumerator counter;
|
|
874 |
881148
| if (levelMap.containsKey(name)) {
|
|
875 |
347606
| counter = (Enumerator) levelMap.get(name);
|
|
876 |
347606
| counter.increaseNumber();
|
|
877 |
| } else { |
|
878 |
533542
| counter = new Enumerator(1);
|
|
879 |
533542
| levelMap.put(name, counter);
|
|
880 |
| } |
|
881 |
881148
| return counter.getNumber();
|
|
882 |
| } |
|
883 |
| |
|
884 |
| } |