Clover coverage report - QedeqKernelSe Coverage Report
Coverage timestamp: Sa Okt 21 2006 08:24:31 CEST
file stats: LOC: 857   Methods: 38
NCLOC: 695   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
QedeqBoFactory.java 65,6% 87,7% 100% 81%
coverage coverage
 1    /* $Id: QedeqBoFactory.java,v 1.25 2006/10/20 20:23:05 m31 Exp $
 2    *
 3    * This file is part of the project "Hilbert II" - http://www.qedeq.org
 4    *
 5    * Copyright 2000-2006, 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.elli.Element;
 21    import org.qedeq.kernel.base.module.Author;
 22    import org.qedeq.kernel.base.module.AuthorList;
 23    import org.qedeq.kernel.base.module.Axiom;
 24    import org.qedeq.kernel.base.module.Chapter;
 25    import org.qedeq.kernel.base.module.ChapterList;
 26    import org.qedeq.kernel.base.module.FormulaOrTerm;
 27    import org.qedeq.kernel.base.module.FunctionDefinition;
 28    import org.qedeq.kernel.base.module.Header;
 29    import org.qedeq.kernel.base.module.Import;
 30    import org.qedeq.kernel.base.module.ImportList;
 31    import org.qedeq.kernel.base.module.Latex;
 32    import org.qedeq.kernel.base.module.LatexList;
 33    import org.qedeq.kernel.base.module.LinkList;
 34    import org.qedeq.kernel.base.module.LiteratureItem;
 35    import org.qedeq.kernel.base.module.LiteratureItemList;
 36    import org.qedeq.kernel.base.module.Location;
 37    import org.qedeq.kernel.base.module.LocationList;
 38    import org.qedeq.kernel.base.module.Node;
 39    import org.qedeq.kernel.base.module.PredicateDefinition;
 40    import org.qedeq.kernel.base.module.Proof;
 41    import org.qedeq.kernel.base.module.ProofList;
 42    import org.qedeq.kernel.base.module.Proposition;
 43    import org.qedeq.kernel.base.module.Qedeq;
 44    import org.qedeq.kernel.base.module.Rule;
 45    import org.qedeq.kernel.base.module.Section;
 46    import org.qedeq.kernel.base.module.SectionList;
 47    import org.qedeq.kernel.base.module.Specification;
 48    import org.qedeq.kernel.base.module.Subsection;
 49    import org.qedeq.kernel.base.module.SubsectionList;
 50    import org.qedeq.kernel.base.module.UsedByList;
 51    import org.qedeq.kernel.base.module.VariableList;
 52    import org.qedeq.kernel.bo.module.AuthorBo;
 53    import org.qedeq.kernel.bo.module.AuthorListBo;
 54    import org.qedeq.kernel.bo.module.AxiomBo;
 55    import org.qedeq.kernel.bo.module.ChapterBo;
 56    import org.qedeq.kernel.bo.module.ChapterListBo;
 57    import org.qedeq.kernel.bo.module.DuplicateLanguageEntryException;
 58    import org.qedeq.kernel.bo.module.FormulaOrTermBo;
 59    import org.qedeq.kernel.bo.module.FunctionDefinitionBo;
 60    import org.qedeq.kernel.bo.module.HeaderBo;
 61    import org.qedeq.kernel.bo.module.ImportBo;
 62    import org.qedeq.kernel.bo.module.ImportListBo;
 63    import org.qedeq.kernel.bo.module.LatexBo;
 64    import org.qedeq.kernel.bo.module.LatexListBo;
 65    import org.qedeq.kernel.bo.module.LinkListBo;
 66    import org.qedeq.kernel.bo.module.LiteratureItemBo;
 67    import org.qedeq.kernel.bo.module.LiteratureItemListBo;
 68    import org.qedeq.kernel.bo.module.LocationBo;
 69    import org.qedeq.kernel.bo.module.LocationListBo;
 70    import org.qedeq.kernel.bo.module.NodeBo;
 71    import org.qedeq.kernel.bo.module.NullPointerListEntryException;
 72    import org.qedeq.kernel.bo.module.PredicateDefinitionBo;
 73    import org.qedeq.kernel.bo.module.ProofBo;
 74    import org.qedeq.kernel.bo.module.ProofListBo;
 75    import org.qedeq.kernel.bo.module.PropositionBo;
 76    import org.qedeq.kernel.bo.module.QedeqBo;
 77    import org.qedeq.kernel.bo.module.RuleBo;
 78    import org.qedeq.kernel.bo.module.SectionBo;
 79    import org.qedeq.kernel.bo.module.SectionListBo;
 80    import org.qedeq.kernel.bo.module.SpecificationBo;
 81    import org.qedeq.kernel.bo.module.SubsectionBo;
 82    import org.qedeq.kernel.bo.module.SubsectionListBo;
 83    import org.qedeq.kernel.bo.module.UsedByListBo;
 84    import org.qedeq.kernel.bo.module.VariableListBo;
 85   
 86   
 87    /**
 88    * A factory for creating {@link org.qedeq.kernel.bo.module.QedeqBo}s.
 89    *
 90    * LATER mime 20050707: use director pattern or transfer creation methods
 91    * into BOs or use visitor pattern
 92    * @version $Revision: 1.25 $
 93    * @author Michael Meyling
 94    */
 95    public class QedeqBoFactory {
 96   
 97    /** Qedeq module business object. */
 98    private QedeqBo qedeq;
 99   
 100    /** Qedeq module input object. */
 101    private Qedeq original;
 102   
 103    /** Current context during creation. */
 104    private ModuleContext currentContext;
 105   
 106    /**
 107    * Constructor.
 108    *
 109    * @param globalContext Module location information.
 110    */
 111  14 protected QedeqBoFactory(final String globalContext) {
 112  14 currentContext = new ModuleContext(globalContext);
 113    }
 114   
 115    /**
 116    * Create {@link QedeqBo} out of an {@link Qedeq} instance.
 117    * During that procedure some basic checking is done. E.g. the uniqueness of entries
 118    * is tested. The resulting business object has no references to the original
 119    * {@link Qedeq} instance.
 120    * <p>
 121    * During the creation process the caller must assert that no modifications are made
 122    * to the {@link Qedeq} instance including its referenced objects.
 123    *
 124    * @param globalContext Module location information.
 125    * @param original Basic qedeq module object.
 126    * @return Filled qedeq business object. Is equal to the parameter <code>qedeq</code>.
 127    * @throws IllegalModuleDataException Basic semantic error occurred.
 128    */
 129  9 public static QedeqBo createQedeq(final String globalContext, final Qedeq original)
 130    throws IllegalModuleDataException {
 131  9 final QedeqBoFactory creator = new QedeqBoFactory(globalContext);
 132  9 return creator.create(original);
 133    }
 134   
 135    /**
 136    * Create {@link QedeqBo} out of an {@link Qedeq} instance.
 137    * During that procedure some basic checking is done. E.g. the uniqueness of entries
 138    * is tested. The resulting business object has no references to the original
 139    * {@link Qedeq} instance.
 140    * <p>
 141    * During the creation process the caller must assert that no modifications are made
 142    * to the {@link Qedeq} instance including its referenced objects.
 143    *
 144    * @param original Basic qedeq module object.
 145    * @return Filled header business object. Is equal to the parameter <code>header</code>.
 146    * @throws IllegalModuleDataException Basic semantic error occurred.
 147    */
 148  14 protected final QedeqBo create(final Qedeq original) throws IllegalModuleDataException {
 149  14 this.original = original;
 150  14 getCurrentContext().setLocationWithinModule("");
 151  14 if (original == null) {
 152  0 qedeq = null;
 153  0 return qedeq;
 154    }
 155  14 qedeq = new QedeqBo();
 156  14 final String context = getCurrentContext().getLocationWithinModule();
 157  14 if (original.getHeader() != null) {
 158  14 getCurrentContext().setLocationWithinModule(context + "getHeader()");
 159  14 qedeq.setHeader(create(original.getHeader()));
 160    }
 161  14 if (original.getChapterList() != null) {
 162  14 getCurrentContext().setLocationWithinModule(context + "getChapterList()");
 163  14 qedeq.setChapterList(create(original.getChapterList()));
 164    }
 165  12 if (original.getLiteratureItemList() != null) {
 166  6 getCurrentContext().setLocationWithinModule(context + "getLiteratureItemList()");
 167  6 qedeq.setLiteratureItemList(create(original.getLiteratureItemList()));
 168    }
 169  12 return qedeq;
 170    }
 171   
 172    /**
 173    * Create {@link HeaderBo} out of an {@link Header} instance.
 174    * During that procedure some basic checking is done. E.g. the uniqueness of entries
 175    * is tested. The resulting business object has no references to the original
 176    * {@link Header} instance.
 177    * <p>
 178    * During the creation process the caller must assert that no modifications are made
 179    * to the {@link Header} instance including its referenced objects.
 180    *
 181    * @param header Basic header object.
 182    * @return Filled header business object. Is equal to the parameter <code>header</code>.
 183    * @throws IllegalModuleDataException Basic semantic error occurred.
 184    */
 185  14 private final HeaderBo create(final Header header)
 186    throws IllegalModuleDataException {
 187  14 if (header == null) {
 188  0 return null;
 189    }
 190  14 final HeaderBo h = new HeaderBo();
 191  14 final String context = getCurrentContext().getLocationWithinModule();
 192  14 if (header.getTitle() != null) {
 193  14 setLocationWithinModule(context + ".getTitle()");
 194  14 h.setTitle(create(header.getTitle()));
 195    }
 196  14 if (header.getAuthorList() != null) {
 197  14 setLocationWithinModule(context + ".getAuthorList()");
 198  14 h.setAuthorList(create(header.getAuthorList()));
 199    }
 200  14 if (header.getSummary() != null) {
 201  14 setLocationWithinModule(context + ".getSummary()");
 202  14 h.setSummary(create(header.getSummary()));
 203    }
 204  14 if (header.getEmail() != null) {
 205  0 setLocationWithinModule(context + ".getEmail()");
 206  0 h.setEmail(header.getEmail());
 207    }
 208  14 if (header.getSpecification() != null) {
 209  14 setLocationWithinModule(context + ".getSpecification()");
 210  14 h.setSpecification(create(header.getSpecification()));
 211    }
 212  14 if (header.getImportList() != null) {
 213  8 setLocationWithinModule(context + ".getImportList()");
 214  8 h.setImportList(create(header.getImportList()));
 215    }
 216  14 if (header.getUsedByList() != null) {
 217  5 setLocationWithinModule(context + ".getUsedByList()");
 218  5 h.setUsedByList(create(header.getUsedByList()));
 219    }
 220  14 return h;
 221    }
 222   
 223    /**
 224    * Create {@link UsedByListBo} out of an {@link UsedByList} instance.
 225    * During that procedure some basic checking is done. E.g. the uniqueness of entries
 226    * is tested. The resulting business object has no references to the original
 227    * {@link UsedByList} instance.
 228    * <p>
 229    * During the creation process the caller must assert that no modifications are made
 230    * to the {@link UsedByList} instance including its referenced objects.
 231    *
 232    * @param usedByList Basic header object.
 233    * @return Filled used by business object. Is equal to the parameter <code>usedByList</code>.
 234    */
 235  5 private final UsedByListBo create(final UsedByList usedByList) {
 236  5 if (usedByList == null) {
 237  0 return null;
 238    }
 239  5 final String context = getCurrentContext().getLocationWithinModule();
 240  5 final UsedByListBo list = new UsedByListBo();
 241  5 for (int i = 0; i < usedByList.size(); i++) {
 242  5 setLocationWithinModule(context + ".get(" + i + ")");
 243  5 list.add(create(usedByList.get(i)));
 244    }
 245  5 return list;
 246    }
 247   
 248  8 private final ImportListBo create(final ImportList importList) {
 249  8 if (importList == null) {
 250  0 return null;
 251    }
 252  8 final String context = getCurrentContext().getLocationWithinModule();
 253  8 final ImportListBo list = new ImportListBo();
 254  8 for (int i = 0; i < importList.size(); i++) {
 255  13 setLocationWithinModule(context + ".get(" + i + ")");
 256  13 list.add(create(importList.get(i)));
 257    }
 258  8 return list;
 259    }
 260   
 261  13 private final ImportBo create(final Import imp) {
 262  13 if (imp == null) {
 263  0 return null;
 264    }
 265  13 final ImportBo i = new ImportBo();
 266  13 final String context = getCurrentContext().getLocationWithinModule();
 267  13 if (imp.getLabel() != null) {
 268  13 setLocationWithinModule(context + ".getLabel()");
 269  13 i.setLabel(imp.getLabel());
 270    }
 271  13 if (imp.getSpecification() != null) {
 272  13 setLocationWithinModule(context + ".getSpecification()");
 273  13 i.setSpecification(create(imp.getSpecification()));
 274    }
 275  13 return i;
 276    }
 277   
 278  32 private final SpecificationBo create(final Specification specification) {
 279  32 if (specification == null) {
 280  0 return null;
 281    }
 282  32 final SpecificationBo s = new SpecificationBo();
 283  32 final String context = getCurrentContext().getLocationWithinModule();
 284  32 if (specification.getName() != null) {
 285  19 setLocationWithinModule(context + ".getName()");
 286  19 s.setName(specification.getName());
 287    }
 288  32 if (specification.getRuleVersion() != null) {
 289  19 setLocationWithinModule(context + ".getRuleVersion()");
 290  19 s.setRuleVersion(specification.getRuleVersion());
 291    }
 292  32 if (specification.getLocationList() != null) {
 293  32 setLocationWithinModule(context + ".getLocationList()");
 294  32 s.setLocationList(create(specification.getLocationList()));
 295    }
 296  32 return s;
 297    }
 298   
 299  32 private final LocationListBo create(final LocationList locationList) {
 300  32 if (locationList == null) {
 301  0 return null;
 302    }
 303  32 final LocationListBo list = new LocationListBo();
 304  32 final String context = getCurrentContext().getLocationWithinModule();
 305  32 for (int i = 0; i < locationList.size(); i++) {
 306  32 setLocationWithinModule(context + ".get(" + i + ")");
 307  32 list.add(create(locationList.get(i)));
 308    }
 309  32 return list;
 310    }
 311   
 312  32 private final LocationBo create(final Location location) {
 313  32 if (location == null) {
 314  0 return null;
 315    }
 316  32 final LocationBo loc = new LocationBo();
 317  32 final String context = getCurrentContext().getLocationWithinModule();
 318  32 if (location.getLocation() != null) {
 319  32 setLocationWithinModule(context + ".getLocation()");
 320  32 loc.setLocation(location.getLocation());
 321    }
 322  32 return loc;
 323    }
 324   
 325  14 private final AuthorListBo create(final AuthorList authorList) {
 326  14 if (authorList == null) {
 327  0 return null;
 328    }
 329  14 final AuthorListBo list = new AuthorListBo();
 330  14 final String context = getCurrentContext().getLocationWithinModule();
 331  14 for (int i = 0; i < authorList.size(); i++) {
 332  14 setLocationWithinModule(context + ".get(" + i + ")");
 333  14 list.add(create(authorList.get(i)));
 334    }
 335  14 return list;
 336    }
 337   
 338  14 private final AuthorBo create(final Author author) {
 339  14 if (author == null) {
 340  0 return null;
 341    }
 342  14 final AuthorBo a = new AuthorBo();
 343  14 final String context = getCurrentContext().getLocationWithinModule();
 344  14 if (author.getName() != null) {
 345  14 setLocationWithinModule(context + ".getName()");
 346  14 a.setName(create(author.getName()));
 347    }
 348  14 if (author.getEmail() != null) {
 349  14 setLocationWithinModule(context + ".getEmail()");
 350  14 a.setEmail(author.getEmail());
 351    }
 352  14 return a;
 353    }
 354   
 355  14 private final ChapterListBo create(final ChapterList chapterList)
 356    throws IllegalModuleDataException {
 357  14 if (chapterList == null) {
 358  0 return null;
 359    }
 360  14 final ChapterListBo list = new ChapterListBo();
 361  14 final String context = getCurrentContext().getLocationWithinModule();
 362  14 for (int i = 0; i < chapterList.size(); i++) {
 363  71 setLocationWithinModule(context + ".get(" + i + ")");
 364  71 list.add(create(chapterList.get(i)));
 365    }
 366  12 return list;
 367    }
 368   
 369  71 private final ChapterBo create(final Chapter chapter)
 370    throws IllegalModuleDataException {
 371  71 if (chapter == null) {
 372  0 return null;
 373    }
 374  71 final ChapterBo c = new ChapterBo();
 375  71 final String context = getCurrentContext().getLocationWithinModule();
 376  71 if (chapter.getTitle() != null) {
 377  71 setLocationWithinModule(context + ".getTitle()");
 378  71 c.setTitle(create(chapter.getTitle()));
 379    }
 380  71 if (chapter.getNoNumber() != null) {
 381  23 setLocationWithinModule(context + ".getNoNumber()");
 382  23 c.setNoNumber(chapter.getNoNumber());
 383    }
 384  71 if (chapter.getIntroduction() != null) {
 385  71 setLocationWithinModule(context + ".getIntroduction()");
 386  71 c.setIntroduction(create(chapter.getIntroduction()));
 387    }
 388  71 if (chapter.getSectionList() != null) {
 389  41 setLocationWithinModule(context + ".getSectionList()");
 390  41 c.setSectionList(create(chapter.getSectionList()));
 391    }
 392  69 return c;
 393    }
 394   
 395  6 private LiteratureItemList create(final LiteratureItemList literatureItemList)
 396    throws IllegalModuleDataException {
 397  6 if (literatureItemList == null) {
 398  0 return null;
 399    }
 400  6 final LiteratureItemListBo list = new LiteratureItemListBo();
 401  6 final String context = getCurrentContext().getLocationWithinModule();
 402  6 for (int i = 0; i < literatureItemList.size(); i++) {
 403  27 setLocationWithinModule(context + ".get(" + i + ")");
 404  27 list.add(create(literatureItemList.get(i)));
 405    }
 406  6 return list;
 407    }
 408   
 409  27 private LiteratureItem create(final LiteratureItem item)
 410    throws IllegalModuleDataException {
 411  27 if (item == null) {
 412  0 return null;
 413    }
 414  27 final LiteratureItemBo it = new LiteratureItemBo();
 415  27 final String context = getCurrentContext().getLocationWithinModule();
 416  27 if (item.getLabel() != null) {
 417  27 setLocationWithinModule(context + ".getLabel()");
 418  27 it.setLabel(item.getLabel());
 419    }
 420  27 if (item.getItem() != null) {
 421  27 setLocationWithinModule(context + ".getItem()");
 422  27 it.setItem(create(item.getItem()));
 423    }
 424  27 return it;
 425   
 426    }
 427   
 428  41 private final SectionListBo create(final SectionList sectionList)
 429    throws IllegalModuleDataException {
 430  41 if (sectionList == null) {
 431  0 return null;
 432    }
 433  41 final SectionListBo list = new SectionListBo();
 434  41 final String context = getCurrentContext().getLocationWithinModule();
 435  41 for (int i = 0; i < sectionList.size(); i++) {
 436  119 setLocationWithinModule(context + ".get(" + i + ")");
 437  119 list.add(create(sectionList.get(i)));
 438    }
 439  39 return list;
 440    }
 441   
 442  119 private final SectionBo create(final Section section)
 443    throws IllegalModuleDataException {
 444  119 if (section == null) {
 445  0 return null;
 446    }
 447  119 final SectionBo s = new SectionBo();
 448  119 final String context = getCurrentContext().getLocationWithinModule();
 449  119 if (section.getTitle() != null) {
 450  119 setLocationWithinModule(context + ".getTitle()");
 451  119 s.setTitle(create(section.getTitle()));
 452    }
 453  119 if (section.getNoNumber() != null) {
 454  0 setLocationWithinModule(context + ".getNoNumber()");
 455  0 s.setNoNumber(section.getNoNumber());
 456    }
 457  119 if (section.getIntroduction() != null) {
 458  119 setLocationWithinModule(context + ".getIntroduction()");
 459  119 s.setIntroduction(create(section.getIntroduction()));
 460    }
 461  119 if (section.getSubsectionList() != null) {
 462  56 setLocationWithinModule(context + ".getSubsectionList()");
 463  56 s.setSubsectionList(create(section.getSubsectionList()));
 464    }
 465  117 return s;
 466    }
 467   
 468  56 private final SubsectionListBo create(final SubsectionList subsectionList)
 469    throws IllegalModuleDataException {
 470  56 if (subsectionList == null) {
 471  0 return null;
 472    }
 473  56 final SubsectionListBo list = new SubsectionListBo();
 474  56 final String context = getCurrentContext().getLocationWithinModule();
 475  56 for (int i = 0; i < subsectionList.size(); i++) {
 476  345 setLocationWithinModule(context + ".get(" + i + ")");
 477    // TODO mime 20050608: here the Subsection context is type dependently specified
 478  345 if (subsectionList.get(i) instanceof Subsection) {
 479  39 list.add(create((Subsection) subsectionList.get(i)));
 480  306 } else if (subsectionList.get(i) instanceof Node) {
 481  306 list.add(create((Node) subsectionList.get(i)));
 482    } else {
 483  0 throw new IllegalArgumentException("unexpected subsection type: "
 484    + subsectionList.get(i).getClass());
 485    }
 486    }
 487  54 return list;
 488    }
 489   
 490  39 private final SubsectionBo create(final Subsection subsection)
 491    throws IllegalModuleDataException {
 492  39 if (subsection == null) {
 493  0 return null;
 494    }
 495  39 final SubsectionBo s = new SubsectionBo();
 496  39 final String context = getCurrentContext().getLocationWithinModule();
 497  39 if (subsection.getTitle() != null) {
 498  30 setLocationWithinModule(context + ".getTitle()");
 499  30 s.setTitle(create(subsection.getTitle()));
 500    }
 501  39 if (subsection.getLevel() != null) {
 502  0 setLocationWithinModule(context + ".getLevel()");
 503  0 s.setLevel(subsection.getLevel());
 504    }
 505  39 if (subsection.getLatex() != null) {
 506  39 setLocationWithinModule(context + ".getLatex()");
 507  39 s.setLatex(create(subsection.getLatex()));
 508    }
 509  39 return s;
 510    }
 511   
 512  306 private final NodeBo create(final Node node)
 513    throws IllegalModuleDataException {
 514  306 if (node == null) {
 515  0 return null;
 516    }
 517  306 final NodeBo n = new NodeBo();
 518  306 final String context = getCurrentContext().getLocationWithinModule();
 519  306 if (node.getName() != null) {
 520  144 setLocationWithinModule(context + ".getName()");
 521  144 n.setName(create(node.getName()));
 522    }
 523  306 if (node.getId() != null) {
 524  306 setLocationWithinModule(context + ".getId()");
 525  306 n.setId(node.getId());
 526    }
 527  306 if (node.getLevel() != null) {
 528  216 setLocationWithinModule(context + ".getLevel()");
 529  216 n.setLevel(node.getLevel());
 530    }
 531  306 if (node.getTitle() != null) {
 532  144 setLocationWithinModule(context + ".getTitle()");
 533  144 n.setTitle(create(node.getTitle()));
 534    }
 535  306 if (node.getPrecedingText() != null) {
 536  306 setLocationWithinModule(context + ".getPrecedingText()");
 537  306 n.setPrecedingText(create(node.getPrecedingText()));
 538    }
 539  306 if (node.getNodeType() != null) {
 540  306 setLocationWithinModule(context + ".getNodeType()");
 541  306 if (node.getNodeType() instanceof Axiom) {
 542  50 setLocationWithinModule(context + ".getNodeType().getAxiom()");
 543  50 n.setNodeType(create((Axiom) node.getNodeType()));
 544  256 } else if (node.getNodeType() instanceof PredicateDefinition) {
 545  40 setLocationWithinModule(context + ".getNodeType().getPredicateDefinition()");
 546  40 n.setNodeType(create((PredicateDefinition) node.getNodeType()));
 547  216 } else if (node.getNodeType() instanceof FunctionDefinition) {
 548  48 setLocationWithinModule(context + ".getNodeType().getFunctionDefinition()");
 549  48 n.setNodeType(create((FunctionDefinition) node.getNodeType()));
 550  168 } else if (node.getNodeType() instanceof Proposition) {
 551  162 setLocationWithinModule(context + ".getNodeType().getProposition()");
 552  162 n.setNodeType(create((Proposition) node.getNodeType()));
 553  6 } else if (node.getNodeType() instanceof Rule) {
 554  6 setLocationWithinModule(context + ".getNodeType().getRule()");
 555  6 n.setNodeType(create((Rule) node.getNodeType()));
 556    } else {
 557  0 throw new IllegalArgumentException("unexpected node type: "
 558    + node.getNodeType().getClass());
 559    }
 560    }
 561  306 if (node.getSucceedingText() != null) {
 562  66 setLocationWithinModule(context + ".getSucceedingText()");
 563  66 n.setSucceedingText(create(node.getSucceedingText()));
 564    }
 565  306 setLocationWithinModule(context);
 566  306 getQedeqCreated().getModuleLabels().addNode(getCurrentContext(), n);
 567  304 return n;
 568    }
 569   
 570  50 private final AxiomBo create(final Axiom axiom) throws IllegalModuleDataException {
 571  50 if (axiom == null) {
 572  0 return null;
 573    }
 574  50 final AxiomBo a = new AxiomBo();
 575  50 final String context = getCurrentContext().getLocationWithinModule();
 576  50 if (axiom.getFormula() != null) {
 577  50 setLocationWithinModule(context + ".getFormula()");
 578  50 a.setFormula(create(axiom.getFormula()));
 579    }
 580  50 if (axiom.getDescription() != null) {
 581  0 setLocationWithinModule(context + ".getDescription()");
 582  0 a.setDescription(create(axiom.getDescription()));
 583    }
 584  50 return a;
 585    }
 586   
 587  40 private final PredicateDefinitionBo create(final PredicateDefinition definition)
 588    throws IllegalModuleDataException {
 589  40 if (definition == null) {
 590  0 return null;
 591    }
 592  40 final PredicateDefinitionBo d = new PredicateDefinitionBo();
 593  40 final String context = getCurrentContext().getLocationWithinModule();
 594  40 if (definition.getLatexPattern() != null) {
 595  40 setLocationWithinModule(context + ".getLatexPattern()");
 596  40 d.setLatexPattern(definition.getLatexPattern());
 597    }
 598  40 if (definition.getName() != null) {
 599  40 setLocationWithinModule(context + ".getName()");
 600  40 d.setName(definition.getName());
 601    }
 602  40 if (definition.getArgumentNumber() != null) {
 603  40 setLocationWithinModule(context + ".getArgumentNumber()");
 604  40 d.setArgumentNumber(definition.getArgumentNumber());
 605    }
 606  40 if (definition.getVariableList() != null) {
 607  40 setLocationWithinModule(context + ".getVariableList()");
 608  40 d.setVariableList(create(definition.getVariableList()));
 609    }
 610  40 if (definition.getFormula() != null) {
 611  32 setLocationWithinModule(context + ".getFormula()");
 612  32 d.setFormula(create(definition.getFormula()));
 613    }
 614  40 if (definition.getDescription() != null) {
 615  0 setLocationWithinModule(context + ".getDescription()");
 616  0 d.setDescription(create(definition.getDescription()));
 617    }
 618  40 return d;
 619    }
 620   
 621  48 private final FunctionDefinitionBo create(final FunctionDefinition definition)
 622    throws IllegalModuleDataException {
 623  48 if (definition == null) {
 624  0 return null;
 625    }
 626  48 final FunctionDefinitionBo d = new FunctionDefinitionBo();
 627  48 final String context = getCurrentContext().getLocationWithinModule();
 628  48 if (definition.getLatexPattern() != null) {
 629  48 setLocationWithinModule(context + ".getLatexPattern()");
 630  48 d.setLatexPattern(definition.getLatexPattern());
 631    }
 632  48 if (definition.getArgumentNumber() != null) {
 633  48 setLocationWithinModule(context + ".getArgumentNumber()");
 634  48 d.setArgumentNumber(definition.getArgumentNumber());
 635    }
 636  48 if (definition.getName() != null) {
 637  48 setLocationWithinModule(context + ".getName()");
 638  48 d.setName(definition.getName());
 639    }
 640  48 if (definition.getVariableList() != null) {
 641  39 setLocationWithinModule(context + ".getVariableList()");
 642  39 d.setVariableList(create(definition.getVariableList()));
 643    }
 644  48 if (definition.getTerm() != null) {
 645  48 setLocationWithinModule(context + ".getTerm()");
 646  48 d.setTerm(create(definition.getTerm()));
 647    }
 648  48 if (definition.getDescription() != null) {
 649  0 setLocationWithinModule(context + ".getDescription()");
 650  0 d.setDescription(create(definition.getDescription()));
 651    }
 652  48 return d;
 653    }
 654   
 655  162 private final PropositionBo create(final Proposition proposition)
 656    throws IllegalModuleDataException {
 657  162 if (proposition == null) {
 658  0 return null;
 659    }
 660  162 final PropositionBo p = new PropositionBo();
 661  162 final String context = getCurrentContext().getLocationWithinModule();
 662  162 if (proposition.getFormula() != null) {
 663  162 setLocationWithinModule(context + ".getFormula()");
 664  162 p.setFormula(create(proposition.getFormula()));
 665    }
 666  162 if (proposition.getDescription() != null) {
 667  3 setLocationWithinModule(context + ".getDescription()");
 668  3 p.setDescription(create(proposition.getDescription()));
 669    }
 670  162 if (proposition.getProofList() != null) {
 671  15 setLocationWithinModule(context + ".getProofList()");
 672  15 p.setProofList(create(proposition.getProofList()));
 673    }
 674  162 return p;
 675    }
 676   
 677  6 private final RuleBo create(final Rule rule)
 678    throws IllegalModuleDataException {
 679  6 if (rule == null) {
 680  0 return null;
 681    }
 682  6 final RuleBo r = new RuleBo();
 683  6 final String context = getCurrentContext().getLocationWithinModule();
 684  6 if (rule.getName() != null) {
 685  6 setLocationWithinModule(context + ".getName()");
 686  6 r.setName(rule.getName());
 687    }
 688  6 if (rule.getLinkList() != null) {
 689  3 setLocationWithinModule(context + ".getLinkList()");
 690  3 r.setLinkList(create(rule.getLinkList()));
 691    }
 692  6 if (rule.getDescription() != null) {
 693  6 setLocationWithinModule(context + ".getDescription()");
 694  6 r.setDescription(create(rule.getDescription()));
 695    }
 696  6 if (rule.getProofList() != null) {
 697  0 setLocationWithinModule(context + ".getProofList()");
 698  0 r.setProofList(create(rule.getProofList()));
 699    }
 700  6 return r;
 701    }
 702   
 703  3 private final LinkListBo create(final LinkList linkList) {
 704  3 if (linkList == null) {
 705  0 return null;
 706    }
 707  3 final LinkListBo list = new LinkListBo();
 708  3 final String context = getCurrentContext().getLocationWithinModule();
 709  3 for (int i = 0; i < linkList.size(); i++) {
 710  3 setLocationWithinModule(context + ".get(" + i + ")");
 711  3 list.add(linkList.get(i));
 712    }
 713  3 return list;
 714    }
 715   
 716  79 private final VariableListBo create(final VariableList variableList) {
 717  79 if (variableList == null) {
 718  0 return null;
 719    }
 720  79 final VariableListBo list = new VariableListBo();
 721  79 final String context = getCurrentContext().getLocationWithinModule();
 722  79 for (int i = 0; i < variableList.size(); i++) {
 723  117 setLocationWithinModule(context + ".get(" + i + ")");
 724  117 list.add(create(variableList.get(i)));
 725    }
 726  79 return list;
 727    }
 728   
 729  15 private final ProofListBo create(final ProofList proofList)
 730    throws IllegalModuleDataException {
 731  15 if (proofList == null) {
 732  0 return null;
 733    }
 734  15 final ProofListBo list = new ProofListBo();
 735  15 final String context = getCurrentContext().getLocationWithinModule();
 736  15 for (int i = 0; i < proofList.size(); i++) {
 737  15 setLocationWithinModule(context + ".get(" + i + ")");
 738  15 list.add(create(proofList.get(i)));
 739    }
 740  15 return list;
 741    }
 742   
 743  15 private final ProofBo create(final Proof proof)
 744    throws IllegalModuleDataException {
 745  15 if (proof == null) {
 746  0 return null;
 747    }
 748  15 final ProofBo p = new ProofBo();
 749  15 final String context = getCurrentContext().getLocationWithinModule();
 750  15 if (proof.getNonFormalProof() != null) {
 751  15 setLocationWithinModule(context + ".getNonFormalProof()");
 752  15 p.setNonFormalProof(create(proof.getNonFormalProof()));
 753    }
 754  15 return p;
 755    }
 756   
 757  292 private final FormulaOrTermBo create(final FormulaOrTerm formulaOrTerm) {
 758  292 if (formulaOrTerm == null) {
 759  0 return null;
 760    }
 761  292 final FormulaOrTermBo f = new FormulaOrTermBo();
 762  292 final String context = getCurrentContext().getLocationWithinModule();
 763  292 if (formulaOrTerm.getElement() != null) {
 764  292 setLocationWithinModule(context + ".getElement()");
 765  292 f.setElement(create(formulaOrTerm.getElement()));
 766    }
 767  292 return f;
 768    }
 769   
 770  409 private final Element create(final Element element) {
 771  409 if (element == null) {
 772  0 return null;
 773    }
 774  409 final String context = getCurrentContext().getLocationWithinModule();
 775    // TODO mime 20050325: create element BO here? Answer: no BO but copy of
 776    // element should be made
 777  409 return element.copy();
 778    }
 779   
 780   
 781  1188 private final LatexListBo create(final LatexList latexList)
 782    throws IllegalModuleDataException {
 783  1188 if (latexList == null) {
 784  0 return null;
 785    }
 786  1188 final LatexListBo list = new LatexListBo();
 787  1188 final String context = getCurrentContext().getLocationWithinModule();
 788  1188 for (int i = 0; i < latexList.size(); i++) {
 789  2115 setLocationWithinModule(context + ".get(" + i + ")");
 790  2115 try {
 791  2115 list.add(create(latexList.get(i)));
 792    } catch (NullPointerListEntryException e) {
 793  0 throw new IllegalModuleDataException(e.getErrorCode(),
 794    e.getMessage(), new ModuleContext(getCurrentContext()), e);
 795    } catch (DuplicateLanguageEntryException e) {
 796  0 throw new IllegalModuleDataException(e.getErrorCode(), e.getMessage(),
 797    new ModuleContext(getCurrentContext()), new ModuleContext(getCurrentContext(),
 798    context + ".get(" + (e.getIndex() + 1) + ")"), e);
 799    }
 800    }
 801  1188 return list;
 802    }
 803   
 804    /**
 805    * Creates LaTeX business object.
 806    *
 807    * @param latex LaTeX object.
 808    * @return LaTeX business object.
 809    */
 810  2129 private final LatexBo create(final Latex latex) {
 811  2129 if (latex == null) {
 812  0 return null;
 813    }
 814  2129 final LatexBo lat = new LatexBo();
 815    // TODO mime 20050707: use here creation process also?
 816  2129 lat.setLanguage(latex.getLanguage());
 817  2129 lat.setLatex(latex.getLatex());
 818  2129 return lat;
 819    }
 820   
 821    /**
 822    * Set location information where are we within the orginal module.
 823    *
 824    * @param locationWithinModule Location within module.
 825    */
 826  4493 protected void setLocationWithinModule(final String locationWithinModule) {
 827  4493 getCurrentContext().setLocationWithinModule(locationWithinModule);
 828    }
 829   
 830    /**
 831    * Get current context within original.
 832    *
 833    * @return Current context.
 834    */
 835  19541 protected final ModuleContext getCurrentContext() {
 836  19541 return currentContext;
 837    }
 838   
 839    /**
 840    * Get original qedeq module.
 841    *
 842    * @return Original qedeq module.
 843    */
 844  2306 protected final Qedeq getQedeqOriginal() {
 845  2306 return original;
 846    }
 847   
 848    /**
 849    * Get currently created qedeq module.
 850    *
 851    * @return Currently created qedeq module.
 852    */
 853  306 protected final QedeqBo getQedeqCreated() {
 854  306 return qedeq;
 855    }
 856   
 857    }