Clover Coverage Report
Coverage timestamp: Sa Aug 2 2008 13:56:27 CEST
../../../../../img/srcFileCovDistChart9.png 30% of files have more coverage
473   920   160   11,82
240   760   0,34   40
40     4  
1    
 
  QedeqVoBuilder       Line # 109 473 160 82,6% 0.82602924
 
  (34)
 
1    /* $Id: QedeqVoBuilder.java,v 1.1 2008/07/26 07:58:29 m31 Exp $
2    *
3    * This file is part of the project "Hilbert II" - http://www.qedeq.org
4    *
5    * Copyright 2000-2008, Michael Meyling <mime@qedeq.org>.
6    *
7    * "Hilbert II" is free software; you can redistribute
8    * it and/or modify it under the terms of the GNU General Public
9    * License as published by the Free Software Foundation; either
10    * version 2 of the License, or (at your option) any later version.
11    *
12    * This program is distributed in the hope that it will be useful,
13    * but WITHOUT ANY WARRANTY; without even the implied warranty of
14    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15    * GNU General Public License for more details.
16    */
17   
18    package org.qedeq.kernel.bo.service;
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.common.IllegalModuleDataException;
56    import org.qedeq.kernel.common.ModuleAddress;
57    import org.qedeq.kernel.common.ModuleContext;
58    import org.qedeq.kernel.common.ModuleDataException;
59    import org.qedeq.kernel.dto.list.DefaultAtom;
60    import org.qedeq.kernel.dto.list.DefaultElementList;
61    import org.qedeq.kernel.dto.module.AuthorListVo;
62    import org.qedeq.kernel.dto.module.AuthorVo;
63    import org.qedeq.kernel.dto.module.AxiomVo;
64    import org.qedeq.kernel.dto.module.ChapterListVo;
65    import org.qedeq.kernel.dto.module.ChapterVo;
66    import org.qedeq.kernel.dto.module.FormulaVo;
67    import org.qedeq.kernel.dto.module.FunctionDefinitionVo;
68    import org.qedeq.kernel.dto.module.HeaderVo;
69    import org.qedeq.kernel.dto.module.ImportListVo;
70    import org.qedeq.kernel.dto.module.ImportVo;
71    import org.qedeq.kernel.dto.module.LatexListVo;
72    import org.qedeq.kernel.dto.module.LatexVo;
73    import org.qedeq.kernel.dto.module.LinkListVo;
74    import org.qedeq.kernel.dto.module.LiteratureItemListVo;
75    import org.qedeq.kernel.dto.module.LiteratureItemVo;
76    import org.qedeq.kernel.dto.module.LocationListVo;
77    import org.qedeq.kernel.dto.module.LocationVo;
78    import org.qedeq.kernel.dto.module.NodeVo;
79    import org.qedeq.kernel.dto.module.PredicateDefinitionVo;
80    import org.qedeq.kernel.dto.module.ProofListVo;
81    import org.qedeq.kernel.dto.module.ProofVo;
82    import org.qedeq.kernel.dto.module.PropositionVo;
83    import org.qedeq.kernel.dto.module.QedeqVo;
84    import org.qedeq.kernel.dto.module.RuleVo;
85    import org.qedeq.kernel.dto.module.SectionListVo;
86    import org.qedeq.kernel.dto.module.SectionVo;
87    import org.qedeq.kernel.dto.module.SpecificationVo;
88    import org.qedeq.kernel.dto.module.SubsectionListVo;
89    import org.qedeq.kernel.dto.module.SubsectionVo;
90    import org.qedeq.kernel.dto.module.TermVo;
91    import org.qedeq.kernel.dto.module.UsedByListVo;
92    import org.qedeq.kernel.dto.module.VariableListVo;
93   
94   
95    /**
96    * An builder for creating {@link org.qedeq.kernel.dto.module.QedeqVo}s. This builder takes
97    * something that implements the QEDEQ interfaces (beginning with
98    * (@link org.qedeq.kernel.base.module.Qedeq} and makes copies that are out of the package
99    * <code>org.qedeq.kernel.dto.*</code>. Only elements that are not <code>null</code> are
100    * copied.
101    *
102    * <p>
103    * LATER mime 20050707: use director pattern or transfer creation methods
104    * into BOs or use visitor pattern
105    *
106    * @version $Revision: 1.1 $
107    * @author Michael Meyling
108    */
 
