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