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