109    public class QedeqVoBuilder {
110   
111    /** QEDEQ module input object. */
112    private Qedeq original;
113   
114    /** Current context during creation. */
115    private ModuleContext currentContext;
116   
117    /**
118    * Constructor.
119    *
120    * @param address QEDEQ address.
121    */
 
122  120 toggle protected QedeqVoBuilder(final ModuleAddress address) {
123  120 this.currentContext = address.createModuleContext();
124    }
125   
126    /**
127    * Create {@link QedeqVo} out of an {@link Qedeq} instance.
128    * The resulting object has no references to the original {@link Qedeq} instance.
129    * <p>
130    * During the creation process the caller must assert that no modifications are made
131    * to the {@link Qedeq} instance including its referenced objects.
132    *
133    * @param address Module address.
134    * @param original Basic QEDEQ module object.
135    * @return Created copy object.
136    * @throws ModuleDataException Invalid data found.
137    */
 
138  109 toggle public static QedeqVo createQedeq(final ModuleAddress address,
139    final Qedeq original) throws ModuleDataException {
140  109 final QedeqVoBuilder creator = new QedeqVoBuilder(address);
141  109 QedeqVo vo = creator.create(original);
142  109 return vo;
143    }
144   
145    /**
146    * Create {@linkQedeqVo} out of an {@link Qedeq} instance.
147    * During that procedure some basic checking is done. E.g. the uniqueness of entries
148    * is tested. The resulting business object has no references to the original
149    * {@link Qedeq} instance.
150    *
151    * <p>
152    * During the creation process the caller must assert that no modifications are made
153    * to the {@link Qedeq} instance including its referenced objects.
154    *
155    * @param original Basic QEDEQ module object.
156    * @return Copied QEDEQ object.
157    * @throws IllegalModuleDataException Basic semantic error occurred.
158    */
 
159  120 toggle protected final QedeqVo create(final Qedeq original) throws IllegalModuleDataException {
160  120 this.original = original;
161  120 getCurrentContext().setLocationWithinModule("");
162  120 QedeqVo qedeq;
163  120 if (original == null) {
164  0 qedeq = null;
165  0 return qedeq;
166    }
167  120 qedeq = new QedeqVo();
168  120 final String context = getCurrentContext().getLocationWithinModule();
169  120 if (original.getHeader() != null) {
170  120 getCurrentContext().setLocationWithinModule(context + "getHeader()");
171  120 qedeq.setHeader(create(original.getHeader()));
172    }
173  120 if (original.getChapterList() != null) {
174  120 getCurrentContext().setLocationWithinModule(context + "getChapterList()");
175  120 qedeq.setChapterList(create(original.getChapterList()));
176    }
177  120 if (original.getLiteratureItemList() != null) {
178  16 getCurrentContext().setLocationWithinModule(context + "getLiteratureItemList()");
179  16 qedeq.setLiteratureItemList(create(original.getLiteratureItemList()));
180    }
181  120 return qedeq;
182    }
183   
184    /**
185    * Create {@link HeaderVo} out of an {@link Header} instance.
186    * During that procedure some basic checking is done. E.g. the uniqueness of entries
187    * is tested. The resulting business object has no references to the original
188    * {@link Header} instance.
189    * <p>
190    * During the creation process the caller must assert that no modifications are made
191    * to the {@link Header} instance including its referenced objects.
192    *
193    * @param header Basic header object.
194    * @return Filled header business object. Is equal to the parameter <code>header</code>.
195    * @throws IllegalModuleDataException Basic semantic error occurred.
196    */
 
197  120 toggle private final HeaderVo create(final Header header)
198    throws IllegalModuleDataException {
199  120 if (header == null) {
200  0 return null;
201    }
202  120 final HeaderVo h = new HeaderVo();
203  120 final String context = getCurrentContext().getLocationWithinModule();
204  120 if (header.getTitle() != null) {
205  120 setLocationWithinModule(context + ".getTitle()");
206  120 h.setTitle(create(header.getTitle()));
207    }
208  120 if (header.getAuthorList() != null) {
209  120 setLocationWithinModule(context + ".getAuthorList()");
210  120 h.setAuthorList(create(header.getAuthorList()));
211    }
212  120 if (header.getSummary() != null) {
213  120 setLocationWithinModule(context + ".getSummary()");
214  120 h.setSummary(create(header.getSummary()));
215    }
216  120 if (header.getEmail() != null) {
217  120 setLocationWithinModule(context + ".getEmail()");
218  120 h.setEmail(header.getEmail());
219    }
220  120 if (header.getSpecification() != null) {
221  120 setLocationWithinModule(context + ".getSpecification()");
222  120 h.setSpecification(create(header.getSpecification()));
223    }
224  120 if (header.getImportList() != null) {
225  79 setLocationWithinModule(context + ".getImportList()");
226  79 h.setImportList(create(header.getImportList()));
227    }
228  120 if (header.getUsedByList() != null) {
229  29 setLocationWithinModule(context + ".getUsedByList()");
230  29 h.setUsedByList(create(header.getUsedByList()));
231    }
232  120 setLocationWithinModule(context);
233  120 return h;
234    }
235   
236    /**
237    * Create {@link UsedByListVo} out of an {@link UsedByList} instance.
238    * During that procedure some basic checking is done. E.g. the uniqueness of entries
239    * is tested. The resulting business object has no references to the original
240    * {@link UsedByList} instance.
241    * <p>
242    * During the creation process the caller must assert that no modifications are made
243    * to the {@link UsedByList} instance including its referenced objects.
244    *
245    * @param usedByList Basic header object.
246    * @return Filled used by business object. Is equal to the parameter <code>usedByList</code>.
247    */
 
248  29 toggle private final UsedByListVo create(final UsedByList usedByList) {
249  29 if (usedByList == null) {
250  0 return null;
251    }
252  29 final String context = getCurrentContext().getLocationWithinModule();
253  29 final UsedByListVo list = new UsedByListVo();
254  58 for (int i = 0; i < usedByList.size(); i++) {
255  29 setLocationWithinModule(context + ".get(" + i + ")");
256  29 list.add(create(usedByList.get(i)));
257    }
258  29 setLocationWithinModule(context);
259  29 return list;
260    }
261   
 
262  79 toggle private final ImportListVo create(final ImportList importList) {
263  79 if (importList == null) {
264  0 return null;
265    }
266  79 final String context = getCurrentContext().getLocationWithinModule();
267  79 final ImportListVo list = new ImportListVo();
268  193 for (int i = 0; i < importList.size(); i++) {
269  114 setLocationWithinModule(context + ".get(" + i + ")");
270  114 list.add(create(importList.get(i)));
271    }
272  79 setLocationWithinModule(context);
273  79 return list;
274    }
275   
 
276  114 toggle private final ImportVo create(final Import imp) {
277  114 if (imp == null) {
278  0 return null;
279    }
280  114 final ImportVo i = new ImportVo();
281  114 final String context = getCurrentContext().getLocationWithinModule();
282  114 if (imp.getLabel() != null) {
283  114 setLocationWithinModule(context + ".getLabel()");
284  114 i.setLabel(imp.getLabel());
285    }
286  114 if (imp.getSpecification() != null) {
287  114 setLocationWithinModule(context + ".getSpecification()");
288  114 i.setSpecification(create(imp.getSpecification()));
289    }
290  114 setLocationWithinModule(context);
291  114 return i;
292    }
293   
 
294  263 toggle private final SpecificationVo create(final Specification specification) {
295  263 if (specification == null) {
296  0 return null;
297    }
298  263 final SpecificationVo s = new SpecificationVo();
299  263 final String context = getCurrentContext().getLocationWithinModule();
300  263 if (specification.getName() != null) {
301  263 setLocationWithinModule(context + ".getName()");
302  263 s.setName(specification.getName());
303    }
304  263 if (specification.getRuleVersion() != null) {
305  263 setLocationWithinModule(context + ".getRuleVersion()");
306  263 s.setRuleVersion(specification.getRuleVersion());
307    }
308  263 if (specification.getLocationList() != null) {
309  263 setLocationWithinModule(context + ".getLocationList()");
310  263 s.setLocationList(create(specification.getLocationList()));
311    }
312  263 setLocationWithinModule(context);
313  263 return s;
314    }
315   
 
316  263 toggle private final LocationListVo create(final LocationList locationList) {
317  263 if (locationList == null) {
318  0 return null;
319    }
320  263 final LocationListVo list = new LocationListVo();
321  263 final String context = getCurrentContext().getLocationWithinModule();
322  563 for (int i = 0; i < locationList.size(); i++) {
323  300 setLocationWithinModule(context + ".get(" + i + ")");
324  300 list.add(create(locationList.get(i)));
325    }
326  263 setLocationWithinModule(context);
327  263 return list;
328    }
329   
 
330  300 toggle private final LocationVo create(final Location location) {
331  300 if (location == null) {
332  0 return null;
333    }
334  300 final LocationVo loc = new LocationVo();
335  300 final String context = getCurrentContext().getLocationWithinModule();
336  300 if (location.getLocation() != null) {
337  300 setLocationWithinModule(context + ".getLocation()");
338  300 loc.setLocation(location.getLocation());
339    }
340  300 setLocationWithinModule(context);
341  300 return loc;
342    }
343   
 
344  120 toggle private final AuthorListVo create(final AuthorList authorList) {
345  120 if (authorList == null) {
346  0 return null;
347    }
348  120 final AuthorListVo list = new AuthorListVo();
349  120 final String context = getCurrentContext().getLocationWithinModule();
350  240 for (int i = 0; i < authorList.size(); i++) {
351  120 setLocationWithinModule(context + ".get(" + i + ")");
352  120 list.add(create(authorList.get(i)));
353    }
354  120 setLocationWithinModule(context);
355  120 return list;
356    }
357   
 
358  120 toggle private final AuthorVo create(final Author author) {
359  120 if (author == null) {
360  0 return null;
361    }
362  120 final AuthorVo a = new AuthorVo();
363  120 final String context = getCurrentContext().getLocationWithinModule();
364  120 if (author.getName() != null) {
365  120 setLocationWithinModule(context + ".getName()");
366  120 a.setName(create(author.getName()));
367    }
368  120 if (author.getEmail() != null) {
369  120 setLocationWithinModule(context + ".getEmail()");
370  120 a.setEmail(author.getEmail());
371    }
372  120 setLocationWithinModule(context);
373  120 return a;
374    }
375   
 
376  120 toggle private final ChapterListVo create(final ChapterList chapterList)
377    throws IllegalModuleDataException {
378  120 if (chapterList == null) {
379  0 return null;
380    }
381  120 final ChapterListVo list = new ChapterListVo();
382  120 final String context = getCurrentContext().getLocationWithinModule();
383  403 for (int i = 0; i < chapterList.size(); i++) {
384  283 setLocationWithinModule(context + ".get(" + i + ")");
385  283 list.add(create(chapterList.get(i)));
386    }
387  120 setLocationWithinModule(context);
388  120 return list;
389    }
390   
 
391  283 toggle private final ChapterVo create(final Chapter chapter)
392    throws IllegalModuleDataException {
393  283 if (chapter == null) {
394  0 return null;
395    }
396  283 final ChapterVo c = new ChapterVo();
397  283 final String context = getCurrentContext().getLocationWithinModule();
398  283 if (chapter.getTitle() != null) {
399  283 setLocationWithinModule(context + ".getTitle()");
400  283 c.setTitle(create(chapter.getTitle()));
401    }
402  283 if (chapter.getNoNumber() != null) {
403  72 setLocationWithinModule(context + ".getNoNumber()");
404  72 c.setNoNumber(chapter.getNoNumber());
405    }
406  283 if (chapter.getIntroduction() != null) {
407  228 setLocationWithinModule(context + ".getIntroduction()");
408  228 c.setIntroduction(create(chapter.getIntroduction()));
409    }
410  283 if (chapter.getSectionList() != null) {
411  149 setLocationWithinModule(context + ".getSectionList()");
412  149 c.setSectionList(create(chapter.getSectionList()));
413    }
414  283 setLocationWithinModule(context);
415  283 return c;
416    }
417   
 
418  16 toggle private LiteratureItemListVo create(final LiteratureItemList literatureItemList)
419    throws IllegalModuleDataException {
420  16 if (literatureItemList == null) {
421  0 return null;
422    }
423  16 final LiteratureItemListVo list = new LiteratureItemListVo();
424  16 final String context = getCurrentContext().getLocationWithinModule();
425  100 for (int i = 0; i < literatureItemList.size(); i++) {
426  84 setLocationWithinModule(context + ".get(" + i + ")");
427  84 list.add(create(literatureItemList.get(i)));
428    }
429  16 setLocationWithinModule(context);
430  16 return list;
431    }
432   
 
433  84 toggle private LiteratureItemVo create(final LiteratureItem item)
434    throws IllegalModuleDataException {
435  84 if (item == null) {
436  0 return null;
437    }
438  84 final LiteratureItemVo it = new LiteratureItemVo();
439  84 final String context = getCurrentContext().getLocationWithinModule();
440  84 if (item.getLabel() != null) {
441  84 setLocationWithinModule(context + ".getLabel()");
442  84 it.setLabel(item.getLabel());
443    }
444  84 if (item.getItem() != null) {
445  84 setLocationWithinModule(context + ".getItem()");
446  84 it.setItem(create(item.getItem()));
447    }
448  84 setLocationWithinModule(context);
449  84 return it;
450   
451    }
452   
 
453  149 toggle private final SectionListVo create(final SectionList sectionList)
454    throws IllegalModuleDataException {
455  149 if (sectionList == null) {
456  0 return null;
457    }
458  149 final SectionListVo list = new SectionListVo();
459  149 final String context = getCurrentContext().getLocationWithinModule();
460  518 for (int i = 0; i < sectionList.size(); i++) {
461  369 setLocationWithinModule(context + ".get(" + i + ")");
462  369 list.add(create(sectionList.get(i)));
463    }
464  149 setLocationWithinModule(context);
465  149 return list;
466    }
467   
 
468  369 toggle private final SectionVo create(final Section section)
469    throws IllegalModuleDataException {
470  369 if (section == null) {
471  0 return null;
472    }
473  369 final SectionVo s = new SectionVo();
474  369 final String context = getCurrentContext().getLocationWithinModule();
475  369 if (section.getTitle() != null) {
476  369 setLocationWithinModule(context + ".getTitle()");
477  369 s.setTitle(create(section.getTitle()));
478    }
479  369 if (section.getNoNumber() != null) {
480  0 setLocationWithinModule(context + ".getNoNumber()");
481  0 s.setNoNumber(section.getNoNumber());
482    }
483  369 if (section.getIntroduction() != null) {
484  366 setLocationWithinModule(context + ".getIntroduction()");
485  366 s.setIntroduction(create(section.getIntroduction()));
486    }
487  369 if (section.getSubsectionList() != null) {
488  220 setLocationWithinModule(context + ".getSubsectionList()");
489  220 s.setSubsectionList(create(section.getSubsectionList()));
490    }
491  369 setLocationWithinModule(context);
492  369 return s;
493    }
494   
 
495  220 toggle private final SubsectionListVo create(final SubsectionList subsectionList)
496    throws IllegalModuleDataException {
497  220 if (subsectionList == null) {
498  0 return null;
499    }
500  220 final SubsectionListVo list = new SubsectionListVo();
501  220 final String context = getCurrentContext().getLocationWithinModule();
502  1446 for (int i = 0; i < subsectionList.size(); i++) {
503  1226 setLocationWithinModule(context + ".get(" + i + ")");
504    // TODO mime 20050608: here the Subsection context is type dependently specified
505  1226 if (subsectionList.get(i) instanceof Subsection) {
506  179 list.add(create((Subsection) subsectionList.get(i)));
507  1047 } else if (subsectionList.get(i) instanceof Node) {
508  1047 list.add(create((Node) subsectionList.get(i)));
509    } else {
510  0 throw new IllegalArgumentException("unexpected subsection type: "
511    + subsectionList.get(i).getClass());
512    }
513    }
514  220 setLocationWithinModule(context);
515  220 return list;
516    }
517   
 
518  179 toggle private final SubsectionVo create(final Subsection subsection) {
519  179 if (subsection == null) {
520  0 return null;
521    }
522  179 final SubsectionVo s = new SubsectionVo();
523  179 final String context = getCurrentContext().getLocationWithinModule();
524  179 if (subsection.getTitle() != null) {
525  130 setLocationWithinModule(context + ".getTitle()");
526  130 s.setTitle(create(subsection.getTitle()));
527    }
528  179 if (subsection.getLevel() != null) {
529  0 setLocationWithinModule(context + ".getLevel()");
530  0 s.setLevel(subsection.getLevel());
531    }
532  179 if (subsection.getLatex() != null) {
533  179 setLocationWithinModule(context + ".getLatex()");
534  179 s.setLatex(create(subsection.getLatex()));
535    }
536  179 setLocationWithinModule(context);
537  179 return s;
538    }
539   
 
540  1047 toggle private final NodeVo create(final Node node)
541    throws IllegalModuleDataException {
542  1047 if (node == null) {
543  0 return null;
544    }
545  1047 final NodeVo n = new NodeVo();
546  1047 final String context = getCurrentContext().getLocationWithinModule();
547  1047 if (node.getName() != null) {
548  618 setLocationWithinModule(context + ".getName()");
549  618 n.setName(create(node.getName()));
550    }
551  1047 if (node.getId() != null) {
552  1047 setLocationWithinModule(context + ".getId()");
553  1047 n.setId(node.getId());
554    }
555  1047 if (node.getLevel() != null) {
556  555 setLocationWithinModule(context + ".getLevel()");
557  555 n.setLevel(node.getLevel());
558    }
559  1047 if (node.getTitle() != null) {
560  618 setLocationWithinModule(context + ".getTitle()");
561  618 n.setTitle(create(node.getTitle()));
562    }
563  1047 if (node.getPrecedingText() != null) {
564  884 setLocationWithinModule(context + ".getPrecedingText()");
565  884 n.setPrecedingText(create(node.getPrecedingText()));
566    }
567  1047 if (node.getNodeType() != null) {
568  1047 setLocationWithinModule(context + ".getNodeType()");
569  1047 if (node.getNodeType() instanceof Axiom) {
570  190 setLocationWithinModule(context + ".getNodeType().getAxiom()");
571  190 n.setNodeType(create((Axiom) node.getNodeType()));
572  857 } else if (node.getNodeType() instanceof PredicateDefinition) {
573  183 setLocationWithinModule(context + ".getNodeType().getPredicateDefinition()");
574  183 n.setNodeType(create((PredicateDefinition) node.getNodeType()));
575  674 } else if (node.getNodeType() instanceof FunctionDefinition) {
576  112 setLocationWithinModule(context + ".getNodeType().getFunctionDefinition()");
577  112 n.setNodeType(create((FunctionDefinition) node.getNodeType()));
578  562 } else if (node.getNodeType() instanceof Proposition) {
579  447 setLocationWithinModule(context + ".getNodeType().getProposition()");
580  447 n.setNodeType(create((Proposition) node.getNodeType()));
581  115 } else if (node.getNodeType() instanceof Rule) {
582  115 setLocationWithinModule(context + ".getNodeType().getRule()");
583  115 n.setNodeType(create((Rule) node.getNodeType()));
584    } else {
585  0 throw new IllegalArgumentException("unexpected node type: "
586    + node.getNodeType().getClass());
587    }
588    }
589  1047 if (node.getSucceedingText() != null) {
590  193 setLocationWithinModule(context + ".getSucceedingText()");
591  193 n.setSucceedingText(create(node.getSucceedingText()));
592    }
593  1047 setLocationWithinModule(context);
594  1047 return n;
595    }
596   
 
597  190 toggle private final AxiomVo create(final Axiom axiom) {
598  190 if (axiom == null) {
599  0 return null;
600    }
601  190 final AxiomVo a = new AxiomVo();
602  190 final String context = getCurrentContext().getLocationWithinModule();
603  190 if (axiom.getFormula() != null) {
604  190 setLocationWithinModule(context + ".getFormula()");
605  190 a.setFormula(create(axiom.getFormula()));
606    }
607  190 if (axiom.getDescription() != null) {
608  0 setLocationWithinModule(context + ".getDescription()");
609  0 a.setDescription(create(axiom.getDescription()));
610    }
611  190 setLocationWithinModule(context);
612  190 return a;
613    }
614   
 
615  183 toggle private final PredicateDefinitionVo create(final PredicateDefinition definition) {
616  183 if (definition == null) {
617  0 return null;
618    }
619  183 final PredicateDefinitionVo d = new PredicateDefinitionVo();
620  183 final String context = getCurrentContext().getLocationWithinModule();
621  183 if (definition.getLatexPattern() != null) {
622  183 setLocationWithinModule(context + ".getLatexPattern()");
623  183 d.setLatexPattern(definition.getLatexPattern());
624    }
625  183 if (definition.getName() != null) {
626  183 setLocationWithinModule(context + ".getName()");
627  183 d.setName(definition.getName());
628    }
629  183 if (definition.getArgumentNumber() != null) {
630  183 setLocationWithinModule(context + ".getArgumentNumber()");
631  183 d.setArgumentNumber(definition.getArgumentNumber());
632    }
633  183 if (definition.getVariableList() != null) {
634  165 setLocationWithinModule(context + ".getVariableList()");
635  165 d.setVariableList(create(definition.getVariableList()));
636    }
637  183 if (definition.getFormula() != null) {
638  141 setLocationWithinModule(context + ".getFormula()");
639  141 d.setFormula(create(definition.getFormula()));
640    }
641  183 if (definition.getDescription() != null) {
642  0 setLocationWithinModule(context + ".getDescription()");
643  0 d.setDescription(create(definition.getDescription()));
644    }
645  183 setLocationWithinModule(context);
646  183 return d;
647    }
648   
 
649  112 toggle private final FunctionDefinitionVo create(final FunctionDefinition definition) {
650  112 if (definition == null) {
651  0 return null;
652    }
653  112 final FunctionDefinitionVo d = new FunctionDefinitionVo();
654  112 final String context = getCurrentContext().getLocationWithinModule();
655  112 if (definition.getLatexPattern() != null) {
656  112 setLocationWithinModule(context + ".getLatexPattern()");
657  112 d.setLatexPattern(definition.getLatexPattern());
658    }
659  112 if (definition.getArgumentNumber() != null) {
660  112 setLocationWithinModule(context + ".getArgumentNumber()");
661  112 d.setArgumentNumber(definition.getArgumentNumber());
662    }
663  112 if (definition.getName() != null) {
664  112 setLocationWithinModule(context + ".getName()");
665  112 d.setName(definition.getName());
666    }
667  112 if (definition.getVariableList() != null) {
668  91 setLocationWithinModule(context + ".getVariableList()");
669  91 d.setVariableList(create(definition.getVariableList()));
670    }
671  112 if (definition.getTerm() != null) {
672  112 setLocationWithinModule(context + ".getTerm()");
673  112 d.setTerm(create(definition.getTerm()));
674    }
675  112 if (definition.getDescription() != null) {
676  0 setLocationWithinModule(context + ".getDescription()");
677  0 d.setDescription(create(definition.getDescription()));
678    }
679  112 setLocationWithinModule(context);
680  112 return d;
681    }
682   
 
683  447 toggle private final PropositionVo create(final Proposition proposition) {
684  447 if (proposition == null) {
685  0 return null;
686    }
687  447 final PropositionVo p = new PropositionVo();
688  447 final String context = getCurrentContext().getLocationWithinModule();
689  447 if (proposition.getFormula() != null) {
690  447 setLocationWithinModule(context + ".getFormula()");
691  447 p.setFormula(create(proposition.getFormula()));
692    }
693  447 if (proposition.getDescription() != null) {
694  7 setLocationWithinModule(context + ".getDescription()");
695  7 p.setDescription(create(proposition.getDescription()));
696    }
697  447 if (proposition.getProofList() != null) {
698  70 setLocationWithinModule(context + ".getProofList()");
699  70 p.setProofList(create(proposition.getProofList()));
700    }
701  447 setLocationWithinModule(context);
702  447 return p;
703    }
704   
 
705  115 toggle private final RuleVo create(final Rule rule) {
706  115 if (rule == null) {
707  0 return null;
708    }
709  115 final RuleVo r = new RuleVo();
710  115 final String context = getCurrentContext().getLocationWithinModule();
711  115 if (rule.getName() != null) {
712  115 setLocationWithinModule(context + ".getName()");
713  115 r.setName(rule.getName());
714    }
715  115 if (rule.getLinkList() != null) {
716  7 setLocationWithinModule(context + ".getLinkList()");
717  7 r.setLinkList(create(rule.getLinkList()));
718    }
719  115 if (rule.getDescription() != null) {
720  115 setLocationWithinModule(context + ".getDescription()");
721  115 r.setDescription(create(rule.getDescription()));
722    }
723  115 if (rule.getProofList() != null) {
724  0 setLocationWithinModule(context + ".getProofList()");
725  0 r.setProofList(create(rule.getProofList()));
726    }
727  115 setLocationWithinModule(context);
728  115 return r;
729    }
730   
 
731  7 toggle private final LinkListVo create(final LinkList linkList) {
732  7 if (linkList == null) {
733  0 return null;
734    }
735  7 final LinkListVo list = new LinkListVo();
736  7 final String context = getCurrentContext().getLocationWithinModule();
737  14 for (int i = 0; i < linkList.size(); i++) {
738  7 setLocationWithinModule(context + ".get(" + i + ")");
739  7 list.add(linkList.get(i));
740    }
741  7 setLocationWithinModule(context);
742  7 return list;
743    }
744   
 
745  256 toggle private final VariableListVo create(final VariableList variableList) {
746  256 if (variableList == null) {
747  0 return null;
748    }
749  256 final VariableListVo list = new VariableListVo();
750  256 final String context = getCurrentContext().getLocationWithinModule();
751  693 for (int i = 0; i < variableList.size(); i++) {
752  437 setLocationWithinModule(context + ".get(" + i + ")");
753  437 list.add(create(variableList.get(i)));
754    }
755  256 setLocationWithinModule(context);
756  256 return list;
757    }
758   
 
759  70 toggle private final ProofListVo create(final ProofList proofList) {
760  70 if (proofList == null) {
761  0 return null;
762    }
763  70 final ProofListVo list = new ProofListVo();
764  70 final String context = getCurrentContext().getLocationWithinModule();
765  146 for (int i = 0; i < proofList.size(); i++) {
766  76 setLocationWithinModule(context + ".get(" + i + ")");
767  76 list.add(create(proofList.get(i)));
768    }
769  70 setLocationWithinModule(context);
770  70 return list;
771    }
772   
 
773  76 toggle private final ProofVo create(final Proof proof) {
774  76 if (proof == null) {
775  0 return null;
776    }
777  76 final ProofVo p = new ProofVo();
778  76 final String context = getCurrentContext().getLocationWithinModule();
779  76 setLocationWithinModule(context + ".getKind()");
780  76 p.setKind(proof.getKind());
781  76 setLocationWithinModule(context + ".getLevel()");
782  76 p.setLevel(proof.getLevel());
783  76 setLocationWithinModule(context);
784  76 if (proof.getNonFormalProof() != null) {
785  76 setLocationWithinModule(context + ".getNonFormalProof()");
786  76 p.setNonFormalProof(create(proof.getNonFormalProof()));
787    }
788  76 setLocationWithinModule(context);
789  76 return p;
790    }
791   
 
792  778 toggle private final FormulaVo create(final Formula formula) {
793  778 if (formula == null) {
794  0 return null;
795    }
796  778 final FormulaVo f = new FormulaVo();
797  778 final String context = getCurrentContext().getLocationWithinModule();
798  778 if (formula.getElement() != null) {
799  778 setLocationWithinModule(context + ".getElement()");
800  778 f.setElement(create(formula.getElement()));
801    }
802  778 setLocationWithinModule(context);
803  778 return f;
804    }
805   
 
806  112 toggle private final TermVo create(final Term term) {
807  112 if (term == null) {
808  0 return null;
809    }
810  112 final TermVo f = new TermVo();
811  112 final String context = getCurrentContext().getLocationWithinModule();
812  112 if (term.getElement() != null) {
813  112 setLocationWithinModule(context + ".getElement()");
814  112 f.setElement(create(term.getElement()));
815    }
816  112 setLocationWithinModule(context);
817  112 return f;
818    }
819   
 
820  30060 toggle private final Element create(final Element element) {
821  30060 if (element == null) {
822  0 return null;
823    }
824  30060 final Element e;
825  30060 final String context = getCurrentContext().getLocationWithinModule();
826  30060 if (element.isList()) {
827  17142 setLocationWithinModule(context + ".getList()");
828  17142 e = create(element.getList());
829  12918 } else if (element.isAtom()) {
830    // setLocationWithinModule(context + ".getAtom()");
831  12918 return create(element.getAtom());
832    } else {
833  0 throw new RuntimeException("unknown element type: " + element);
834    }
835  17142 setLocationWithinModule(context);
836  17142 return e;
837    }
838   
839   
 
840  17142 toggle private final DefaultElementList create(final ElementList list) {
841  17142 if (list == null) {
842  0 return null;
843    }
844  17142 final DefaultElementList n = new DefaultElementList(list.getOperator(), new Element[] {});
845  17142 final String context = getCurrentContext().getLocationWithinModule();
846  45875 for (int i = 0; i < list.size(); i++) {
847  28733 if (list.getElement(i).isList()) {
848  15815 setLocationWithinModule(context + ".getElement(" + i + ")");
849    }
850  28733 n.add(create(list.getElement(i)));
851    }
852  17142 setLocationWithinModule(context);
853  17142 return n;
854    }
855   
 
856  12918 toggle private final DefaultAtom create(final Atom atom) {
857  12918 if (atom == null) {
858  0 return null;
859    }
860  12918 return new DefaultAtom(atom.getString());
861    }
862   
 
863  4390 toggle private final LatexListVo create(final LatexList latexList) {
864  4390 if (latexList == null) {
865  0 return null;
866    }
867  4390 final LatexListVo list = new LatexListVo();
868  4390 final String context = getCurrentContext().getLocationWithinModule();
869  12290 for (int i = 0; i < latexList.size(); i++) {
870  7900 setLocationWithinModule(context + ".get(" + i + ")");
871  7900 list.add(create(latexList.get(i)));
872    }
873  4390 setLocationWithinModule(context);
874  4390 return list;
875    }
876   
877    /**
878    * Creates LaTeX business object.
879    *
880    * @param latex LaTeX object.
881    * @return LaTeX business object.
882    */
 
883  8020 toggle private final LatexVo create(final Latex latex) {
884  8020 if (latex == null) {
885  0 return null;
886    }
887  8020 final LatexVo lat = new LatexVo();
888  8020 lat.setLanguage(latex.getLanguage());
889  8020 lat.setLatex(latex.getLatex());
890  8020 return lat;
891    }
892   
893    /**
894    * Set location information where are we within the original module.
895    *
896    * @param locationWithinModule Location within module.
897    */
 
898  77950 toggle protected void setLocationWithinModule(final String locationWithinModule) {
899  77950 getCurrentContext().setLocationWithinModule(locationWithinModule);
900    }
901   
902    /**
903    * Get current context within original.
904    *
905    * @return Current context.
906    */
 
907  260379 toggle protected final ModuleContext getCurrentContext() {
908  260379 return currentContext;
909    }
910   
911    /**
912    * Get original QEDEQ module.
913    *
914    * @return Original QEDEQ module.
915    */
 
916  49648 toggle protected final Qedeq getQedeqOriginal() {
917  49648 return original;
918    }
919   
920    }