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 * TODO 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 if (literatureItemList == null) {
0452 return null;
0453 }
0454 final LiteratureItemListVo list = new LiteratureItemListVo();
0455 final String context = getCurrentContext().getLocationWithinModule();
0456 for (int i = 0; i < literatureItemList.size(); i++) {
0457 setLocationWithinModule(context + ".get(" + i + ")");
0458 list.add(create(literatureItemList.get(i)));
0459 }
0460 setLocationWithinModule(context);
0461 return list;
0462 }
0463
0464 private LiteratureItemVo create(final LiteratureItem item) {
0465 if (item == null) {
0466 return null;
0467 }
0468 final LiteratureItemVo it = new LiteratureItemVo();
0469 final String context = getCurrentContext().getLocationWithinModule();
0470 if (item.getLabel() != null) {
0471 setLocationWithinModule(context + ".getLabel()");
0472 it.setLabel(item.getLabel());
0473 }
0474 if (item.getItem() != null) {
0475 setLocationWithinModule(context + ".getItem()");
0476 it.setItem(create(item.getItem()));
0477 }
0478 setLocationWithinModule(context);
0479 return it;
0480
0481 }
0482
0483 private final SectionListVo create(final SectionList sectionList)
0484 throws IllegalModuleDataException {
0485 if (sectionList == null) {
0486 return null;
0487 }
0488 final SectionListVo list = new SectionListVo();
0489 final String context = getCurrentContext().getLocationWithinModule();
0490 for (int i = 0; i < sectionList.size(); i++) {
0491 setLocationWithinModule(context + ".get(" + i + ")");
0492 list.add(create(sectionList.get(i)));
0493 }
0494 setLocationWithinModule(context);
0495 return list;
0496 }
0497
0498 private final SectionVo create(final Section section)
0499 throws IllegalModuleDataException {
0500 if (section == null) {
0501 return null;
0502 }
0503 final SectionVo s = new SectionVo();
0504 final String context = getCurrentContext().getLocationWithinModule();
0505 if (section.getTitle() != null) {
0506 setLocationWithinModule(context + ".getTitle()");
0507 s.setTitle(create(section.getTitle()));
0508 }
0509 if (section.getNoNumber() != null) {
0510 setLocationWithinModule(context + ".getNoNumber()");
0511 s.setNoNumber(section.getNoNumber());
0512 }
0513 if (section.getIntroduction() != null) {
0514 setLocationWithinModule(context + ".getIntroduction()");
0515 s.setIntroduction(create(section.getIntroduction()));
0516 }
0517 if (section.getSubsectionList() != null) {
0518 setLocationWithinModule(context + ".getSubsectionList()");
0519 s.setSubsectionList(create(section.getSubsectionList()));
0520 }
0521 setLocationWithinModule(context);
0522 return s;
0523 }
0524
0525 private final SubsectionListVo create(final SubsectionList subsectionList)
0526 throws IllegalModuleDataException {
0527 if (subsectionList == null) {
0528 return null;
0529 }
0530 final SubsectionListVo list = new SubsectionListVo();
0531 final String context = getCurrentContext().getLocationWithinModule();
0532 for (int i = 0; i < subsectionList.size(); i++) {
0533 // FIXME 20130201 m31: removed, because we can't find the location if we don't also specify the
0534 // subsection type here, but is this handling ok?
0535 // setLocationWithinModule(context + ".get(" + i + ")");
0536 // TODO mime 20050608: here the Subsection context is type dependently specified
0537 if (subsectionList.get(i).getSubsection() != null) {
0538 setLocationWithinModule(context + ".get(" + i + ").getSubsection()");
0539 list.add(create(subsectionList.get(i).getSubsection()));
0540 } else if (subsectionList.get(i).getNode() != null) {
0541 setLocationWithinModule(context + ".get(" + i + ").getNode()");
0542 list.add(create(subsectionList.get(i).getNode()));
0543 } else {
0544 throw new IllegalArgumentException("unexpected subsection type: "
0545 + subsectionList.get(i).getClass());
0546 }
0547 }
0548 setLocationWithinModule(context);
0549 return list;
0550 }
0551
0552 private final SubsectionVo create(final Subsection subsection) {
0553 if (subsection == null) {
0554 return null;
0555 }
0556 final SubsectionVo s = new SubsectionVo();
0557 final String context = getCurrentContext().getLocationWithinModule();
0558 if (subsection.getId() != null) {
0559 setLocationWithinModule(context + ".getId()");
0560 s.setId(subsection.getId());
0561 }
0562 if (subsection.getLevel() != null) {
0563 setLocationWithinModule(context + ".getLevel()");
0564 s.setLevel(subsection.getLevel());
0565 }
0566 if (subsection.getTitle() != null) {
0567 setLocationWithinModule(context + ".getTitle()");
0568 s.setTitle(create(subsection.getTitle()));
0569 }
0570 if (subsection.getLatex() != null) {
0571 setLocationWithinModule(context + ".getLatex()");
0572 s.setLatex(create(subsection.getLatex()));
0573 }
0574 setLocationWithinModule(context);
0575 return s;
0576 }
0577
0578 private final NodeVo create(final Node node)
0579 throws IllegalModuleDataException {
0580 if (node == null) {
0581 return null;
0582 }
0583 final NodeVo n = new NodeVo();
0584 final String context = getCurrentContext().getLocationWithinModule();
0585 if (node.getName() != null) {
0586 setLocationWithinModule(context + ".getName()");
0587 n.setName(create(node.getName()));
0588 }
0589 if (node.getId() != null) {
0590 setLocationWithinModule(context + ".getId()");
0591 n.setId(node.getId());
0592 }
0593 if (node.getLevel() != null) {
0594 setLocationWithinModule(context + ".getLevel()");
0595 n.setLevel(node.getLevel());
0596 }
0597 if (node.getTitle() != null) {
0598 setLocationWithinModule(context + ".getTitle()");
0599 n.setTitle(create(node.getTitle()));
0600 }
0601 if (node.getPrecedingText() != null) {
0602 setLocationWithinModule(context + ".getPrecedingText()");
0603 n.setPrecedingText(create(node.getPrecedingText()));
0604 }
0605 if (node.getNodeType() != null) {
0606 setLocationWithinModule(context + ".getNodeType()");
0607 if (node.getNodeType() instanceof Axiom) {
0608 setLocationWithinModule(context + ".getNodeType().getAxiom()");
0609 n.setNodeType(create((Axiom) node.getNodeType()));
0610 } else if (node.getNodeType() instanceof InitialPredicateDefinition) {
0611 setLocationWithinModule(context + ".getNodeType().getInitialPredicateDefinition()");
0612 n.setNodeType(create((InitialPredicateDefinition) node.getNodeType()));
0613 } else if (node.getNodeType() instanceof PredicateDefinition) {
0614 setLocationWithinModule(context + ".getNodeType().getPredicateDefinition()");
0615 n.setNodeType(create((PredicateDefinition) node.getNodeType()));
0616 } else if (node.getNodeType() instanceof InitialFunctionDefinition) {
0617 setLocationWithinModule(context + ".getNodeType().getInitialFunctionDefinition()");
0618 n.setNodeType(create((InitialFunctionDefinition) node.getNodeType()));
0619 } else if (node.getNodeType() instanceof FunctionDefinition) {
0620 setLocationWithinModule(context + ".getNodeType().getFunctionDefinition()");
0621 n.setNodeType(create((FunctionDefinition) node.getNodeType()));
0622 } else if (node.getNodeType() instanceof Proposition) {
0623 setLocationWithinModule(context + ".getNodeType().getProposition()");
0624 n.setNodeType(create((Proposition) node.getNodeType()));
0625 } else if (node.getNodeType() instanceof Rule) {
0626 setLocationWithinModule(context + ".getNodeType().getRule()");
0627 n.setNodeType(create((Rule) node.getNodeType()));
0628 } else {
0629 throw new IllegalModuleDataException(ServiceErrors.RUNTIME_ERROR_CODE,
0630 ServiceErrors.RUNTIME_ERROR_TEXT + " "
0631 + "unexpected node type: " + node.getNodeType().getClass(),
0632 getCurrentContext());
0633 }
0634 }
0635 if (node.getSucceedingText() != null) {
0636 setLocationWithinModule(context + ".getSucceedingText()");
0637 n.setSucceedingText(create(node.getSucceedingText()));
0638 }
0639 setLocationWithinModule(context);
0640 return n;
0641 }
0642
0643 private final AxiomVo create(final Axiom axiom) {
0644 if (axiom == null) {
0645 return null;
0646 }
0647 final AxiomVo a = new AxiomVo();
0648 final String context = getCurrentContext().getLocationWithinModule();
0649 if (axiom.getDefinedOperator() != null) {
0650 setLocationWithinModule(context + ".getDefinedOperator()");
0651 a.setDefinedOperator(axiom.getDefinedOperator());
0652 }
0653 if (axiom.getFormula() != null) {
0654 setLocationWithinModule(context + ".getFormula()");
0655 a.setFormula(create(axiom.getFormula()));
0656 }
0657 if (axiom.getDescription() != null) {
0658 setLocationWithinModule(context + ".getDescription()");
0659 a.setDescription(create(axiom.getDescription()));
0660 }
0661 setLocationWithinModule(context);
0662 return a;
0663 }
0664
0665 private final InitialPredicateDefinitionVo create(final InitialPredicateDefinition definition) {
0666 if (definition == null) {
0667 return null;
0668 }
0669 final InitialPredicateDefinitionVo d = new InitialPredicateDefinitionVo();
0670 final String context = getCurrentContext().getLocationWithinModule();
0671 if (definition.getLatexPattern() != null) {
0672 setLocationWithinModule(context + ".getLatexPattern()");
0673 d.setLatexPattern(definition.getLatexPattern());
0674 }
0675 if (definition.getName() != null) {
0676 setLocationWithinModule(context + ".getName()");
0677 d.setName(definition.getName());
0678 }
0679 if (definition.getArgumentNumber() != null) {
0680 setLocationWithinModule(context + ".getArgumentNumber()");
0681 d.setArgumentNumber(definition.getArgumentNumber());
0682 }
0683 if (definition.getPredCon() != null) {
0684 setLocationWithinModule(context + ".getPredCon()");
0685 d.setPredCon(create(definition.getPredCon()));
0686 }
0687 if (definition.getDescription() != null) {
0688 setLocationWithinModule(context + ".getDescription()");
0689 d.setDescription(create(definition.getDescription()));
0690 }
0691 setLocationWithinModule(context);
0692 return d;
0693 }
0694
0695 private final PredicateDefinitionVo create(final PredicateDefinition definition) {
0696 if (definition == null) {
0697 return null;
0698 }
0699 final PredicateDefinitionVo d = new PredicateDefinitionVo();
0700 final String context = getCurrentContext().getLocationWithinModule();
0701 if (definition.getLatexPattern() != null) {
0702 setLocationWithinModule(context + ".getLatexPattern()");
0703 d.setLatexPattern(definition.getLatexPattern());
0704 }
0705 if (definition.getName() != null) {
0706 setLocationWithinModule(context + ".getName()");
0707 d.setName(definition.getName());
0708 }
0709 if (definition.getArgumentNumber() != null) {
0710 setLocationWithinModule(context + ".getArgumentNumber()");
0711 d.setArgumentNumber(definition.getArgumentNumber());
0712 }
0713 if (definition.getFormula() != null) {
0714 setLocationWithinModule(context + ".getFormula()");
0715 d.setFormula(create(definition.getFormula()));
0716 }
0717 if (definition.getDescription() != null) {
0718 setLocationWithinModule(context + ".getDescription()");
0719 d.setDescription(create(definition.getDescription()));
0720 }
0721 setLocationWithinModule(context);
0722 return d;
0723 }
0724
0725 private final InitialFunctionDefinitionVo create(final InitialFunctionDefinition definition) {
0726 if (definition == null) {
0727 return null;
0728 }
0729 final InitialFunctionDefinitionVo d = new InitialFunctionDefinitionVo();
0730 final String context = getCurrentContext().getLocationWithinModule();
0731 if (definition.getLatexPattern() != null) {
0732 setLocationWithinModule(context + ".getLatexPattern()");
0733 d.setLatexPattern(definition.getLatexPattern());
0734 }
0735 if (definition.getArgumentNumber() != null) {
0736 setLocationWithinModule(context + ".getArgumentNumber()");
0737 d.setArgumentNumber(definition.getArgumentNumber());
0738 }
0739 if (definition.getName() != null) {
0740 setLocationWithinModule(context + ".getName()");
0741 d.setName(definition.getName());
0742 }
0743 if (definition.getFunCon() != null) {
0744 setLocationWithinModule(context + ".getFunCon()");
0745 d.setFunCon(create(definition.getFunCon()));
0746 }
0747 if (definition.getDescription() != null) {
0748 setLocationWithinModule(context + ".getDescription()");
0749 d.setDescription(create(definition.getDescription()));
0750 }
0751 setLocationWithinModule(context);
0752 return d;
0753 }
0754
0755 private final FunctionDefinitionVo create(final FunctionDefinition definition) {
0756 if (definition == null) {
0757 return null;
0758 }
0759 final FunctionDefinitionVo d = new FunctionDefinitionVo();
0760 final String context = getCurrentContext().getLocationWithinModule();
0761 if (definition.getLatexPattern() != null) {
0762 setLocationWithinModule(context + ".getLatexPattern()");
0763 d.setLatexPattern(definition.getLatexPattern());
0764 }
0765 if (definition.getArgumentNumber() != null) {
0766 setLocationWithinModule(context + ".getArgumentNumber()");
0767 d.setArgumentNumber(definition.getArgumentNumber());
0768 }
0769 if (definition.getName() != null) {
0770 setLocationWithinModule(context + ".getName()");
0771 d.setName(definition.getName());
0772 }
0773 if (definition.getFormula() != null) {
0774 setLocationWithinModule(context + ".getFormula()");
0775 d.setFormula(create(definition.getFormula()));
0776 }
0777 if (definition.getDescription() != null) {
0778 setLocationWithinModule(context + ".getDescription()");
0779 d.setDescription(create(definition.getDescription()));
0780 }
0781 setLocationWithinModule(context);
0782 return d;
0783 }
0784
0785 private final PropositionVo create(final Proposition proposition) {
0786 if (proposition == null) {
0787 return null;
0788 }
0789 final PropositionVo p = new PropositionVo();
0790 final String context = getCurrentContext().getLocationWithinModule();
0791 if (proposition.getFormula() != null) {
0792 setLocationWithinModule(context + ".getFormula()");
0793 p.setFormula(create(proposition.getFormula()));
0794 }
0795 if (proposition.getDescription() != null) {
0796 setLocationWithinModule(context + ".getDescription()");
0797 p.setDescription(create(proposition.getDescription()));
0798 }
0799 if (proposition.getProofList() != null) {
0800 setLocationWithinModule(context + ".getProofList()");
0801 p.setProofList(create(proposition.getProofList()));
0802 }
0803 if (proposition.getFormalProofList() != null) {
0804 setLocationWithinModule(context + ".getFormalProofList()");
0805 p.setFormalProofList(create(proposition.getFormalProofList()));
0806 }
0807 setLocationWithinModule(context);
0808 return p;
0809 }
0810
0811 private final RuleVo create(final Rule rule) {
0812 if (rule == null) {
0813 return null;
0814 }
0815 final RuleVo r = new RuleVo();
0816 final String context = getCurrentContext().getLocationWithinModule();
0817 if (rule.getName() != null) {
0818 setLocationWithinModule(context + ".getName()");
0819 r.setName(rule.getName());
0820 }
0821 if (rule.getVersion() != null) {
0822 setLocationWithinModule(context + ".getVersion()");
0823 r.setVersion(rule.getVersion());
0824 }
0825 if (rule.getLinkList() != null) {
0826 setLocationWithinModule(context + ".getLinkList()");
0827 r.setLinkList(create(rule.getLinkList()));
0828 }
0829 if (rule.getDescription() != null) {
0830 setLocationWithinModule(context + ".getDescription()");
0831 r.setDescription(create(rule.getDescription()));
0832 }
0833 if (rule.getChangedRuleList() != null) {
0834 setLocationWithinModule(context + ".getChangedRuleList()");
0835 r.setChangedRuleList(create(rule.getChangedRuleList()));
0836 }
0837 if (rule.getProofList() != null) {
0838 setLocationWithinModule(context + ".getProofList()");
0839 r.setProofList(create(rule.getProofList()));
0840 }
0841 setLocationWithinModule(context);
0842 return r;
0843 }
0844
0845 private final ChangedRuleListVo create(final ChangedRuleList changedRuleList) {
0846 if (changedRuleList == null) {
0847 return null;
0848 }
0849 final ChangedRuleListVo list = new ChangedRuleListVo();
0850 final String context = getCurrentContext().getLocationWithinModule();
0851 for (int i = 0; i < changedRuleList.size(); i++) {
0852 setLocationWithinModule(context + ".get(" + i + ")");
0853 list.add(create(changedRuleList.get(i)));
0854 }
0855 setLocationWithinModule(context);
0856 return list;
0857 }
0858
0859 private final ChangedRuleVo create(final ChangedRule rule) {
0860 if (rule == null) {
0861 return null;
0862 }
0863 final ChangedRuleVo r = new ChangedRuleVo();
0864 final String context = getCurrentContext().getLocationWithinModule();
0865 if (rule.getName() != null) {
0866 setLocationWithinModule(context + ".getName()");
0867 r.setName(rule.getName());
0868 }
0869 if (rule.getVersion() != null) {
0870 setLocationWithinModule(context + ".getVersion()");
0871 r.setVersion(rule.getVersion());
0872 }
0873 if (rule.getDescription() != null) {
0874 setLocationWithinModule(context + ".getDescription()");
0875 r.setDescription(create(rule.getDescription()));
0876 }
0877 setLocationWithinModule(context);
0878 return r;
0879 }
0880
0881 private final LinkListVo create(final LinkList linkList) {
0882 if (linkList == null) {
0883 return null;
0884 }
0885 final LinkListVo list = new LinkListVo();
0886 final String context = getCurrentContext().getLocationWithinModule();
0887 for (int i = 0; i < linkList.size(); i++) {
0888 setLocationWithinModule(context + ".get(" + i + ")");
0889 list.add(linkList.get(i));
0890 }
0891 setLocationWithinModule(context);
0892 return list;
0893 }
0894
0895 private final ProofListVo create(final ProofList proofList) {
0896 if (proofList == null) {
0897 return null;
0898 }
0899 final ProofListVo list = new ProofListVo();
0900 final String context = getCurrentContext().getLocationWithinModule();
0901 for (int i = 0; i < proofList.size(); i++) {
0902 setLocationWithinModule(context + ".get(" + i + ")");
0903 list.add(create(proofList.get(i)));
0904 }
0905 setLocationWithinModule(context);
0906 return list;
0907 }
0908
0909 private final ProofVo create(final Proof proof) {
0910 if (proof == null) {
0911 return null;
0912 }
0913 final ProofVo p = new ProofVo();
0914 final String context = getCurrentContext().getLocationWithinModule();
0915 setLocationWithinModule(context + ".getKind()");
0916 p.setKind(proof.getKind());
0917 setLocationWithinModule(context + ".getLevel()");
0918 p.setLevel(proof.getLevel());
0919 setLocationWithinModule(context);
0920 if (proof.getNonFormalProof() != null) {
0921 setLocationWithinModule(context + ".getNonFormalProof()");
0922 p.setNonFormalProof(create(proof.getNonFormalProof()));
0923 }
0924 setLocationWithinModule(context);
0925 return p;
0926 }
0927
0928 private final FormalProofListVo create(final FormalProofList proofList) {
0929 if (proofList == null) {
0930 return null;
0931 }
0932 final FormalProofListVo list = new FormalProofListVo();
0933 final String context = getCurrentContext().getLocationWithinModule();
0934 for (int i = 0; i < proofList.size(); i++) {
0935 setLocationWithinModule(context + ".get(" + i + ")");
0936 list.add(create(proofList.get(i)));
0937 }
0938 setLocationWithinModule(context);
0939 return list;
0940 }
0941
0942 private final FormalProofVo create(final FormalProof proof) {
0943 if (proof == null) {
0944 return null;
0945 }
0946 final FormalProofVo p = new FormalProofVo();
0947 final String context = getCurrentContext().getLocationWithinModule();
0948 setLocationWithinModule(context);
0949 if (proof.getPrecedingText() != null) {
0950 setLocationWithinModule(context + ".getPrecedingText()");
0951 p.setPrecedingText(create(proof.getPrecedingText()));
0952 }
0953 if (proof.getFormalProofLineList() != null) {
0954 setLocationWithinModule(context + ".getFormalProofLineList()");
0955 p.setFormalProofLineList(create(proof.getFormalProofLineList()));
0956 }
0957 if (proof.getSucceedingText() != null) {
0958 setLocationWithinModule(context + ".getSucceedingText()");
0959 p.setSucceedingText(create(proof.getSucceedingText()));
0960 }
0961 setLocationWithinModule(context);
0962 return p;
0963 }
0964
0965 private final FormalProofLineListVo create(final FormalProofLineList proofList) {
0966 if (proofList == null) {
0967 return null;
0968 }
0969 final FormalProofLineListVo list = new FormalProofLineListVo();
0970 final String context = getCurrentContext().getLocationWithinModule();
0971 for (int i = 0; i < proofList.size(); i++) {
0972 setLocationWithinModule(context + ".get(" + i + ")");
0973 if (proofList.get(i) instanceof ConditionalProof) {
0974 list.add(create((ConditionalProof) proofList.get(i)));
0975 } else {
0976 list.add(create(proofList.get(i)));
0977 }
0978 }
0979 setLocationWithinModule(context);
0980 return list;
0981 }
0982
0983 private final FormalProofLineVo create(final FormalProofLine proofLine) {
0984 if (proofLine == null) {
0985 return null;
0986 }
0987 final FormalProofLineVo line = new FormalProofLineVo();
0988 final String context = getCurrentContext().getLocationWithinModule();
0989 if (proofLine.getLabel() != null) {
0990 setLocationWithinModule(context + ".getLabel()");
0991 line.setLabel(proofLine.getLabel());
0992 }
0993 if (proofLine.getFormula() != null) {
0994 setLocationWithinModule(context + ".getFormula()");
0995 line.setFormula(create(proofLine.getFormula()));
0996 }
0997 if (proofLine.getReason() != null) {
0998 setLocationWithinModule(context + ".getReason()");
0999 line.setReason(create(proofLine.getReason()));
1000 }
1001 setLocationWithinModule(context);
1002 return line;
1003 }
1004
1005 private final ConditionalProofVo create(final ConditionalProof proofLine) {
1006 if (proofLine == null) {
1007 return null;
1008 }
1009 final ConditionalProofVo line = new ConditionalProofVo();
1010 final String context = getCurrentContext().getLocationWithinModule();
1011 if (proofLine.getHypothesis() != null) {
1012 setLocationWithinModule(context + ".getHypothesis()");
1013 line.setHypothesis(proofLine.getHypothesis());
1014 }
1015 if (proofLine.getFormalProofLineList() != null) {
1016 setLocationWithinModule(context + ".getFormalProofLineList()");
1017 line.setFormalProofLineList(create(proofLine.getFormalProofLineList()));
1018 }
1019 if (proofLine.getConclusion() != null) {
1020 setLocationWithinModule(context + ".getConclusion()");
1021 line.setConclusion(create(proofLine.getConclusion()));
1022 }
1023 setLocationWithinModule(context);
1024 return line;
1025 }
1026
1027 private final Reason create(final Reason reason) {
1028 if (reason == null) {
1029 return null;
1030 }
1031 final String context = getCurrentContext().getLocationWithinModule();
1032 Reason result = null;
1033 if (reason instanceof ModusPonens) {
1034 setLocationWithinModule(context + ".getModusPonens()");
1035 final ModusPonens r = (ModusPonens) reason;
1036 result = new ModusPonensVo(r.getReference1(), r.getReference2());
1037 } else if (reason instanceof Add) {
1038 setLocationWithinModule(context + ".getAdd()");
1039 final Add r = (Add) reason;
1040 result = new AddVo(r.getReference());
1041 } else if (reason instanceof Rename) {
1042 setLocationWithinModule(context + ".getRename()");
1043 final Rename r = (Rename) reason;
1044 result = new RenameVo(r.getReference(), r.getOriginalSubjectVariable(),
1045 r.getReplacementSubjectVariable(), r.getOccurrence());
1046 } else if (reason instanceof SubstFree) {
1047 setLocationWithinModule(context + ".getSubstFree()");
1048 final SubstFree r = (SubstFree) reason;
1049 result = new SubstFreeVo(r.getReference(), r.getSubjectVariable(),
1050 r.getSubstituteTerm());
1051 } else if (reason instanceof SubstFunc) {
1052 setLocationWithinModule(context + ".getSubstFunc()");
1053 final SubstFunc r = (SubstFunc) reason;
1054 result = new SubstFuncVo(r.getReference(), r.getFunctionVariable(),
1055 r.getSubstituteTerm());
1056 } else if (reason instanceof SubstPred) {
1057 setLocationWithinModule(context + ".getSubstPred()");
1058 final SubstPred r = (SubstPred) reason;
1059 result = new SubstPredVo(r.getReference(), r.getPredicateVariable(),
1060 r.getSubstituteFormula());
1061 } else if (reason instanceof Existential) {
1062 setLocationWithinModule(context + ".getExistential()");
1063 final Existential r = (Existential) reason;
1064 result = new ExistentialVo(r.getReference(), r.getSubjectVariable());
1065 } else if (reason instanceof Universal) {
1066 setLocationWithinModule(context + ".getUniversal()");
1067 final Universal r = (Universal) reason;
1068 result = new UniversalVo(r.getReference(), r.getSubjectVariable());
1069 } else if (reason instanceof ConditionalProof) {
1070 setLocationWithinModule(context + ".getConditionalProof()");
1071 final ConditionalProof r = (ConditionalProof) reason;
1072 setLocationWithinModule(context + ".getConditionalProof().getHypothesis()");
1073 final Hypothesis h = create(r.getHypothesis());
1074 setLocationWithinModule(context + ".getConditionalProof().getFormalProofLineList()");
1075 final FormalProofLineList l = create(r.getFormalProofLineList());
1076 setLocationWithinModule(context + ".getConditionalProof().getConclusion()");
1077 final Conclusion c = create(r.getConclusion());
1078 result = new ConditionalProofVo(h, l, c);
1079 } else {
1080 throw new RuntimeException("unknown reason class: " + reason.getClass());
1081 }
1082 setLocationWithinModule(context);
1083 return result;
1084 }
1085
1086 private final HypothesisVo create(final Hypothesis hypothesis) {
1087 if (hypothesis == null) {
1088 return null;
1089 }
1090 final HypothesisVo h = new HypothesisVo();
1091 final String context = getCurrentContext().getLocationWithinModule();
1092 if (hypothesis.getLabel() != null) {
1093 h.setLabel(hypothesis.getLabel());
1094 }
1095 if (hypothesis.getFormula() != null) {
1096 setLocationWithinModule(context + ".getFormula()");
1097 h.setFormula(create(hypothesis.getFormula()));
1098 }
1099 setLocationWithinModule(context);
1100 return h;
1101 }
1102
1103 private final ConclusionVo create(final Conclusion conclusion) {
1104 if (conclusion == null) {
1105 return null;
1106 }
1107 final ConclusionVo c = new ConclusionVo();
1108 final String context = getCurrentContext().getLocationWithinModule();
1109 if (conclusion.getLabel() != null) {
1110 c.setLabel(conclusion.getLabel());
1111 }
1112 if (conclusion.getFormula() != null) {
1113 setLocationWithinModule(context + ".getFormula()");
1114 c.setFormula(create(conclusion.getFormula()));
1115 }
1116 setLocationWithinModule(context);
1117 return c;
1118 }
1119
1120 private final FormulaVo create(final Formula formula) {
1121 if (formula == null) {
1122 return null;
1123 }
1124 final FormulaVo f = new FormulaVo();
1125 final String context = getCurrentContext().getLocationWithinModule();
1126 if (formula.getElement() != null) {
1127 setLocationWithinModule(context + ".getElement()");
1128 f.setElement(create(formula.getElement()));
1129 }
1130 setLocationWithinModule(context);
1131 return f;
1132 }
1133
1134 private final Element create(final Element element) {
1135 if (element == null) {
1136 return null;
1137 }
1138 final Element e;
1139 final String context = getCurrentContext().getLocationWithinModule();
1140 if (element.isList()) {
1141 setLocationWithinModule(context + ".getList()");
1142 e = create(element.getList());
1143 } else if (element.isAtom()) {
1144 // setLocationWithinModule(context + ".getAtom()");
1145 return create(element.getAtom());
1146 } else {
1147 throw new RuntimeException("unknown element type: " + element);
1148 }
1149 setLocationWithinModule(context);
1150 return e;
1151 }
1152
1153
1154 private final DefaultElementList create(final ElementList list) {
1155 if (list == null) {
1156 return null;
1157 }
1158 final DefaultElementList n = new DefaultElementList(list.getOperator(), new Element[] {});
1159 final String context = getCurrentContext().getLocationWithinModule();
1160 for (int i = 0; i < list.size(); i++) {
1161 if (list.getElement(i).isList()) {
1162 setLocationWithinModule(context + ".getElement(" + i + ")");
1163 }
1164 n.add(create(list.getElement(i)));
1165 }
1166 setLocationWithinModule(context);
1167 return n;
1168 }
1169
1170 private final DefaultAtom create(final Atom atom) {
1171 if (atom == null) {
1172 return null;
1173 }
1174 return new DefaultAtom(atom.getString());
1175 }
1176
1177 private final LatexListVo create(final LatexList latexList) {
1178 if (latexList == null) {
1179 return null;
1180 }
1181 final LatexListVo list = new LatexListVo();
1182 final String context = getCurrentContext().getLocationWithinModule();
1183 for (int i = 0; i < latexList.size(); i++) {
1184 setLocationWithinModule(context + ".get(" + i + ")");
1185 list.add(create(latexList.get(i)));
1186 }
1187 setLocationWithinModule(context);
1188 return list;
1189 }
1190
1191 /**
1192 * Creates LaTeX business object.
1193 *
1194 * @param latex LaTeX object.
1195 * @return LaTeX business object.
1196 */
1197 private final LatexVo create(final Latex latex) {
1198 if (latex == null) {
1199 return null;
1200 }
1201 final LatexVo lat = new LatexVo();
1202 lat.setLanguage(latex.getLanguage());
1203 lat.setLatex(latex.getLatex());
1204 return lat;
1205 }
1206
1207 /**
1208 * Set location information where are we within the original module.
1209 *
1210 * @param locationWithinModule Location within module.
1211 */
1212 protected void setLocationWithinModule(final String locationWithinModule) {
1213 getCurrentContext().setLocationWithinModule(locationWithinModule);
1214 }
1215
1216 /**
1217 * Get current context within original.
1218 *
1219 * @return Current context.
1220 */
1221 protected final ModuleContext getCurrentContext() {
1222 return currentContext;
1223 }
1224
1225 /**
1226 * Get original QEDEQ module.
1227 *
1228 * @return Original QEDEQ module.
1229 */
1230 protected final Qedeq getQedeqOriginal() {
1231 return original;
1232 }
1233
1234 }
|