1 |
| |
2 |
| |
3 |
| |
4 |
| |
5 |
| |
6 |
| |
7 |
| |
8 |
| |
9 |
| |
10 |
| |
11 |
| |
12 |
| |
13 |
| |
14 |
| |
15 |
| |
16 |
| |
17 |
| |
18 |
| package org.qedeq.kernel.bo.load; |
19 |
| |
20 |
| import org.qedeq.kernel.base.list.Atom; |
21 |
| import org.qedeq.kernel.base.list.Element; |
22 |
| import org.qedeq.kernel.base.list.ElementList; |
23 |
| import org.qedeq.kernel.base.module.Author; |
24 |
| import org.qedeq.kernel.base.module.AuthorList; |
25 |
| import org.qedeq.kernel.base.module.Axiom; |
26 |
| import org.qedeq.kernel.base.module.Chapter; |
27 |
| import org.qedeq.kernel.base.module.ChapterList; |
28 |
| import org.qedeq.kernel.base.module.Formula; |
29 |
| import org.qedeq.kernel.base.module.FunctionDefinition; |
30 |
| import org.qedeq.kernel.base.module.Header; |
31 |
| import org.qedeq.kernel.base.module.Import; |
32 |
| import org.qedeq.kernel.base.module.ImportList; |
33 |
| import org.qedeq.kernel.base.module.Latex; |
34 |
| import org.qedeq.kernel.base.module.LatexList; |
35 |
| import org.qedeq.kernel.base.module.LinkList; |
36 |
| import org.qedeq.kernel.base.module.LiteratureItem; |
37 |
| import org.qedeq.kernel.base.module.LiteratureItemList; |
38 |
| import org.qedeq.kernel.base.module.Location; |
39 |
| import org.qedeq.kernel.base.module.LocationList; |
40 |
| import org.qedeq.kernel.base.module.Node; |
41 |
| import org.qedeq.kernel.base.module.PredicateDefinition; |
42 |
| import org.qedeq.kernel.base.module.Proof; |
43 |
| import org.qedeq.kernel.base.module.ProofList; |
44 |
| import org.qedeq.kernel.base.module.Proposition; |
45 |
| import org.qedeq.kernel.base.module.Qedeq; |
46 |
| import org.qedeq.kernel.base.module.Rule; |
47 |
| import org.qedeq.kernel.base.module.Section; |
48 |
| import org.qedeq.kernel.base.module.SectionList; |
49 |
| import org.qedeq.kernel.base.module.Specification; |
50 |
| import org.qedeq.kernel.base.module.Subsection; |
51 |
| import org.qedeq.kernel.base.module.SubsectionList; |
52 |
| import org.qedeq.kernel.base.module.Term; |
53 |
| import org.qedeq.kernel.base.module.UsedByList; |
54 |
| import org.qedeq.kernel.base.module.VariableList; |
55 |
| import org.qedeq.kernel.bo.control.QedeqBoDuplicateLanguageChecker; |
56 |
| import org.qedeq.kernel.bo.control.QedeqBoFormalLogicChecker; |
57 |
| import org.qedeq.kernel.bo.module.IllegalModuleDataException; |
58 |
| import org.qedeq.kernel.bo.module.ModuleContext; |
59 |
| import org.qedeq.kernel.bo.module.ModuleDataException; |
60 |
| import org.qedeq.kernel.bo.module.QedeqBo; |
61 |
| import org.qedeq.kernel.dto.list.DefaultAtom; |
62 |
| import org.qedeq.kernel.dto.list.DefaultElementList; |
63 |
| import org.qedeq.kernel.dto.module.AuthorListVo; |
64 |
| import org.qedeq.kernel.dto.module.AuthorVo; |
65 |
| import org.qedeq.kernel.dto.module.AxiomVo; |
66 |
| import org.qedeq.kernel.dto.module.ChapterListVo; |
67 |
| import org.qedeq.kernel.dto.module.ChapterVo; |
68 |
| import org.qedeq.kernel.dto.module.FormulaVo; |
69 |
| import org.qedeq.kernel.dto.module.FunctionDefinitionVo; |
70 |
| import org.qedeq.kernel.dto.module.HeaderVo; |
71 |
| import org.qedeq.kernel.dto.module.ImportListVo; |
72 |
| import org.qedeq.kernel.dto.module.ImportVo; |
73 |
| import org.qedeq.kernel.dto.module.LatexListVo; |
74 |
| import org.qedeq.kernel.dto.module.LatexVo; |
75 |
| import org.qedeq.kernel.dto.module.LinkListVo; |
76 |
| import org.qedeq.kernel.dto.module.LiteratureItemListVo; |
77 |
| import org.qedeq.kernel.dto.module.LiteratureItemVo; |
78 |
| import org.qedeq.kernel.dto.module.LocationListVo; |
79 |
| import org.qedeq.kernel.dto.module.LocationVo; |
80 |
| import org.qedeq.kernel.dto.module.NodeVo; |
81 |
| import org.qedeq.kernel.dto.module.PredicateDefinitionVo; |
82 |
| import org.qedeq.kernel.dto.module.ProofListVo; |
83 |
| import org.qedeq.kernel.dto.module.ProofVo; |
84 |
| import org.qedeq.kernel.dto.module.PropositionVo; |
85 |
| import org.qedeq.kernel.dto.module.RuleVo; |
86 |
| import org.qedeq.kernel.dto.module.SectionListVo; |
87 |
| import org.qedeq.kernel.dto.module.SectionVo; |
88 |
| import org.qedeq.kernel.dto.module.SpecificationVo; |
89 |
| import org.qedeq.kernel.dto.module.SubsectionListVo; |
90 |
| import org.qedeq.kernel.dto.module.SubsectionVo; |
91 |
| import org.qedeq.kernel.dto.module.TermVo; |
92 |
| import org.qedeq.kernel.dto.module.UsedByListVo; |
93 |
| import org.qedeq.kernel.dto.module.VariableListVo; |
94 |
| |
95 |
| |
96 |
| |
97 |
| |
98 |
| |
99 |
| |
100 |
| |
101 |
| |
102 |
| |
103 |
| |
104 |
| |
105 |
| |
106 |
| |
107 |
| |
108 |
| |
109 |
| |
110 |
| public class QedeqBoFactory { |
111 |
| |
112 |
| |
113 |
| private DefaultQedeqBo qedeq; |
114 |
| |
115 |
| |
116 |
| private Qedeq original; |
117 |
| |
118 |
| |
119 |
| private ModuleContext currentContext; |
120 |
| |
121 |
| |
122 |
| |
123 |
| |
124 |
| |
125 |
| |
126 |
28
| protected QedeqBoFactory(final String globalContext) {
|
127 |
28
| currentContext = new ModuleContext(globalContext);
|
128 |
| } |
129 |
| |
130 |
| |
131 |
| |
132 |
| |
133 |
| |
134 |
| |
135 |
| |
136 |
| |
137 |
| |
138 |
| |
139 |
| |
140 |
| |
141 |
| |
142 |
| |
143 |
| |
144 |
17
| public static DefaultQedeqBo createQedeq(final String globalContext, final Qedeq original)
|
145 |
| throws ModuleDataException { |
146 |
17
| final QedeqBoFactory creator = new QedeqBoFactory(globalContext);
|
147 |
17
| DefaultQedeqBo bo = creator.create(original);
|
148 |
| |
149 |
| |
150 |
| |
151 |
| |
152 |
16
| QedeqBoFormalLogicChecker.check(globalContext, bo);
|
153 |
10
| QedeqBoDuplicateLanguageChecker.check(globalContext, bo);
|
154 |
9
| return bo;
|
155 |
| } |
156 |
| |
157 |
| |
158 |
| |
159 |
| |
160 |
| |
161 |
| |
162 |
| |
163 |
| |
164 |
| |
165 |
| |
166 |
| |
167 |
| |
168 |
| |
169 |
| |
170 |
| |
171 |
28
| protected final DefaultQedeqBo create(final Qedeq original) throws IllegalModuleDataException {
|
172 |
28
| this.original = original;
|
173 |
28
| getCurrentContext().setLocationWithinModule("");
|
174 |
28
| if (original == null) {
|
175 |
0
| qedeq = null;
|
176 |
0
| return qedeq;
|
177 |
| } |
178 |
28
| qedeq = new DefaultQedeqBo();
|
179 |
28
| final String context = getCurrentContext().getLocationWithinModule();
|
180 |
28
| if (original.getHeader() != null) {
|
181 |
28
| getCurrentContext().setLocationWithinModule(context + "getHeader()");
|
182 |
28
| qedeq.setHeader(create(original.getHeader()));
|
183 |
| } |
184 |
28
| if (original.getChapterList() != null) {
|
185 |
28
| getCurrentContext().setLocationWithinModule(context + "getChapterList()");
|
186 |
28
| qedeq.setChapterList(create(original.getChapterList()));
|
187 |
| } |
188 |
26
| if (original.getLiteratureItemList() != null) {
|
189 |
9
| getCurrentContext().setLocationWithinModule(context + "getLiteratureItemList()");
|
190 |
9
| qedeq.setLiteratureItemList(create(original.getLiteratureItemList()));
|
191 |
| } |
192 |
26
| return qedeq;
|
193 |
| } |
194 |
| |
195 |
| |
196 |
| |
197 |
| |
198 |
| |
199 |
| |
200 |
| |
201 |
| |
202 |
| |
203 |
| |
204 |
| |
205 |
| |
206 |
| |
207 |
| |
208 |
28
| private final HeaderVo create(final Header header)
|
209 |
| throws IllegalModuleDataException { |
210 |
28
| if (header == null) {
|
211 |
0
| return null;
|
212 |
| } |
213 |
28
| final HeaderVo h = new HeaderVo();
|
214 |
28
| final String context = getCurrentContext().getLocationWithinModule();
|
215 |
28
| if (header.getTitle() != null) {
|
216 |
28
| setLocationWithinModule(context + ".getTitle()");
|
217 |
28
| h.setTitle(create(header.getTitle()));
|
218 |
| } |
219 |
28
| if (header.getAuthorList() != null) {
|
220 |
28
| setLocationWithinModule(context + ".getAuthorList()");
|
221 |
28
| h.setAuthorList(create(header.getAuthorList()));
|
222 |
| } |
223 |
28
| if (header.getSummary() != null) {
|
224 |
28
| setLocationWithinModule(context + ".getSummary()");
|
225 |
28
| h.setSummary(create(header.getSummary()));
|
226 |
| } |
227 |
28
| if (header.getEmail() != null) {
|
228 |
28
| setLocationWithinModule(context + ".getEmail()");
|
229 |
28
| h.setEmail(header.getEmail());
|
230 |
| } |
231 |
28
| if (header.getSpecification() != null) {
|
232 |
28
| setLocationWithinModule(context + ".getSpecification()");
|
233 |
28
| h.setSpecification(create(header.getSpecification()));
|
234 |
| } |
235 |
28
| if (header.getImportList() != null) {
|
236 |
15
| setLocationWithinModule(context + ".getImportList()");
|
237 |
15
| h.setImportList(create(header.getImportList()));
|
238 |
| } |
239 |
28
| if (header.getUsedByList() != null) {
|
240 |
12
| setLocationWithinModule(context + ".getUsedByList()");
|
241 |
12
| h.setUsedByList(create(header.getUsedByList()));
|
242 |
| } |
243 |
28
| setLocationWithinModule(context);
|
244 |
28
| return h;
|
245 |
| } |
246 |
| |
247 |
| |
248 |
| |
249 |
| |
250 |
| |
251 |
| |
252 |
| |
253 |
| |
254 |
| |
255 |
| |
256 |
| |
257 |
| |
258 |
| |
259 |
12
| private final UsedByListVo create(final UsedByList usedByList) {
|
260 |
12
| if (usedByList == null) {
|
261 |
0
| return null;
|
262 |
| } |
263 |
12
| final String context = getCurrentContext().getLocationWithinModule();
|
264 |
12
| final UsedByListVo list = new UsedByListVo();
|
265 |
12
| for (int i = 0; i < usedByList.size(); i++) {
|
266 |
12
| setLocationWithinModule(context + ".get(" + i + ")");
|
267 |
12
| list.add(create(usedByList.get(i)));
|
268 |
| } |
269 |
12
| setLocationWithinModule(context);
|
270 |
12
| return list;
|
271 |
| } |
272 |
| |
273 |
15
| private final ImportListVo create(final ImportList importList) {
|
274 |
15
| if (importList == null) {
|
275 |
0
| return null;
|
276 |
| } |
277 |
15
| final String context = getCurrentContext().getLocationWithinModule();
|
278 |
15
| final ImportListVo list = new ImportListVo();
|
279 |
15
| for (int i = 0; i < importList.size(); i++) {
|
280 |
24
| setLocationWithinModule(context + ".get(" + i + ")");
|
281 |
24
| list.add(create(importList.get(i)));
|
282 |
| } |
283 |
15
| setLocationWithinModule(context);
|
284 |
15
| return list;
|
285 |
| } |
286 |
| |
287 |
24
| private final ImportVo create(final Import imp) {
|
288 |
24
| if (imp == null) {
|
289 |
0
| return null;
|
290 |
| } |
291 |
24
| final ImportVo i = new ImportVo();
|
292 |
24
| final String context = getCurrentContext().getLocationWithinModule();
|
293 |
24
| if (imp.getLabel() != null) {
|
294 |
24
| setLocationWithinModule(context + ".getLabel()");
|
295 |
24
| i.setLabel(imp.getLabel());
|
296 |
| } |
297 |
24
| if (imp.getSpecification() != null) {
|
298 |
24
| setLocationWithinModule(context + ".getSpecification()");
|
299 |
24
| i.setSpecification(create(imp.getSpecification()));
|
300 |
| } |
301 |
24
| setLocationWithinModule(context);
|
302 |
24
| return i;
|
303 |
| } |
304 |
| |
305 |
64
| private final SpecificationVo create(final Specification specification) {
|
306 |
64
| if (specification == null) {
|
307 |
0
| return null;
|
308 |
| } |
309 |
64
| final SpecificationVo s = new SpecificationVo();
|
310 |
64
| final String context = getCurrentContext().getLocationWithinModule();
|
311 |
64
| if (specification.getName() != null) {
|
312 |
64
| setLocationWithinModule(context + ".getName()");
|
313 |
64
| s.setName(specification.getName());
|
314 |
| } |
315 |
64
| if (specification.getRuleVersion() != null) {
|
316 |
64
| setLocationWithinModule(context + ".getRuleVersion()");
|
317 |
64
| s.setRuleVersion(specification.getRuleVersion());
|
318 |
| } |
319 |
64
| if (specification.getLocationList() != null) {
|
320 |
64
| setLocationWithinModule(context + ".getLocationList()");
|
321 |
64
| s.setLocationList(create(specification.getLocationList()));
|
322 |
| } |
323 |
64
| setLocationWithinModule(context);
|
324 |
64
| return s;
|
325 |
| } |
326 |
| |
327 |
64
| private final LocationListVo create(final LocationList locationList) {
|
328 |
64
| if (locationList == null) {
|
329 |
0
| return null;
|
330 |
| } |
331 |
64
| final LocationListVo list = new LocationListVo();
|
332 |
64
| final String context = getCurrentContext().getLocationWithinModule();
|
333 |
64
| for (int i = 0; i < locationList.size(); i++) {
|
334 |
64
| setLocationWithinModule(context + ".get(" + i + ")");
|
335 |
64
| list.add(create(locationList.get(i)));
|
336 |
| } |
337 |
64
| setLocationWithinModule(context);
|
338 |
64
| return list;
|
339 |
| } |
340 |
| |
341 |
64
| private final LocationVo create(final Location location) {
|
342 |
64
| if (location == null) {
|
343 |
0
| return null;
|
344 |
| } |
345 |
64
| final LocationVo loc = new LocationVo();
|
346 |
64
| final String context = getCurrentContext().getLocationWithinModule();
|
347 |
64
| if (location.getLocation() != null) {
|
348 |
64
| setLocationWithinModule(context + ".getLocation()");
|
349 |
64
| loc.setLocation(location.getLocation());
|
350 |
| } |
351 |
64
| setLocationWithinModule(context);
|
352 |
64
| return loc;
|
353 |
| } |
354 |
| |
355 |
28
| private final AuthorListVo create(final AuthorList authorList) {
|
356 |
28
| if (authorList == null) {
|
357 |
0
| return null;
|
358 |
| } |
359 |
28
| final AuthorListVo list = new AuthorListVo();
|
360 |
28
| final String context = getCurrentContext().getLocationWithinModule();
|
361 |
28
| for (int i = 0; i < authorList.size(); i++) {
|
362 |
28
| setLocationWithinModule(context + ".get(" + i + ")");
|
363 |
28
| list.add(create(authorList.get(i)));
|
364 |
| } |
365 |
28
| setLocationWithinModule(context);
|
366 |
28
| return list;
|
367 |
| } |
368 |
| |
369 |
28
| private final AuthorVo create(final Author author) {
|
370 |
28
| if (author == null) {
|
371 |
0
| return null;
|
372 |
| } |
373 |
28
| final AuthorVo a = new AuthorVo();
|
374 |
28
| final String context = getCurrentContext().getLocationWithinModule();
|
375 |
28
| if (author.getName() != null) {
|
376 |
28
| setLocationWithinModule(context + ".getName()");
|
377 |
28
| a.setName(create(author.getName()));
|
378 |
| } |
379 |
28
| if (author.getEmail() != null) {
|
380 |
28
| setLocationWithinModule(context + ".getEmail()");
|
381 |
28
| a.setEmail(author.getEmail());
|
382 |
| } |
383 |
28
| setLocationWithinModule(context);
|
384 |
28
| return a;
|
385 |
| } |
386 |
| |
387 |
28
| private final ChapterListVo create(final ChapterList chapterList)
|
388 |
| throws IllegalModuleDataException { |
389 |
28
| if (chapterList == null) {
|
390 |
0
| return null;
|
391 |
| } |
392 |
28
| final ChapterListVo list = new ChapterListVo();
|
393 |
28
| final String context = getCurrentContext().getLocationWithinModule();
|
394 |
28
| for (int i = 0; i < chapterList.size(); i++) {
|
395 |
121
| setLocationWithinModule(context + ".get(" + i + ")");
|
396 |
121
| list.add(create(chapterList.get(i)));
|
397 |
| } |
398 |
26
| setLocationWithinModule(context);
|
399 |
26
| return list;
|
400 |
| } |
401 |
| |
402 |
121
| private final ChapterVo create(final Chapter chapter)
|
403 |
| throws IllegalModuleDataException { |
404 |
121
| if (chapter == null) {
|
405 |
0
| return null;
|
406 |
| } |
407 |
121
| final ChapterVo c = new ChapterVo();
|
408 |
121
| final String context = getCurrentContext().getLocationWithinModule();
|
409 |
121
| if (chapter.getTitle() != null) {
|
410 |
121
| setLocationWithinModule(context + ".getTitle()");
|
411 |
121
| c.setTitle(create(chapter.getTitle()));
|
412 |
| } |
413 |
121
| if (chapter.getNoNumber() != null) {
|
414 |
38
| setLocationWithinModule(context + ".getNoNumber()");
|
415 |
38
| c.setNoNumber(chapter.getNoNumber());
|
416 |
| } |
417 |
121
| if (chapter.getIntroduction() != null) {
|
418 |
118
| setLocationWithinModule(context + ".getIntroduction()");
|
419 |
118
| c.setIntroduction(create(chapter.getIntroduction()));
|
420 |
| } |
421 |
121
| if (chapter.getSectionList() != null) {
|
422 |
75
| setLocationWithinModule(context + ".getSectionList()");
|
423 |
75
| c.setSectionList(create(chapter.getSectionList()));
|
424 |
| } |
425 |
119
| setLocationWithinModule(context);
|
426 |
119
| return c;
|
427 |
| } |
428 |
| |
429 |
9
| private LiteratureItemListVo create(final LiteratureItemList literatureItemList)
|
430 |
| throws IllegalModuleDataException { |
431 |
9
| if (literatureItemList == null) {
|
432 |
0
| return null;
|
433 |
| } |
434 |
9
| final LiteratureItemListVo list = new LiteratureItemListVo();
|
435 |
9
| final String context = getCurrentContext().getLocationWithinModule();
|
436 |
9
| for (int i = 0; i < literatureItemList.size(); i++) {
|
437 |
39
| setLocationWithinModule(context + ".get(" + i + ")");
|
438 |
39
| list.add(create(literatureItemList.get(i)));
|
439 |
| } |
440 |
9
| setLocationWithinModule(context);
|
441 |
9
| return list;
|
442 |
| } |
443 |
| |
444 |
39
| private LiteratureItemVo create(final LiteratureItem item)
|
445 |
| throws IllegalModuleDataException { |
446 |
39
| if (item == null) {
|
447 |
0
| return null;
|
448 |
| } |
449 |
39
| final LiteratureItemVo it = new LiteratureItemVo();
|
450 |
39
| final String context = getCurrentContext().getLocationWithinModule();
|
451 |
39
| if (item.getLabel() != null) {
|
452 |
39
| setLocationWithinModule(context + ".getLabel()");
|
453 |
39
| it.setLabel(item.getLabel());
|
454 |
| } |
455 |
39
| if (item.getItem() != null) {
|
456 |
39
| setLocationWithinModule(context + ".getItem()");
|
457 |
39
| it.setItem(create(item.getItem()));
|
458 |
| } |
459 |
39
| setLocationWithinModule(context);
|
460 |
39
| return it;
|
461 |
| |
462 |
| } |
463 |
| |
464 |
75
| private final SectionListVo create(final SectionList sectionList)
|
465 |
| throws IllegalModuleDataException { |
466 |
75
| if (sectionList == null) {
|
467 |
0
| return null;
|
468 |
| } |
469 |
75
| final SectionListVo list = new SectionListVo();
|
470 |
75
| final String context = getCurrentContext().getLocationWithinModule();
|
471 |
75
| for (int i = 0; i < sectionList.size(); i++) {
|
472 |
224
| setLocationWithinModule(context + ".get(" + i + ")");
|
473 |
224
| list.add(create(sectionList.get(i)));
|
474 |
| } |
475 |
73
| setLocationWithinModule(context);
|
476 |
73
| return list;
|
477 |
| } |
478 |
| |
479 |
224
| private final SectionVo create(final Section section)
|
480 |
| throws IllegalModuleDataException { |
481 |
224
| if (section == null) {
|
482 |
0
| return null;
|
483 |
| } |
484 |
224
| final SectionVo s = new SectionVo();
|
485 |
224
| final String context = getCurrentContext().getLocationWithinModule();
|
486 |
224
| if (section.getTitle() != null) {
|
487 |
224
| setLocationWithinModule(context + ".getTitle()");
|
488 |
224
| s.setTitle(create(section.getTitle()));
|
489 |
| } |
490 |
224
| if (section.getNoNumber() != null) {
|
491 |
0
| setLocationWithinModule(context + ".getNoNumber()");
|
492 |
0
| s.setNoNumber(section.getNoNumber());
|
493 |
| } |
494 |
224
| if (section.getIntroduction() != null) {
|
495 |
221
| setLocationWithinModule(context + ".getIntroduction()");
|
496 |
221
| s.setIntroduction(create(section.getIntroduction()));
|
497 |
| } |
498 |
224
| if (section.getSubsectionList() != null) {
|
499 |
116
| setLocationWithinModule(context + ".getSubsectionList()");
|
500 |
116
| s.setSubsectionList(create(section.getSubsectionList()));
|
501 |
| } |
502 |
222
| setLocationWithinModule(context);
|
503 |
222
| return s;
|
504 |
| } |
505 |
| |
506 |
116
| private final SubsectionListVo create(final SubsectionList subsectionList)
|
507 |
| throws IllegalModuleDataException { |
508 |
116
| if (subsectionList == null) {
|
509 |
0
| return null;
|
510 |
| } |
511 |
116
| final SubsectionListVo list = new SubsectionListVo();
|
512 |
116
| final String context = getCurrentContext().getLocationWithinModule();
|
513 |
116
| for (int i = 0; i < subsectionList.size(); i++) {
|
514 |
704
| setLocationWithinModule(context + ".get(" + i + ")");
|
515 |
| |
516 |
704
| if (subsectionList.get(i) instanceof Subsection) {
|
517 |
82
| list.add(create((Subsection) subsectionList.get(i)));
|
518 |
622
| } else if (subsectionList.get(i) instanceof Node) {
|
519 |
622
| list.add(create((Node) subsectionList.get(i)));
|
520 |
| } else { |
521 |
0
| throw new IllegalArgumentException("unexpected subsection type: "
|
522 |
| + subsectionList.get(i).getClass()); |
523 |
| } |
524 |
| } |
525 |
114
| setLocationWithinModule(context);
|
526 |
114
| return list;
|
527 |
| } |
528 |
| |
529 |
82
| private final SubsectionVo create(final Subsection subsection) {
|
530 |
82
| if (subsection == null) {
|
531 |
0
| return null;
|
532 |
| } |
533 |
82
| final SubsectionVo s = new SubsectionVo();
|
534 |
82
| final String context = getCurrentContext().getLocationWithinModule();
|
535 |
82
| if (subsection.getTitle() != null) {
|
536 |
70
| setLocationWithinModule(context + ".getTitle()");
|
537 |
70
| s.setTitle(create(subsection.getTitle()));
|
538 |
| } |
539 |
82
| if (subsection.getLevel() != null) {
|
540 |
0
| setLocationWithinModule(context + ".getLevel()");
|
541 |
0
| s.setLevel(subsection.getLevel());
|
542 |
| } |
543 |
82
| if (subsection.getLatex() != null) {
|
544 |
82
| setLocationWithinModule(context + ".getLatex()");
|
545 |
82
| s.setLatex(create(subsection.getLatex()));
|
546 |
| } |
547 |
82
| setLocationWithinModule(context);
|
548 |
82
| return s;
|
549 |
| } |
550 |
| |
551 |
622
| private final NodeVo create(final Node node)
|
552 |
| throws IllegalModuleDataException { |
553 |
622
| if (node == null) {
|
554 |
0
| return null;
|
555 |
| } |
556 |
622
| final NodeVo n = new NodeVo();
|
557 |
622
| final String context = getCurrentContext().getLocationWithinModule();
|
558 |
622
| if (node.getName() != null) {
|
559 |
297
| setLocationWithinModule(context + ".getName()");
|
560 |
297
| n.setName(create(node.getName()));
|
561 |
| } |
562 |
622
| if (node.getId() != null) {
|
563 |
622
| setLocationWithinModule(context + ".getId()");
|
564 |
622
| n.setId(node.getId());
|
565 |
| } |
566 |
622
| if (node.getLevel() != null) {
|
567 |
433
| setLocationWithinModule(context + ".getLevel()");
|
568 |
433
| n.setLevel(node.getLevel());
|
569 |
| } |
570 |
622
| if (node.getTitle() != null) {
|
571 |
297
| setLocationWithinModule(context + ".getTitle()");
|
572 |
297
| n.setTitle(create(node.getTitle()));
|
573 |
| } |
574 |
622
| if (node.getPrecedingText() != null) {
|
575 |
601
| setLocationWithinModule(context + ".getPrecedingText()");
|
576 |
601
| n.setPrecedingText(create(node.getPrecedingText()));
|
577 |
| } |
578 |
622
| if (node.getNodeType() != null) {
|
579 |
622
| setLocationWithinModule(context + ".getNodeType()");
|
580 |
622
| if (node.getNodeType() instanceof Axiom) {
|
581 |
96
| setLocationWithinModule(context + ".getNodeType().getAxiom()");
|
582 |
96
| n.setNodeType(create((Axiom) node.getNodeType()));
|
583 |
526
| } else if (node.getNodeType() instanceof PredicateDefinition) {
|
584 |
75
| setLocationWithinModule(context + ".getNodeType().getPredicateDefinition()");
|
585 |
75
| n.setNodeType(create((PredicateDefinition) node.getNodeType()));
|
586 |
451
| } else if (node.getNodeType() instanceof FunctionDefinition) {
|
587 |
96
| setLocationWithinModule(context + ".getNodeType().getFunctionDefinition()");
|
588 |
96
| n.setNodeType(create((FunctionDefinition) node.getNodeType()));
|
589 |
355
| } else if (node.getNodeType() instanceof Proposition) {
|
590 |
328
| setLocationWithinModule(context + ".getNodeType().getProposition()");
|
591 |
328
| n.setNodeType(create((Proposition) node.getNodeType()));
|
592 |
27
| } else if (node.getNodeType() instanceof Rule) {
|
593 |
27
| setLocationWithinModule(context + ".getNodeType().getRule()");
|
594 |
27
| n.setNodeType(create((Rule) node.getNodeType()));
|
595 |
| } else { |
596 |
0
| throw new IllegalArgumentException("unexpected node type: "
|
597 |
| + node.getNodeType().getClass()); |
598 |
| } |
599 |
| } |
600 |
622
| if (node.getSucceedingText() != null) {
|
601 |
129
| setLocationWithinModule(context + ".getSucceedingText()");
|
602 |
129
| n.setSucceedingText(create(node.getSucceedingText()));
|
603 |
| } |
604 |
622
| setLocationWithinModule(context);
|
605 |
622
| getQedeqCreated().getModuleLabels().addNode(getCurrentContext(), n);
|
606 |
620
| return n;
|
607 |
| } |
608 |
| |
609 |
96
| private final AxiomVo create(final Axiom axiom) {
|
610 |
96
| if (axiom == null) {
|
611 |
0
| return null;
|
612 |
| } |
613 |
96
| final AxiomVo a = new AxiomVo();
|
614 |
96
| final String context = getCurrentContext().getLocationWithinModule();
|
615 |
96
| if (axiom.getFormula() != null) {
|
616 |
96
| setLocationWithinModule(context + ".getFormula()");
|
617 |
96
| a.setFormula(create(axiom.getFormula()));
|
618 |
| } |
619 |
96
| if (axiom.getDescription() != null) {
|
620 |
0
| setLocationWithinModule(context + ".getDescription()");
|
621 |
0
| a.setDescription(create(axiom.getDescription()));
|
622 |
| } |
623 |
96
| setLocationWithinModule(context);
|
624 |
96
| return a;
|
625 |
| } |
626 |
| |
627 |
75
| private final PredicateDefinitionVo create(final PredicateDefinition definition) {
|
628 |
75
| if (definition == null) {
|
629 |
0
| return null;
|
630 |
| } |
631 |
75
| final PredicateDefinitionVo d = new PredicateDefinitionVo();
|
632 |
75
| final String context = getCurrentContext().getLocationWithinModule();
|
633 |
75
| if (definition.getLatexPattern() != null) {
|
634 |
75
| setLocationWithinModule(context + ".getLatexPattern()");
|
635 |
75
| d.setLatexPattern(definition.getLatexPattern());
|
636 |
| } |
637 |
75
| if (definition.getName() != null) {
|
638 |
75
| setLocationWithinModule(context + ".getName()");
|
639 |
75
| d.setName(definition.getName());
|
640 |
| } |
641 |
75
| if (definition.getArgumentNumber() != null) {
|
642 |
75
| setLocationWithinModule(context + ".getArgumentNumber()");
|
643 |
75
| d.setArgumentNumber(definition.getArgumentNumber());
|
644 |
| } |
645 |
75
| if (definition.getVariableList() != null) {
|
646 |
69
| setLocationWithinModule(context + ".getVariableList()");
|
647 |
69
| d.setVariableList(create(definition.getVariableList()));
|
648 |
| } |
649 |
75
| if (definition.getFormula() != null) {
|
650 |
60
| setLocationWithinModule(context + ".getFormula()");
|
651 |
60
| d.setFormula(create(definition.getFormula()));
|
652 |
| } |
653 |
75
| if (definition.getDescription() != null) {
|
654 |
0
| setLocationWithinModule(context + ".getDescription()");
|
655 |
0
| d.setDescription(create(definition.getDescription()));
|
656 |
| } |
657 |
75
| setLocationWithinModule(context);
|
658 |
75
| return d;
|
659 |
| } |
660 |
| |
661 |
96
| private final FunctionDefinitionVo create(final FunctionDefinition definition) {
|
662 |
96
| if (definition == null) {
|
663 |
0
| return null;
|
664 |
| } |
665 |
96
| final FunctionDefinitionVo d = new FunctionDefinitionVo();
|
666 |
96
| final String context = getCurrentContext().getLocationWithinModule();
|
667 |
96
| if (definition.getLatexPattern() != null) {
|
668 |
96
| setLocationWithinModule(context + ".getLatexPattern()");
|
669 |
96
| d.setLatexPattern(definition.getLatexPattern());
|
670 |
| } |
671 |
96
| if (definition.getArgumentNumber() != null) {
|
672 |
96
| setLocationWithinModule(context + ".getArgumentNumber()");
|
673 |
96
| d.setArgumentNumber(definition.getArgumentNumber());
|
674 |
| } |
675 |
96
| if (definition.getName() != null) {
|
676 |
96
| setLocationWithinModule(context + ".getName()");
|
677 |
96
| d.setName(definition.getName());
|
678 |
| } |
679 |
96
| if (definition.getVariableList() != null) {
|
680 |
78
| setLocationWithinModule(context + ".getVariableList()");
|
681 |
78
| d.setVariableList(create(definition.getVariableList()));
|
682 |
| } |
683 |
96
| if (definition.getTerm() != null) {
|
684 |
96
| setLocationWithinModule(context + ".getTerm()");
|
685 |
96
| d.setTerm(create(definition.getTerm()));
|
686 |
| } |
687 |
96
| if (definition.getDescription() != null) {
|
688 |
0
| setLocationWithinModule(context + ".getDescription()");
|
689 |
0
| d.setDescription(create(definition.getDescription()));
|
690 |
| } |
691 |
96
| setLocationWithinModule(context);
|
692 |
96
| return d;
|
693 |
| } |
694 |
| |
695 |
328
| private final PropositionVo create(final Proposition proposition) {
|
696 |
328
| if (proposition == null) {
|
697 |
0
| return null;
|
698 |
| } |
699 |
328
| final PropositionVo p = new PropositionVo();
|
700 |
328
| final String context = getCurrentContext().getLocationWithinModule();
|
701 |
328
| if (proposition.getFormula() != null) {
|
702 |
328
| setLocationWithinModule(context + ".getFormula()");
|
703 |
328
| p.setFormula(create(proposition.getFormula()));
|
704 |
| } |
705 |
328
| if (proposition.getDescription() != null) {
|
706 |
6
| setLocationWithinModule(context + ".getDescription()");
|
707 |
6
| p.setDescription(create(proposition.getDescription()));
|
708 |
| } |
709 |
328
| if (proposition.getProofList() != null) {
|
710 |
31
| setLocationWithinModule(context + ".getProofList()");
|
711 |
31
| p.setProofList(create(proposition.getProofList()));
|
712 |
| } |
713 |
328
| setLocationWithinModule(context);
|
714 |
328
| return p;
|
715 |
| } |
716 |
| |
717 |
27
| private final RuleVo create(final Rule rule) {
|
718 |
27
| if (rule == null) {
|
719 |
0
| return null;
|
720 |
| } |
721 |
27
| final RuleVo r = new RuleVo();
|
722 |
27
| final String context = getCurrentContext().getLocationWithinModule();
|
723 |
27
| if (rule.getName() != null) {
|
724 |
27
| setLocationWithinModule(context + ".getName()");
|
725 |
27
| r.setName(rule.getName());
|
726 |
| } |
727 |
27
| if (rule.getLinkList() != null) {
|
728 |
6
| setLocationWithinModule(context + ".getLinkList()");
|
729 |
6
| r.setLinkList(create(rule.getLinkList()));
|
730 |
| } |
731 |
27
| if (rule.getDescription() != null) {
|
732 |
27
| setLocationWithinModule(context + ".getDescription()");
|
733 |
27
| r.setDescription(create(rule.getDescription()));
|
734 |
| } |
735 |
27
| if (rule.getProofList() != null) {
|
736 |
0
| setLocationWithinModule(context + ".getProofList()");
|
737 |
0
| r.setProofList(create(rule.getProofList()));
|
738 |
| } |
739 |
27
| setLocationWithinModule(context);
|
740 |
27
| return r;
|
741 |
| } |
742 |
| |
743 |
6
| private final LinkListVo create(final LinkList linkList) {
|
744 |
6
| if (linkList == null) {
|
745 |
0
| return null;
|
746 |
| } |
747 |
6
| final LinkListVo list = new LinkListVo();
|
748 |
6
| final String context = getCurrentContext().getLocationWithinModule();
|
749 |
6
| for (int i = 0; i < linkList.size(); i++) {
|
750 |
6
| setLocationWithinModule(context + ".get(" + i + ")");
|
751 |
6
| list.add(linkList.get(i));
|
752 |
| } |
753 |
6
| setLocationWithinModule(context);
|
754 |
6
| return list;
|
755 |
| } |
756 |
| |
757 |
147
| private final VariableListVo create(final VariableList variableList) {
|
758 |
147
| if (variableList == null) {
|
759 |
0
| return null;
|
760 |
| } |
761 |
147
| final VariableListVo list = new VariableListVo();
|
762 |
147
| final String context = getCurrentContext().getLocationWithinModule();
|
763 |
147
| for (int i = 0; i < variableList.size(); i++) {
|
764 |
213
| setLocationWithinModule(context + ".get(" + i + ")");
|
765 |
213
| list.add(create(variableList.get(i)));
|
766 |
| } |
767 |
147
| setLocationWithinModule(context);
|
768 |
147
| return list;
|
769 |
| } |
770 |
| |
771 |
31
| private final ProofListVo create(final ProofList proofList) {
|
772 |
31
| if (proofList == null) {
|
773 |
0
| return null;
|
774 |
| } |
775 |
31
| final ProofListVo list = new ProofListVo();
|
776 |
31
| final String context = getCurrentContext().getLocationWithinModule();
|
777 |
31
| for (int i = 0; i < proofList.size(); i++) {
|
778 |
31
| setLocationWithinModule(context + ".get(" + i + ")");
|
779 |
31
| list.add(create(proofList.get(i)));
|
780 |
| } |
781 |
31
| setLocationWithinModule(context);
|
782 |
31
| return list;
|
783 |
| } |
784 |
| |
785 |
31
| private final ProofVo create(final Proof proof) {
|
786 |
31
| if (proof == null) {
|
787 |
0
| return null;
|
788 |
| } |
789 |
31
| final ProofVo p = new ProofVo();
|
790 |
31
| final String context = getCurrentContext().getLocationWithinModule();
|
791 |
31
| setLocationWithinModule(context + ".getKind()");
|
792 |
31
| p.setKind(proof.getKind());
|
793 |
31
| setLocationWithinModule(context + ".getLevel()");
|
794 |
31
| p.setLevel(proof.getLevel());
|
795 |
31
| setLocationWithinModule(context);
|
796 |
31
| if (proof.getNonFormalProof() != null) {
|
797 |
31
| setLocationWithinModule(context + ".getNonFormalProof()");
|
798 |
31
| p.setNonFormalProof(create(proof.getNonFormalProof()));
|
799 |
| } |
800 |
31
| setLocationWithinModule(context);
|
801 |
31
| return p;
|
802 |
| } |
803 |
| |
804 |
484
| private final FormulaVo create(final Formula formula) {
|
805 |
484
| if (formula == null) {
|
806 |
0
| return null;
|
807 |
| } |
808 |
484
| final FormulaVo f = new FormulaVo();
|
809 |
484
| final String context = getCurrentContext().getLocationWithinModule();
|
810 |
484
| if (formula.getElement() != null) {
|
811 |
484
| setLocationWithinModule(context + ".getElement()");
|
812 |
484
| f.setElement(create(formula.getElement()));
|
813 |
| } |
814 |
484
| setLocationWithinModule(context);
|
815 |
484
| return f;
|
816 |
| } |
817 |
| |
818 |
96
| private final TermVo create(final Term term) {
|
819 |
96
| if (term == null) {
|
820 |
0
| return null;
|
821 |
| } |
822 |
96
| final TermVo f = new TermVo();
|
823 |
96
| final String context = getCurrentContext().getLocationWithinModule();
|
824 |
96
| if (term.getElement() != null) {
|
825 |
96
| setLocationWithinModule(context + ".getElement()");
|
826 |
96
| f.setElement(create(term.getElement()));
|
827 |
| } |
828 |
96
| setLocationWithinModule(context);
|
829 |
96
| return f;
|
830 |
| } |
831 |
| |
832 |
18076
| private final Element create(final Element element) {
|
833 |
18076
| if (element == null) {
|
834 |
0
| return null;
|
835 |
| } |
836 |
18076
| final Element e;
|
837 |
18076
| final String context = getCurrentContext().getLocationWithinModule();
|
838 |
18076
| if (element.isList()) {
|
839 |
10027
| setLocationWithinModule(context + ".getList()");
|
840 |
10027
| e = create(element.getList());
|
841 |
8049
| } else if (element.isAtom()) {
|
842 |
| |
843 |
8049
| return create(element.getAtom());
|
844 |
| } else { |
845 |
0
| throw new RuntimeException("unknown element type: " + element);
|
846 |
| } |
847 |
10027
| setLocationWithinModule(context);
|
848 |
10027
| return e;
|
849 |
| } |
850 |
| |
851 |
| |
852 |
10027
| private final DefaultElementList create(final ElementList list) {
|
853 |
10027
| if (list == null) {
|
854 |
0
| return null;
|
855 |
| } |
856 |
10027
| final DefaultElementList n = new DefaultElementList(list.getOperator(), new Element[] {});
|
857 |
10027
| final String context = getCurrentContext().getLocationWithinModule();
|
858 |
10027
| for (int i = 0; i < list.size(); i++) {
|
859 |
17283
| if (list.getElement(i).isList()) {
|
860 |
9234
| setLocationWithinModule(context + ".getElement(" + i + ")");
|
861 |
| } |
862 |
17283
| n.add(create(list.getElement(i)));
|
863 |
| } |
864 |
10027
| setLocationWithinModule(context);
|
865 |
10027
| return n;
|
866 |
| } |
867 |
| |
868 |
8049
| private final DefaultAtom create(final Atom atom) {
|
869 |
8049
| if (atom == null) {
|
870 |
0
| return null;
|
871 |
| } |
872 |
8049
| final String context = getCurrentContext().getLocationWithinModule();
|
873 |
8049
| return new DefaultAtom(atom.getString());
|
874 |
| } |
875 |
| |
876 |
2319
| private final LatexListVo create(final LatexList latexList) {
|
877 |
2319
| if (latexList == null) {
|
878 |
0
| return null;
|
879 |
| } |
880 |
2319
| final LatexListVo list = new LatexListVo();
|
881 |
2319
| final String context = getCurrentContext().getLocationWithinModule();
|
882 |
2319
| for (int i = 0; i < latexList.size(); i++) {
|
883 |
4193
| setLocationWithinModule(context + ".get(" + i + ")");
|
884 |
4193
| list.add(create(latexList.get(i)));
|
885 |
| } |
886 |
2319
| setLocationWithinModule(context);
|
887 |
2319
| return list;
|
888 |
| } |
889 |
| |
890 |
| |
891 |
| |
892 |
| |
893 |
| |
894 |
| |
895 |
| |
896 |
4221
| private final LatexVo create(final Latex latex) {
|
897 |
4221
| if (latex == null) {
|
898 |
0
| return null;
|
899 |
| } |
900 |
4221
| final LatexVo lat = new LatexVo();
|
901 |
4221
| lat.setLanguage(latex.getLanguage());
|
902 |
4221
| lat.setLatex(latex.getLatex());
|
903 |
4221
| return lat;
|
904 |
| } |
905 |
| |
906 |
| |
907 |
| |
908 |
| |
909 |
| |
910 |
| |
911 |
36212
| protected void setLocationWithinModule(final String locationWithinModule) {
|
912 |
36212
| getCurrentContext().setLocationWithinModule(locationWithinModule);
|
913 |
| } |
914 |
| |
915 |
| |
916 |
| |
917 |
| |
918 |
| |
919 |
| |
920 |
185811
| protected final ModuleContext getCurrentContext() {
|
921 |
185811
| return currentContext;
|
922 |
| } |
923 |
| |
924 |
| |
925 |
| |
926 |
| |
927 |
| |
928 |
| |
929 |
42930
| protected final Qedeq getQedeqOriginal() {
|
930 |
42930
| return original;
|
931 |
| } |
932 |
| |
933 |
| |
934 |
| |
935 |
| |
936 |
| |
937 |
| |
938 |
622
| protected final QedeqBo getQedeqCreated() {
|
939 |
622
| return qedeq;
|
940 |
| } |
941 |
| |
942 |
| } |