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