0001 /* This file is part of the project "Hilbert II" - http://www.qedeq.org
0002 *
0003 * Copyright 2000-2013, Michael Meyling <mime@qedeq.org>.
0004 *
0005 * "Hilbert II" is free software; you can redistribute
0006 * it and/or modify it under the terms of the GNU General Public
0007 * License as published by the Free Software Foundation; either
0008 * version 2 of the License, or (at your option) any later version.
0009 *
0010 * This program is distributed in the hope that it will be useful,
0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of
0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0013 * GNU General Public License for more details.
0014 */
0015
0016 package org.qedeq.kernel.bo.service;
0017
0018 import org.qedeq.kernel.se.base.list.Atom;
0019 import org.qedeq.kernel.se.base.list.Element;
0020 import org.qedeq.kernel.se.base.list.ElementList;
0021 import org.qedeq.kernel.se.base.module.Add;
0022 import org.qedeq.kernel.se.base.module.Author;
0023 import org.qedeq.kernel.se.base.module.AuthorList;
0024 import org.qedeq.kernel.se.base.module.Axiom;
0025 import org.qedeq.kernel.se.base.module.ChangedRule;
0026 import org.qedeq.kernel.se.base.module.ChangedRuleList;
0027 import org.qedeq.kernel.se.base.module.Chapter;
0028 import org.qedeq.kernel.se.base.module.ChapterList;
0029 import org.qedeq.kernel.se.base.module.Conclusion;
0030 import org.qedeq.kernel.se.base.module.ConditionalProof;
0031 import org.qedeq.kernel.se.base.module.Existential;
0032 import org.qedeq.kernel.se.base.module.FormalProof;
0033 import org.qedeq.kernel.se.base.module.FormalProofLine;
0034 import org.qedeq.kernel.se.base.module.FormalProofLineList;
0035 import org.qedeq.kernel.se.base.module.FormalProofList;
0036 import org.qedeq.kernel.se.base.module.Formula;
0037 import org.qedeq.kernel.se.base.module.FunctionDefinition;
0038 import org.qedeq.kernel.se.base.module.Header;
0039 import org.qedeq.kernel.se.base.module.Hypothesis;
0040 import org.qedeq.kernel.se.base.module.Import;
0041 import org.qedeq.kernel.se.base.module.ImportList;
0042 import org.qedeq.kernel.se.base.module.InitialFunctionDefinition;
0043 import org.qedeq.kernel.se.base.module.InitialPredicateDefinition;
0044 import org.qedeq.kernel.se.base.module.Latex;
0045 import org.qedeq.kernel.se.base.module.LatexList;
0046 import org.qedeq.kernel.se.base.module.LinkList;
0047 import org.qedeq.kernel.se.base.module.LiteratureItem;
0048 import org.qedeq.kernel.se.base.module.LiteratureItemList;
0049 import org.qedeq.kernel.se.base.module.Location;
0050 import org.qedeq.kernel.se.base.module.LocationList;
0051 import org.qedeq.kernel.se.base.module.ModusPonens;
0052 import org.qedeq.kernel.se.base.module.Node;
0053 import org.qedeq.kernel.se.base.module.PredicateDefinition;
0054 import org.qedeq.kernel.se.base.module.Proof;
0055 import org.qedeq.kernel.se.base.module.ProofList;
0056 import org.qedeq.kernel.se.base.module.Proposition;
0057 import org.qedeq.kernel.se.base.module.Qedeq;
0058 import org.qedeq.kernel.se.base.module.Reason;
0059 import org.qedeq.kernel.se.base.module.Rename;
0060 import org.qedeq.kernel.se.base.module.Rule;
0061 import org.qedeq.kernel.se.base.module.Section;
0062 import org.qedeq.kernel.se.base.module.SectionList;
0063 import org.qedeq.kernel.se.base.module.Specification;
0064 import org.qedeq.kernel.se.base.module.Subsection;
0065 import org.qedeq.kernel.se.base.module.SubsectionList;
0066 import org.qedeq.kernel.se.base.module.SubstFree;
0067 import org.qedeq.kernel.se.base.module.SubstFunc;
0068 import org.qedeq.kernel.se.base.module.SubstPred;
0069 import org.qedeq.kernel.se.base.module.Universal;
0070 import org.qedeq.kernel.se.base.module.UsedByList;
0071 import org.qedeq.kernel.se.common.IllegalModuleDataException;
0072 import org.qedeq.kernel.se.common.ModuleAddress;
0073 import org.qedeq.kernel.se.common.ModuleContext;
0074 import org.qedeq.kernel.se.common.ModuleDataException;
0075 import org.qedeq.kernel.se.dto.list.DefaultAtom;
0076 import org.qedeq.kernel.se.dto.list.DefaultElementList;
0077 import org.qedeq.kernel.se.dto.module.AddVo;
0078 import org.qedeq.kernel.se.dto.module.AuthorListVo;
0079 import org.qedeq.kernel.se.dto.module.AuthorVo;
0080 import org.qedeq.kernel.se.dto.module.AxiomVo;
0081 import org.qedeq.kernel.se.dto.module.ChangedRuleListVo;
0082 import org.qedeq.kernel.se.dto.module.ChangedRuleVo;
0083 import org.qedeq.kernel.se.dto.module.ChapterListVo;
0084 import org.qedeq.kernel.se.dto.module.ChapterVo;
0085 import org.qedeq.kernel.se.dto.module.ConclusionVo;
0086 import org.qedeq.kernel.se.dto.module.ConditionalProofVo;
0087 import org.qedeq.kernel.se.dto.module.ExistentialVo;
0088 import org.qedeq.kernel.se.dto.module.FormalProofLineListVo;
0089 import org.qedeq.kernel.se.dto.module.FormalProofLineVo;
0090 import org.qedeq.kernel.se.dto.module.FormalProofListVo;
0091 import org.qedeq.kernel.se.dto.module.FormalProofVo;
0092 import org.qedeq.kernel.se.dto.module.FormulaVo;
0093 import org.qedeq.kernel.se.dto.module.FunctionDefinitionVo;
0094 import org.qedeq.kernel.se.dto.module.HeaderVo;
0095 import org.qedeq.kernel.se.dto.module.HypothesisVo;
0096 import org.qedeq.kernel.se.dto.module.ImportListVo;
0097 import org.qedeq.kernel.se.dto.module.ImportVo;
0098 import org.qedeq.kernel.se.dto.module.InitialFunctionDefinitionVo;
0099 import org.qedeq.kernel.se.dto.module.InitialPredicateDefinitionVo;
0100 import org.qedeq.kernel.se.dto.module.LatexListVo;
0101 import org.qedeq.kernel.se.dto.module.LatexVo;
0102 import org.qedeq.kernel.se.dto.module.LinkListVo;
0103 import org.qedeq.kernel.se.dto.module.LiteratureItemListVo;
0104 import org.qedeq.kernel.se.dto.module.LiteratureItemVo;
0105 import org.qedeq.kernel.se.dto.module.LocationListVo;
0106 import org.qedeq.kernel.se.dto.module.LocationVo;
0107 import org.qedeq.kernel.se.dto.module.ModusPonensVo;
0108 import org.qedeq.kernel.se.dto.module.NodeVo;
0109 import org.qedeq.kernel.se.dto.module.PredicateDefinitionVo;
0110 import org.qedeq.kernel.se.dto.module.ProofListVo;
0111 import org.qedeq.kernel.se.dto.module.ProofVo;
0112 import org.qedeq.kernel.se.dto.module.PropositionVo;
0113 import org.qedeq.kernel.se.dto.module.QedeqVo;
0114 import org.qedeq.kernel.se.dto.module.RenameVo;
0115 import org.qedeq.kernel.se.dto.module.RuleVo;
0116 import org.qedeq.kernel.se.dto.module.SectionListVo;
0117 import org.qedeq.kernel.se.dto.module.SectionVo;
0118 import org.qedeq.kernel.se.dto.module.SpecificationVo;
0119 import org.qedeq.kernel.se.dto.module.SubsectionListVo;
0120 import org.qedeq.kernel.se.dto.module.SubsectionVo;
0121 import org.qedeq.kernel.se.dto.module.SubstFreeVo;
0122 import org.qedeq.kernel.se.dto.module.SubstFuncVo;
0123 import org.qedeq.kernel.se.dto.module.SubstPredVo;
0124 import org.qedeq.kernel.se.dto.module.UniversalVo;
0125 import org.qedeq.kernel.se.dto.module.UsedByListVo;
0126
0127
0128 /**
0129 * FIXME 20110125 m31: why do we need this builder? To make copies. Why don't we take the original?
0130 * At least use director pattern or transfer creation methods into BOs or use visitor pattern!
0131 * We have lots of duplicate code here!
0132 * <p>
0133 * An builder for creating {@link org.qedeq.kernel.se.dto.module.QedeqVo}s. This builder takes
0134 * something that implements the QEDEQ interfaces (beginning with
0135 * (@link org.qedeq.kernel.base.module.Qedeq} and makes copies that are out of the package
0136 * <code>org.qedeq.kernel.dto.*</code>. Only elements that are not <code>null</code> are
0137 * copied.
0138
0139 * @author Michael Meyling
0140 */
0141 public class QedeqVoBuilder {
0142
0143 /** QEDEQ module input object. */
0144 private Qedeq original;
0145
0146 /** Current context during creation. */
0147 private ModuleContext currentContext;
0148
0149 /**
0150 * Constructor.
0151 *
0152 * @param address QEDEQ address.
0153 */
0154 protected QedeqVoBuilder(final ModuleAddress address) {
0155 this.currentContext = address.createModuleContext();
0156 }
0157
0158 /**
0159 * Create {@link QedeqVo} out of an {@link Qedeq} instance.
0160 * The resulting object has no references to the original {@link Qedeq} instance.
0161 * <p>
0162 * During the creation process the caller must assert that no modifications are made
0163 * to the {@link Qedeq} instance including its referenced objects.
0164 *
0165 * @param address Module address.
0166 * @param original Basic QEDEQ module object.
0167 * @return Created copy object.
0168 * @throws ModuleDataException Invalid data found.
0169 */
0170 public static QedeqVo createQedeq(final ModuleAddress address,
0171 final Qedeq original) throws ModuleDataException {
0172 final QedeqVoBuilder creator = new QedeqVoBuilder(address);
0173 QedeqVo vo = creator.create(original);
0174 return vo;
0175 }
0176
0177 /**
0178 * Create {@linkQedeqVo} out of an {@link Qedeq} instance.
0179 * During that procedure some basic checking is done. E.g. the uniqueness of entries
0180 * is tested. The resulting business object has no references to the original
0181 * {@link Qedeq} instance.
0182 *
0183 * <p>
0184 * During the creation process the caller must assert that no modifications are made
0185 * to the {@link Qedeq} instance including its referenced objects.
0186 *
0187 * @param original Basic QEDEQ module object.
0188 * @return Copied QEDEQ object.
0189 * @throws IllegalModuleDataException Basic semantic error occurred.
0190 */
0191 protected final QedeqVo create(final Qedeq original) throws IllegalModuleDataException {
0192 this.original = original;
0193 getCurrentContext().setLocationWithinModule("");
0194 QedeqVo qedeq;
0195 if (original == null) {
0196 qedeq = null;
0197 return qedeq;
0198 }
0199 qedeq = new QedeqVo();
0200 final String context = getCurrentContext().getLocationWithinModule();
0201 if (original.getHeader() != null) {
0202 getCurrentContext().setLocationWithinModule(context + "getHeader()");
0203 qedeq.setHeader(create(original.getHeader()));
0204 }
0205 if (original.getChapterList() != null) {
0206 getCurrentContext().setLocationWithinModule(context + "getChapterList()");
0207 qedeq.setChapterList(create(original.getChapterList()));
0208 }
0209 if (original.getLiteratureItemList() != null) {
0210 getCurrentContext().setLocationWithinModule(context + "getLiteratureItemList()");
0211 qedeq.setLiteratureItemList(create(original.getLiteratureItemList()));
0212 }
0213 return qedeq;
0214 }
0215
0216 /**
0217 * Create {@link HeaderVo} out of an {@link Header} instance.
0218 * During that procedure some basic checking is done. E.g. the uniqueness of entries
0219 * is tested. The resulting business object has no references to the original
0220 * {@link Header} instance.
0221 * <p>
0222 * During the creation process the caller must assert that no modifications are made
0223 * to the {@link Header} instance including its referenced objects.
0224 *
0225 * @param header Basic header object.
0226 * @return Filled header business object. Is equal to the parameter <code>header</code>.
0227 * @throws IllegalModuleDataException Basic semantic error occurred.
0228 */
0229 private final HeaderVo create(final Header header)
0230 throws IllegalModuleDataException {
0231 if (header == null) {
0232 return null;
0233 }
0234 final HeaderVo h = new HeaderVo();
0235 final String context = getCurrentContext().getLocationWithinModule();
0236 if (header.getTitle() != null) {
0237 setLocationWithinModule(context + ".getTitle()");
0238 h.setTitle(create(header.getTitle()));
0239 }
0240 if (header.getAuthorList() != null) {
0241 setLocationWithinModule(context + ".getAuthorList()");
0242 h.setAuthorList(create(header.getAuthorList()));
0243 }
0244 if (header.getSummary() != null) {
0245 setLocationWithinModule(context + ".getSummary()");
0246 h.setSummary(create(header.getSummary()));
0247 }
0248 if (header.getEmail() != null) {
0249 setLocationWithinModule(context + ".getEmail()");
0250 h.setEmail(header.getEmail());
0251 }
0252 if (header.getSpecification() != null) {
0253 setLocationWithinModule(context + ".getSpecification()");
0254 h.setSpecification(create(header.getSpecification()));
0255 }
0256 if (header.getImportList() != null) {
0257 setLocationWithinModule(context + ".getImportList()");
0258 h.setImportList(create(header.getImportList()));
0259 }
0260 if (header.getUsedByList() != null) {
0261 setLocationWithinModule(context + ".getUsedByList()");
0262 h.setUsedByList(create(header.getUsedByList()));
0263 }
0264 setLocationWithinModule(context);
0265 return h;
0266 }
0267
0268 /**
0269 * Create {@link UsedByListVo} out of an {@link UsedByList} instance.
0270 * During that procedure some basic checking is done. E.g. the uniqueness of entries
0271 * is tested. The resulting business object has no references to the original
0272 * {@link UsedByList} instance.
0273 * <p>
0274 * During the creation process the caller must assert that no modifications are made
0275 * to the {@link UsedByList} instance including its referenced objects.
0276 *
0277 * @param usedByList Basic header object.
0278 * @return Filled used by business object. Is equal to the parameter <code>usedByList</code>.
0279 */
0280 private final UsedByListVo create(final UsedByList usedByList) {
0281 if (usedByList == null) {
0282 return null;
0283 }
0284 final String context = getCurrentContext().getLocationWithinModule();
0285 final UsedByListVo list = new UsedByListVo();
0286 for (int i = 0; i < usedByList.size(); i++) {
0287 setLocationWithinModule(context + ".get(" + i + ")");
0288 list.add(create(usedByList.get(i)));
0289 }
0290 setLocationWithinModule(context);
0291 return list;
0292 }
0293
0294 private final ImportListVo create(final ImportList importList) {
0295 if (importList == null) {
0296 return null;
0297 }
0298 final String context = getCurrentContext().getLocationWithinModule();
0299 final ImportListVo list = new ImportListVo();
0300 for (int i = 0; i < importList.size(); i++) {
0301 setLocationWithinModule(context + ".get(" + i + ")");
0302 list.add(create(importList.get(i)));
0303 }
0304 setLocationWithinModule(context);
0305 return list;
0306 }
0307
0308 private final ImportVo create(final Import imp) {
0309 if (imp == null) {
0310 return null;
0311 }
0312 final ImportVo i = new ImportVo();
0313 final String context = getCurrentContext().getLocationWithinModule();
0314 if (imp.getLabel() != null) {
0315 setLocationWithinModule(context + ".getLabel()");
0316 i.setLabel(imp.getLabel());
0317 }
0318 if (imp.getSpecification() != null) {
0319 setLocationWithinModule(context + ".getSpecification()");
0320 i.setSpecification(create(imp.getSpecification()));
0321 }
0322 setLocationWithinModule(context);
0323 return i;
0324 }
0325
0326 private final SpecificationVo create(final Specification specification) {
0327 if (specification == null) {
0328 return null;
0329 }
0330 final SpecificationVo s = new SpecificationVo();
0331 final String context = getCurrentContext().getLocationWithinModule();
0332 if (specification.getName() != null) {
0333 setLocationWithinModule(context + ".getName()");
0334 s.setName(specification.getName());
0335 }
0336 if (specification.getRuleVersion() != null) {
0337 setLocationWithinModule(context + ".getRuleVersion()");
0338 s.setRuleVersion(specification.getRuleVersion());
0339 }
0340 if (specification.getLocationList() != null) {
0341 setLocationWithinModule(context + ".getLocationList()");
0342 s.setLocationList(create(specification.getLocationList()));
0343 }
0344 setLocationWithinModule(context);
0345 return s;
0346 }
0347
0348 private final LocationListVo create(final LocationList locationList) {
0349 if (locationList == null) {
0350 return null;
0351 }
0352 final LocationListVo list = new LocationListVo();
0353 final String context = getCurrentContext().getLocationWithinModule();
0354 for (int i = 0; i < locationList.size(); i++) {
0355 setLocationWithinModule(context + ".get(" + i + ")");
0356 list.add(create(locationList.get(i)));
0357 }
0358 setLocationWithinModule(context);
0359 return list;
0360 }
0361
0362 private final LocationVo create(final Location location) {
0363 if (location == null) {
0364 return null;
0365 }
0366 final LocationVo loc = new LocationVo();
0367 final String context = getCurrentContext().getLocationWithinModule();
0368 if (location.getLocation() != null) {
0369 setLocationWithinModule(context + ".getLocation()");
0370 loc.setLocation(location.getLocation());
0371 }
0372 setLocationWithinModule(context);
0373 return loc;
0374 }
0375
0376 private final AuthorListVo create(final AuthorList authorList) {
0377 if (authorList == null) {
0378 return null;
0379 }
0380 final AuthorListVo list = new AuthorListVo();
0381 final String context = getCurrentContext().getLocationWithinModule();
0382 for (int i = 0; i < authorList.size(); i++) {
0383 setLocationWithinModule(context + ".get(" + i + ")");
0384 list.add(create(authorList.get(i)));
0385 }
0386 setLocationWithinModule(context);
0387 return list;
0388 }
0389
0390 private final AuthorVo create(final Author author) {
0391 if (author == null) {
0392 return null;
0393 }
0394 final AuthorVo a = new AuthorVo();
0395 final String context = getCurrentContext().getLocationWithinModule();
0396 if (author.getName() != null) {
0397 setLocationWithinModule(context + ".getName()");
0398 a.setName(create(author.getName()));
0399 }
0400 if (author.getEmail() != null) {
0401 setLocationWithinModule(context + ".getEmail()");
0402 a.setEmail(author.getEmail());
0403 }
0404 setLocationWithinModule(context);
0405 return a;
0406 }
0407
0408 private final ChapterListVo create(final ChapterList chapterList)
0409 throws IllegalModuleDataException {
0410 if (chapterList == null) {
0411 return null;
0412 }
0413 final ChapterListVo list = new ChapterListVo();
0414 final String context = getCurrentContext().getLocationWithinModule();
0415 for (int i = 0; i < chapterList.size(); i++) {
0416 setLocationWithinModule(context + ".get(" + i + ")");
0417 list.add(create(chapterList.get(i)));
0418 }
0419 setLocationWithinModule(context);
0420 return list;
0421 }
0422
0423 private final ChapterVo create(final Chapter chapter)
0424 throws IllegalModuleDataException {
0425 if (chapter == null) {
0426 return null;
0427 }
0428 final ChapterVo c = new ChapterVo();
0429 final String context = getCurrentContext().getLocationWithinModule();
0430 if (chapter.getTitle() != null) {
0431 setLocationWithinModule(context + ".getTitle()");
0432 c.setTitle(create(chapter.getTitle()));
0433 }
0434 if (chapter.getNoNumber() != null) {
0435 setLocationWithinModule(context + ".getNoNumber()");
0436 c.setNoNumber(chapter.getNoNumber());
0437 }
0438 if (chapter.getIntroduction() != null) {
0439 setLocationWithinModule(context + ".getIntroduction()");
0440 c.setIntroduction(create(chapter.getIntroduction()));
0441 }
0442 if (chapter.getSectionList() != null) {
0443 setLocationWithinModule(context + ".getSectionList()");
0444 c.setSectionList(create(chapter.getSectionList()));
0445 }
0446 setLocationWithinModule(context);
0447 return c;
0448 }
0449
0450 private LiteratureItemListVo create(final LiteratureItemList literatureItemList)
0451 throws IllegalModuleDataException {
0452 if (literatureItemList == null) {
0453 return null;
0454 }
0455 final LiteratureItemListVo list = new LiteratureItemListVo();
0456 final String context = getCurrentContext().getLocationWithinModule();
0457 for (int i = 0; i < literatureItemList.size(); i++) {
0458 setLocationWithinModule(context + ".get(" + i + ")");
0459 list.add(create(literatureItemList.get(i)));
0460 }
0461 setLocationWithinModule(context);
0462 return list;
0463 }
0464
0465 private LiteratureItemVo create(final LiteratureItem item)
0466 throws IllegalModuleDataException {
0467 if (item == null) {
0468 return null;
0469 }
0470 final LiteratureItemVo it = new LiteratureItemVo();
0471 final String context = getCurrentContext().getLocationWithinModule();
0472 if (item.getLabel() != null) {
0473 setLocationWithinModule(context + ".getLabel()");
0474 it.setLabel(item.getLabel());
0475 }
0476 if (item.getItem() != null) {
0477 setLocationWithinModule(context + ".getItem()");
0478 it.setItem(create(item.getItem()));
0479 }
0480 setLocationWithinModule(context);
0481 return it;
0482
0483 }
0484
0485 private final SectionListVo create(final SectionList sectionList)
0486 throws IllegalModuleDataException {
0487 if (sectionList == null) {
0488 return null;
0489 }
0490 final SectionListVo list = new SectionListVo();
0491 final String context = getCurrentContext().getLocationWithinModule();
0492 for (int i = 0; i < sectionList.size(); i++) {
0493 setLocationWithinModule(context + ".get(" + i + ")");
0494 list.add(create(sectionList.get(i)));
0495 }
0496 setLocationWithinModule(context);
0497 return list;
0498 }
0499
0500 private final SectionVo create(final Section section)
0501 throws IllegalModuleDataException {
0502 if (section == null) {
0503 return null;
0504 }
0505 final SectionVo s = new SectionVo();
0506 final String context = getCurrentContext().getLocationWithinModule();
0507 if (section.getTitle() != null) {
0508 setLocationWithinModule(context + ".getTitle()");
0509 s.setTitle(create(section.getTitle()));
0510 }
0511 if (section.getNoNumber() != null) {
0512 setLocationWithinModule(context + ".getNoNumber()");
0513 s.setNoNumber(section.getNoNumber());
0514 }
0515 if (section.getIntroduction() != null) {
0516 setLocationWithinModule(context + ".getIntroduction()");
0517 s.setIntroduction(create(section.getIntroduction()));
0518 }
0519 if (section.getSubsectionList() != null) {
0520 setLocationWithinModule(context + ".getSubsectionList()");
0521 s.setSubsectionList(create(section.getSubsectionList()));
0522 }
0523 setLocationWithinModule(context);
0524 return s;
0525 }
0526
0527 private final SubsectionListVo create(final SubsectionList subsectionList)
0528 throws IllegalModuleDataException {
0529 if (subsectionList == null) {
0530 return null;
0531 }
0532 final SubsectionListVo list = new SubsectionListVo();
0533 final String context = getCurrentContext().getLocationWithinModule();
0534 for (int i = 0; i < subsectionList.size(); i++) {
0535 // FIXME 20130201 m31: removed, because we can't find the location if we don't also specify the
0536 // subsection type here, but is this handling ok?
0537 // setLocationWithinModule(context + ".get(" + i + ")");
0538 // TODO mime 20050608: here the Subsection context is type dependently specified
0539 if (subsectionList.get(i).getSubsection() != null) {
0540 setLocationWithinModule(context + ".get(" + i + ").getSubsection()");
0541 list.add(create(subsectionList.get(i).getSubsection()));
0542 } else if (subsectionList.get(i).getNode() != null) {
0543 setLocationWithinModule(context + ".get(" + i + ").getNode()");
0544 list.add(create(subsectionList.get(i).getNode()));
0545 } else {
0546 throw new IllegalArgumentException("unexpected subsection type: "
0547 + subsectionList.get(i).getClass());
0548 }
0549 }
0550 setLocationWithinModule(context);
0551 return list;
0552 }
0553
0554 private final SubsectionVo create(final Subsection subsection) {
0555 if (subsection == null) {
0556 return null;
0557 }
0558 final SubsectionVo s = new SubsectionVo();
0559 final String context = getCurrentContext().getLocationWithinModule();
0560 if (subsection.getId() != null) {
0561 setLocationWithinModule(context + ".getId()");
0562 s.setId(subsection.getId());
0563 }
0564 if (subsection.getLevel() != null) {
0565 setLocationWithinModule(context + ".getLevel()");
0566 s.setLevel(subsection.getLevel());
0567 }
0568 if (subsection.getTitle() != null) {
0569 setLocationWithinModule(context + ".getTitle()");
0570 s.setTitle(create(subsection.getTitle()));
0571 }
0572 if (subsection.getLatex() != null) {
0573 setLocationWithinModule(context + ".getLatex()");
0574 s.setLatex(create(subsection.getLatex()));
0575 }
0576 setLocationWithinModule(context);
0577 return s;
0578 }
0579
0580 private final NodeVo create(final Node node)
0581 throws IllegalModuleDataException {
0582 if (node == null) {
0583 return null;
0584 }
0585 final NodeVo n = new NodeVo();
0586 final String context = getCurrentContext().getLocationWithinModule();
0587 if (node.getName() != null) {
0588 setLocationWithinModule(context + ".getName()");
0589 n.setName(create(node.getName()));
0590 }
0591 if (node.getId() != null) {
0592 setLocationWithinModule(context + ".getId()");
0593 n.setId(node.getId());
0594 }
0595 if (node.getLevel() != null) {
0596 setLocationWithinModule(context + ".getLevel()");
0597 n.setLevel(node.getLevel());
0598 }
0599 if (node.getTitle() != null) {
0600 setLocationWithinModule(context + ".getTitle()");
0601 n.setTitle(create(node.getTitle()));
0602 }
0603 if (node.getPrecedingText() != null) {
0604 setLocationWithinModule(context + ".getPrecedingText()");
0605 n.setPrecedingText(create(node.getPrecedingText()));
0606 }
0607 if (node.getNodeType() != null) {
0608 setLocationWithinModule(context + ".getNodeType()");
0609 if (node.getNodeType() instanceof Axiom) {
0610 setLocationWithinModule(context + ".getNodeType().getAxiom()");
0611 n.setNodeType(create((Axiom) node.getNodeType()));
0612 } else if (node.getNodeType() instanceof InitialPredicateDefinition) {
0613 setLocationWithinModule(context + ".getNodeType().getInitialPredicateDefinition()");
0614 n.setNodeType(create((InitialPredicateDefinition) node.getNodeType()));
0615 } else if (node.getNodeType() instanceof PredicateDefinition) {
0616 setLocationWithinModule(context + ".getNodeType().getPredicateDefinition()");
0617 n.setNodeType(create((PredicateDefinition) node.getNodeType()));
0618 } else if (node.getNodeType() instanceof InitialFunctionDefinition) {
0619 setLocationWithinModule(context + ".getNodeType().getInitialFunctionDefinition()");
0620 n.setNodeType(create((InitialFunctionDefinition) node.getNodeType()));
0621 } else if (node.getNodeType() instanceof FunctionDefinition) {
0622 setLocationWithinModule(context + ".getNodeType().getFunctionDefinition()");
0623 n.setNodeType(create((FunctionDefinition) node.getNodeType()));
0624 } else if (node.getNodeType() instanceof Proposition) {
0625 setLocationWithinModule(context + ".getNodeType().getProposition()");
0626 n.setNodeType(create((Proposition) node.getNodeType()));
0627 } else if (node.getNodeType() instanceof Rule) {
0628 setLocationWithinModule(context + ".getNodeType().getRule()");
0629 n.setNodeType(create((Rule) node.getNodeType()));
0630 } else {
0631 throw new IllegalModuleDataException(ServiceErrors.RUNTIME_ERROR_CODE,
0632 ServiceErrors.RUNTIME_ERROR_TEXT + " "
0633 + "unexpected node type: " + node.getNodeType().getClass(),
0634 getCurrentContext());
0635 }
0636 }
0637 if (node.getSucceedingText() != null) {
0638 setLocationWithinModule(context + ".getSucceedingText()");
0639 n.setSucceedingText(create(node.getSucceedingText()));
0640 }
0641 setLocationWithinModule(context);
0642 return n;
0643 }
0644
0645 private final AxiomVo create(final Axiom axiom) {
0646 if (axiom == null) {
0647 return null;
0648 }
0649 final AxiomVo a = new AxiomVo();
0650 final String context = getCurrentContext().getLocationWithinModule();
0651 if (axiom.getDefinedOperator() != null) {
0652 setLocationWithinModule(context + ".getDefinedOperator()");
0653 a.setDefinedOperator(axiom.getDefinedOperator());
0654 }
0655 if (axiom.getFormula() != null) {
0656 setLocationWithinModule(context + ".getFormula()");
0657 a.setFormula(create(axiom.getFormula()));
0658 }
0659 if (axiom.getDescription() != null) {
0660 setLocationWithinModule(context + ".getDescription()");
0661 a.setDescription(create(axiom.getDescription()));
0662 }
0663 setLocationWithinModule(context);
0664 return a;
0665 }
0666
0667 private final InitialPredicateDefinitionVo create(final InitialPredicateDefinition definition) {
0668 if (definition == null) {
0669 return null;
0670 }
0671 final InitialPredicateDefinitionVo d = new InitialPredicateDefinitionVo();
0672 final String context = getCurrentContext().getLocationWithinModule();
0673 if (definition.getLatexPattern() != null) {
0674 setLocationWithinModule(context + ".getLatexPattern()");
0675 d.setLatexPattern(definition.getLatexPattern());
0676 }
0677 if (definition.getName() != null) {
0678 setLocationWithinModule(context + ".getName()");
0679 d.setName(definition.getName());
0680 }
0681 if (definition.getArgumentNumber() != null) {
0682 setLocationWithinModule(context + ".getArgumentNumber()");
0683 d.setArgumentNumber(definition.getArgumentNumber());
0684 }
0685 if (definition.getPredCon() != null) {
0686 setLocationWithinModule(context + ".getPredCon()");
0687 d.setPredCon(create(definition.getPredCon()));
0688 }
0689 if (definition.getDescription() != null) {
0690 setLocationWithinModule(context + ".getDescription()");
0691 d.setDescription(create(definition.getDescription()));
0692 }
0693 setLocationWithinModule(context);
0694 return d;
0695 }
0696
0697 private final PredicateDefinitionVo create(final PredicateDefinition definition) {
0698 if (definition == null) {
0699 return null;
0700 }
0701 final PredicateDefinitionVo d = new PredicateDefinitionVo();
0702 final String context = getCurrentContext().getLocationWithinModule();
0703 if (definition.getLatexPattern() != null) {
0704 setLocationWithinModule(context + ".getLatexPattern()");
0705 d.setLatexPattern(definition.getLatexPattern());
0706 }
0707 if (definition.getName() != null) {
0708 setLocationWithinModule(context + ".getName()");
0709 d.setName(definition.getName());
0710 }
0711 if (definition.getArgumentNumber() != null) {
0712 setLocationWithinModule(context + ".getArgumentNumber()");
0713 d.setArgumentNumber(definition.getArgumentNumber());
0714 }
0715 if (definition.getFormula() != null) {
0716 setLocationWithinModule(context + ".getFormula()");
0717 d.setFormula(create(definition.getFormula()));
0718 }
0719 if (definition.getDescription() != null) {
0720 setLocationWithinModule(context + ".getDescription()");
0721 d.setDescription(create(definition.getDescription()));
0722 }
0723 setLocationWithinModule(context);
0724 return d;
0725 }
0726
0727 private final InitialFunctionDefinitionVo create(final InitialFunctionDefinition definition) {
0728 if (definition == null) {
0729 return null;
0730 }
0731 final InitialFunctionDefinitionVo d = new InitialFunctionDefinitionVo();
0732 final String context = getCurrentContext().getLocationWithinModule();
0733 if (definition.getLatexPattern() != null) {
0734 setLocationWithinModule(context + ".getLatexPattern()");
0735 d.setLatexPattern(definition.getLatexPattern());
0736 }
0737 if (definition.getArgumentNumber() != null) {
0738 setLocationWithinModule(context + ".getArgumentNumber()");
0739 d.setArgumentNumber(definition.getArgumentNumber());
0740 }
0741 if (definition.getName() != null) {
0742 setLocationWithinModule(context + ".getName()");
0743 d.setName(definition.getName());
0744 }
0745 if (definition.getFunCon() != null) {
0746 setLocationWithinModule(context + ".getFunCon()");
0747 d.setFunCon(create(definition.getFunCon()));
0748 }
0749 if (definition.getDescription() != null) {
0750 setLocationWithinModule(context + ".getDescription()");
0751 d.setDescription(create(definition.getDescription()));
0752 }
0753 setLocationWithinModule(context);
0754 return d;
0755 }
0756
0757 private final FunctionDefinitionVo create(final FunctionDefinition definition) {
0758 if (definition == null) {
0759 return null;
0760 }
0761 final FunctionDefinitionVo d = new FunctionDefinitionVo();
0762 final String context = getCurrentContext().getLocationWithinModule();
0763 if (definition.getLatexPattern() != null) {
0764 setLocationWithinModule(context + ".getLatexPattern()");
0765 d.setLatexPattern(definition.getLatexPattern());
0766 }
0767 if (definition.getArgumentNumber() != null) {
0768 setLocationWithinModule(context + ".getArgumentNumber()");
0769 d.setArgumentNumber(definition.getArgumentNumber());
0770 }
0771 if (definition.getName() != null) {
0772 setLocationWithinModule(context + ".getName()");
0773 d.setName(definition.getName());
0774 }
0775 if (definition.getFormula() != null) {
0776 setLocationWithinModule(context + ".getFormula()");
0777 d.setFormula(create(definition.getFormula()));
0778 }
0779 if (definition.getDescription() != null) {
0780 setLocationWithinModule(context + ".getDescription()");
0781 d.setDescription(create(definition.getDescription()));
0782 }
0783 setLocationWithinModule(context);
0784 return d;
0785 }
0786
0787 private final PropositionVo create(final Proposition proposition) {
0788 if (proposition == null) {
0789 return null;
0790 }
0791 final PropositionVo p = new PropositionVo();
0792 final String context = getCurrentContext().getLocationWithinModule();
0793 if (proposition.getFormula() != null) {
0794 setLocationWithinModule(context + ".getFormula()");
0795 p.setFormula(create(proposition.getFormula()));
0796 }
0797 if (proposition.getDescription() != null) {
0798 setLocationWithinModule(context + ".getDescription()");
0799 p.setDescription(create(proposition.getDescription()));
0800 }
0801 if (proposition.getProofList() != null) {
0802 setLocationWithinModule(context + ".getProofList()");
0803 p.setProofList(create(proposition.getProofList()));
0804 }
0805 if (proposition.getFormalProofList() != null) {
0806 setLocationWithinModule(context + ".getFormalProofList()");
0807 p.setFormalProofList(create(proposition.getFormalProofList()));
0808 }
0809 setLocationWithinModule(context);
0810 return p;
0811 }
0812
0813 private final RuleVo create(final Rule rule) {
0814 if (rule == null) {
0815 return null;
0816 }
0817 final RuleVo r = new RuleVo();
0818 final String context = getCurrentContext().getLocationWithinModule();
0819 if (rule.getName() != null) {
0820 setLocationWithinModule(context + ".getName()");
0821 r.setName(rule.getName());
0822 }
0823 if (rule.getVersion() != null) {
0824 setLocationWithinModule(context + ".getVersion()");
0825 r.setVersion(rule.getVersion());
0826 }
0827 if (rule.getLinkList() != null) {
0828 setLocationWithinModule(context + ".getLinkList()");
0829 r.setLinkList(create(rule.getLinkList()));
0830 }
0831 if (rule.getDescription() != null) {
0832 setLocationWithinModule(context + ".getDescription()");
0833 r.setDescription(create(rule.getDescription()));
0834 }
0835 if (rule.getChangedRuleList() != null) {
0836 setLocationWithinModule(context + ".getChangedRuleList()");
0837 r.setChangedRuleList(create(rule.getChangedRuleList()));
0838 }
0839 if (rule.getProofList() != null) {
0840 setLocationWithinModule(context + ".getProofList()");
0841 r.setProofList(create(rule.getProofList()));
0842 }
0843 setLocationWithinModule(context);
0844 return r;
0845 }
0846
0847 private final ChangedRuleListVo create(final ChangedRuleList changedRuleList) {
0848 if (changedRuleList == null) {
0849 return null;
0850 }
0851 final ChangedRuleListVo list = new ChangedRuleListVo();
0852 final String context = getCurrentContext().getLocationWithinModule();
0853 for (int i = 0; i < changedRuleList.size(); i++) {
0854 setLocationWithinModule(context + ".get(" + i + ")");
0855 list.add(create(changedRuleList.get(i)));
0856 }
0857 setLocationWithinModule(context);
0858 return list;
0859 }
0860
0861 private final ChangedRuleVo create(final ChangedRule rule) {
0862 if (rule == null) {
0863 return null;
0864 }
0865 final ChangedRuleVo r = new ChangedRuleVo();
0866 final String context = getCurrentContext().getLocationWithinModule();
0867 if (rule.getName() != null) {
0868 setLocationWithinModule(context + ".getName()");
0869 r.setName(rule.getName());
0870 }
0871 if (rule.getVersion() != null) {
0872 setLocationWithinModule(context + ".getVersion()");
0873 r.setVersion(rule.getVersion());
0874 }
0875 if (rule.getDescription() != null) {
0876 setLocationWithinModule(context + ".getDescription()");
0877 r.setDescription(create(rule.getDescription()));
0878 }
0879 setLocationWithinModule(context);
0880 return r;
0881 }
0882
0883 private final LinkListVo create(final LinkList linkList) {
0884 if (linkList == null) {
0885 return null;
0886 }
0887 final LinkListVo list = new LinkListVo();
0888 final String context = getCurrentContext().getLocationWithinModule();
0889 for (int i = 0; i < linkList.size(); i++) {
0890 setLocationWithinModule(context + ".get(" + i + ")");
0891 list.add(linkList.get(i));
0892 }
0893 setLocationWithinModule(context);
0894 return list;
0895 }
0896
0897 private final ProofListVo create(final ProofList proofList) {
0898 if (proofList == null) {
0899 return null;
0900 }
0901 final ProofListVo list = new ProofListVo();
0902 final String context = getCurrentContext().getLocationWithinModule();
0903 for (int i = 0; i < proofList.size(); i++) {
0904 setLocationWithinModule(context + ".get(" + i + ")");
0905 list.add(create(proofList.get(i)));
0906 }
0907 setLocationWithinModule(context);
0908 return list;
0909 }
0910
0911 private final ProofVo create(final Proof proof) {
0912 if (proof == null) {
0913 return null;
0914 }
0915 final ProofVo p = new ProofVo();
0916 final String context = getCurrentContext().getLocationWithinModule();
0917 setLocationWithinModule(context + ".getKind()");
0918 p.setKind(proof.getKind());
0919 setLocationWithinModule(context + ".getLevel()");
0920 p.setLevel(proof.getLevel());
0921 setLocationWithinModule(context);
0922 if (proof.getNonFormalProof() != null) {
0923 setLocationWithinModule(context + ".getNonFormalProof()");
0924 p.setNonFormalProof(create(proof.getNonFormalProof()));
0925 }
0926 setLocationWithinModule(context);
0927 return p;
0928 }
0929
0930 private final FormalProofListVo create(final FormalProofList proofList) {
0931 if (proofList == null) {
0932 return null;
0933 }
0934 final FormalProofListVo list = new FormalProofListVo();
0935 final String context = getCurrentContext().getLocationWithinModule();
0936 for (int i = 0; i < proofList.size(); i++) {
0937 setLocationWithinModule(context + ".get(" + i + ")");
0938 list.add(create(proofList.get(i)));
0939 }
0940 setLocationWithinModule(context);
0941 return list;
0942 }
0943
0944 private final FormalProofVo create(final FormalProof proof) {
0945 if (proof == null) {
0946 return null;
0947 }
0948 final FormalProofVo p = new FormalProofVo();
0949 final String context = getCurrentContext().getLocationWithinModule();
0950 setLocationWithinModule(context);
0951 if (proof.getPrecedingText() != null) {
0952 setLocationWithinModule(context + ".getPrecedingText()");
0953 p.setPrecedingText(create(proof.getPrecedingText()));
0954 }
0955 if (proof.getFormalProofLineList() != null) {
0956 setLocationWithinModule(context + ".getFormalProofLineList()");
0957 p.setFormalProofLineList(create(proof.getFormalProofLineList()));
0958 }
0959 if (proof.getSucceedingText() != null) {
0960 setLocationWithinModule(context + ".getSucceedingText()");
0961 p.setSucceedingText(create(proof.getSucceedingText()));
0962 }
0963 setLocationWithinModule(context);
0964 return p;
0965 }
0966
0967 private final FormalProofLineListVo create(final FormalProofLineList proofList) {
0968 if (proofList == null) {
0969 return null;
0970 }
0971 final FormalProofLineListVo list = new FormalProofLineListVo();
0972 final String context = getCurrentContext().getLocationWithinModule();
0973 for (int i = 0; i < proofList.size(); i++) {
0974 setLocationWithinModule(context + ".get(" + i + ")");
0975 if (proofList.get(i) instanceof ConditionalProof) {
0976 list.add(create((ConditionalProof) proofList.get(i)));
0977 } else {
0978 list.add(create(proofList.get(i)));
0979 }
0980 }
0981 setLocationWithinModule(context);
0982 return list;
0983 }
0984
0985 private final FormalProofLineVo create(final FormalProofLine proofLine) {
0986 if (proofLine == null) {
0987 return null;
0988 }
0989 final FormalProofLineVo line = new FormalProofLineVo();
0990 final String context = getCurrentContext().getLocationWithinModule();
0991 if (proofLine.getLabel() != null) {
0992 setLocationWithinModule(context + ".getLabel()");
0993 line.setLabel(proofLine.getLabel());
0994 }
0995 if (proofLine.getFormula() != null) {
0996 setLocationWithinModule(context + ".getFormula()");
0997 line.setFormula(create(proofLine.getFormula()));
0998 }
0999 if (proofLine.getReason() != null) {
1000 setLocationWithinModule(context + ".getReason()");
1001 line.setReason(create(proofLine.getReason()));
1002 }
1003 setLocationWithinModule(context);
1004 return line;
1005 }
1006
1007 private final ConditionalProofVo create(final ConditionalProof proofLine) {
1008 if (proofLine == null) {
1009 return null;
1010 }
1011 final ConditionalProofVo line = new ConditionalProofVo();
1012 final String context = getCurrentContext().getLocationWithinModule();
1013 if (proofLine.getHypothesis() != null) {
1014 setLocationWithinModule(context + ".getHypothesis()");
1015 line.setHypothesis(proofLine.getHypothesis());
1016 }
1017 if (proofLine.getFormalProofLineList() != null) {
1018 setLocationWithinModule(context + ".getFormalProofLineList()");
1019 line.setFormalProofLineList(create(proofLine.getFormalProofLineList()));
1020 }
1021 if (proofLine.getConclusion() != null) {
1022 setLocationWithinModule(context + ".getConclusion()");
1023 line.setConclusion(create(proofLine.getConclusion()));
1024 }
1025 setLocationWithinModule(context);
1026 return line;
1027 }
1028
1029 private final Reason create(final Reason reason) {
1030 if (reason == null) {
1031 return null;
1032 }
1033 final String context = getCurrentContext().getLocationWithinModule();
1034 Reason result = null;
1035 if (reason instanceof ModusPonens) {
1036 setLocationWithinModule(context + ".getModusPonens()");
1037 final ModusPonens r = (ModusPonens) reason;
1038 result = new ModusPonensVo(r.getReference1(), r.getReference2());
1039 } else if (reason instanceof Add) {
1040 setLocationWithinModule(context + ".getAdd()");
1041 final Add r = (Add) reason;
1042 result = new AddVo(r.getReference());
1043 } else if (reason instanceof Rename) {
1044 setLocationWithinModule(context + ".getRename()");
1045 final Rename r = (Rename) reason;
1046 result = new RenameVo(r.getReference(), r.getOriginalSubjectVariable(),
1047 r.getReplacementSubjectVariable(), r.getOccurrence());
1048 } else if (reason instanceof SubstFree) {
1049 setLocationWithinModule(context + ".getSubstFree()");
1050 final SubstFree r = (SubstFree) reason;
1051 result = new SubstFreeVo(r.getReference(), r.getSubjectVariable(),
1052 r.getSubstituteTerm());
1053 } else if (reason instanceof SubstFunc) {
1054 setLocationWithinModule(context + ".getSubstFunc()");
1055 final SubstFunc r = (SubstFunc) reason;
1056 result = new SubstFuncVo(r.getReference(), r.getFunctionVariable(),
1057 r.getSubstituteTerm());
1058 } else if (reason instanceof SubstPred) {
1059 setLocationWithinModule(context + ".getSubstPred()");
1060 final SubstPred r = (SubstPred) reason;
1061 result = new SubstPredVo(r.getReference(), r.getPredicateVariable(),
1062 r.getSubstituteFormula());
1063 } else if (reason instanceof Existential) {
1064 setLocationWithinModule(context + ".getExistential()");
1065 final Existential r = (Existential) reason;
1066 result = new ExistentialVo(r.getReference(), r.getSubjectVariable());
1067 } else if (reason instanceof Universal) {
1068 setLocationWithinModule(context + ".getUniversal()");
1069 final Universal r = (Universal) reason;
1070 result = new UniversalVo(r.getReference(), r.getSubjectVariable());
1071 } else if (reason instanceof ConditionalProof) {
1072 setLocationWithinModule(context + ".getConditionalProof()");
1073 final ConditionalProof r = (ConditionalProof) reason;
1074 setLocationWithinModule(context + ".getConditionalProof().getHypothesis()");
1075 final Hypothesis h = create(r.getHypothesis());
1076 setLocationWithinModule(context + ".getConditionalProof().getFormalProofLineList()");
1077 final FormalProofLineList l = create(r.getFormalProofLineList());
1078 setLocationWithinModule(context + ".getConditionalProof().getConclusion()");
1079 final Conclusion c = create(r.getConclusion());
1080 result = new ConditionalProofVo(h, l, c);
1081 } else {
1082 throw new RuntimeException("unknown reason class: " + reason.getClass());
1083 }
1084 setLocationWithinModule(context);
1085 return result;
1086 }
1087
1088 private final HypothesisVo create(final Hypothesis hypothesis) {
1089 if (hypothesis == null) {
1090 return null;
1091 }
1092 final HypothesisVo h = new HypothesisVo();
1093 final String context = getCurrentContext().getLocationWithinModule();
1094 if (hypothesis.getLabel() != null) {
1095 h.setLabel(hypothesis.getLabel());
1096 }
1097 if (hypothesis.getFormula() != null) {
1098 setLocationWithinModule(context + ".getFormula()");
1099 h.setFormula(create(hypothesis.getFormula()));
1100 }
1101 setLocationWithinModule(context);
1102 return h;
1103 }
1104
1105 private final ConclusionVo create(final Conclusion conclusion) {
1106 if (conclusion == null) {
1107 return null;
1108 }
1109 final ConclusionVo c = new ConclusionVo();
1110 final String context = getCurrentContext().getLocationWithinModule();
1111 if (conclusion.getLabel() != null) {
1112 c.setLabel(conclusion.getLabel());
1113 }
1114 if (conclusion.getFormula() != null) {
1115 setLocationWithinModule(context + ".getFormula()");
1116 c.setFormula(create(conclusion.getFormula()));
1117 }
1118 setLocationWithinModule(context);
1119 return c;
1120 }
1121
1122 private final FormulaVo create(final Formula formula) {
1123 if (formula == null) {
1124 return null;
1125 }
1126 final FormulaVo f = new FormulaVo();
1127 final String context = getCurrentContext().getLocationWithinModule();
1128 if (formula.getElement() != null) {
1129 setLocationWithinModule(context + ".getElement()");
1130 f.setElement(create(formula.getElement()));
1131 }
1132 setLocationWithinModule(context);
1133 return f;
1134 }
1135
1136 private final Element create(final Element element) {
1137 if (element == null) {
1138 return null;
1139 }
1140 final Element e;
1141 final String context = getCurrentContext().getLocationWithinModule();
1142 if (element.isList()) {
1143 setLocationWithinModule(context + ".getList()");
1144 e = create(element.getList());
1145 } else if (element.isAtom()) {
1146 // setLocationWithinModule(context + ".getAtom()");
1147 return create(element.getAtom());
1148 } else {
1149 throw new RuntimeException("unknown element type: " + element);
1150 }
1151 setLocationWithinModule(context);
1152 return e;
1153 }
1154
1155
1156 private final DefaultElementList create(final ElementList list) {
1157 if (list == null) {
1158 return null;
1159 }
1160 final DefaultElementList n = new DefaultElementList(list.getOperator(), new Element[] {});
1161 final String context = getCurrentContext().getLocationWithinModule();
1162 for (int i = 0; i < list.size(); i++) {
1163 if (list.getElement(i).isList()) {
1164 setLocationWithinModule(context + ".getElement(" + i + ")");
1165 }
1166 n.add(create(list.getElement(i)));
1167 }
1168 setLocationWithinModule(context);
1169 return n;
1170 }
1171
1172 private final DefaultAtom create(final Atom atom) {
1173 if (atom == null) {
1174 return null;
1175 }
1176 return new DefaultAtom(atom.getString());
1177 }
1178
1179 private final LatexListVo create(final LatexList latexList) {
1180 if (latexList == null) {
1181 return null;
1182 }
1183 final LatexListVo list = new LatexListVo();
1184 final String context = getCurrentContext().getLocationWithinModule();
1185 for (int i = 0; i < latexList.size(); i++) {
1186 setLocationWithinModule(context + ".get(" + i + ")");
1187 list.add(create(latexList.get(i)));
1188 }
1189 setLocationWithinModule(context);
1190 return list;
1191 }
1192
1193 /**
1194 * Creates LaTeX business object.
1195 *
1196 * @param latex LaTeX object.
1197 * @return LaTeX business object.
1198 */
1199 private final LatexVo create(final Latex latex) {
1200 if (latex == null) {
1201 return null;
1202 }
1203 final LatexVo lat = new LatexVo();
1204 lat.setLanguage(latex.getLanguage());
1205 lat.setLatex(latex.getLatex());
1206 return lat;
1207 }
1208
1209 /**
1210 * Set location information where are we within the original module.
1211 *
1212 * @param locationWithinModule Location within module.
1213 */
1214 protected void setLocationWithinModule(final String locationWithinModule) {
1215 getCurrentContext().setLocationWithinModule(locationWithinModule);
1216 }
1217
1218 /**
1219 * Get current context within original.
1220 *
1221 * @return Current context.
1222 */
1223 protected final ModuleContext getCurrentContext() {
1224 return currentContext;
1225 }
1226
1227 /**
1228 * Get original QEDEQ module.
1229 *
1230 * @return Original QEDEQ module.
1231 */
1232 protected final Qedeq getQedeqOriginal() {
1233 return original;
1234 }
1235
1236 }
|