QedeqNotNullTraverser.java
0001 /* This file is part of the project "Hilbert II" - http://www.qedeq.org
0002  *
0003  * Copyright 2000-2014,  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.se.visitor;
0017 
0018 import java.util.HashMap;
0019 import java.util.Map;
0020 import java.util.Stack;
0021 
0022 import org.qedeq.kernel.se.base.list.Atom;
0023 import org.qedeq.kernel.se.base.list.Element;
0024 import org.qedeq.kernel.se.base.list.ElementList;
0025 import org.qedeq.kernel.se.base.module.Add;
0026 import org.qedeq.kernel.se.base.module.Author;
0027 import org.qedeq.kernel.se.base.module.AuthorList;
0028 import org.qedeq.kernel.se.base.module.Axiom;
0029 import org.qedeq.kernel.se.base.module.ChangedRule;
0030 import org.qedeq.kernel.se.base.module.ChangedRuleList;
0031 import org.qedeq.kernel.se.base.module.Chapter;
0032 import org.qedeq.kernel.se.base.module.ChapterList;
0033 import org.qedeq.kernel.se.base.module.Conclusion;
0034 import org.qedeq.kernel.se.base.module.ConditionalProof;
0035 import org.qedeq.kernel.se.base.module.Existential;
0036 import org.qedeq.kernel.se.base.module.FormalProof;
0037 import org.qedeq.kernel.se.base.module.FormalProofLine;
0038 import org.qedeq.kernel.se.base.module.FormalProofLineList;
0039 import org.qedeq.kernel.se.base.module.FormalProofList;
0040 import org.qedeq.kernel.se.base.module.Formula;
0041 import org.qedeq.kernel.se.base.module.FunctionDefinition;
0042 import org.qedeq.kernel.se.base.module.Header;
0043 import org.qedeq.kernel.se.base.module.Hypothesis;
0044 import org.qedeq.kernel.se.base.module.Import;
0045 import org.qedeq.kernel.se.base.module.ImportList;
0046 import org.qedeq.kernel.se.base.module.InitialFunctionDefinition;
0047 import org.qedeq.kernel.se.base.module.InitialPredicateDefinition;
0048 import org.qedeq.kernel.se.base.module.Latex;
0049 import org.qedeq.kernel.se.base.module.LatexList;
0050 import org.qedeq.kernel.se.base.module.LinkList;
0051 import org.qedeq.kernel.se.base.module.LiteratureItem;
0052 import org.qedeq.kernel.se.base.module.LiteratureItemList;
0053 import org.qedeq.kernel.se.base.module.Location;
0054 import org.qedeq.kernel.se.base.module.LocationList;
0055 import org.qedeq.kernel.se.base.module.ModusPonens;
0056 import org.qedeq.kernel.se.base.module.Node;
0057 import org.qedeq.kernel.se.base.module.PredicateDefinition;
0058 import org.qedeq.kernel.se.base.module.Proof;
0059 import org.qedeq.kernel.se.base.module.ProofList;
0060 import org.qedeq.kernel.se.base.module.Proposition;
0061 import org.qedeq.kernel.se.base.module.Qedeq;
0062 import org.qedeq.kernel.se.base.module.Reason;
0063 import org.qedeq.kernel.se.base.module.Rename;
0064 import org.qedeq.kernel.se.base.module.Rule;
0065 import org.qedeq.kernel.se.base.module.Section;
0066 import org.qedeq.kernel.se.base.module.SectionList;
0067 import org.qedeq.kernel.se.base.module.Specification;
0068 import org.qedeq.kernel.se.base.module.Subsection;
0069 import org.qedeq.kernel.se.base.module.SubsectionList;
0070 import org.qedeq.kernel.se.base.module.SubstFree;
0071 import org.qedeq.kernel.se.base.module.SubstFunc;
0072 import org.qedeq.kernel.se.base.module.SubstPred;
0073 import org.qedeq.kernel.se.base.module.Term;
0074 import org.qedeq.kernel.se.base.module.Universal;
0075 import org.qedeq.kernel.se.base.module.UsedByList;
0076 import org.qedeq.kernel.se.common.ModuleAddress;
0077 import org.qedeq.kernel.se.common.ModuleContext;
0078 import org.qedeq.kernel.se.common.ModuleDataException;
0079 import org.qedeq.kernel.se.common.RuleKey;
0080 import org.qedeq.kernel.se.common.ServiceCompleteness;
0081 import org.qedeq.kernel.se.dto.module.FormulaVo;
0082 import org.qedeq.kernel.se.dto.module.TermVo;
0083 
0084 
0085 /**
0086  * Traverse QEDEQ module. Calls visitors of {@link org.qedeq.kernel.se.visitor.QedeqVisitor}
0087  * for non <code>null</code> arguments.
0088  *
0089  @author  Michael Meyling
0090  */
0091 public class QedeqNotNullTraverser implements QedeqTraverser, ServiceCompleteness {
0092 
0093     /** Current context during creation. */
0094     private final ModuleContext currentContext;
0095 
0096     /** Readable traverse location info. */
0097     private final Stack location = new Stack();
0098 
0099     /** Herein are various counters for the current node. */
0100     private QedeqNumbers data = new QedeqNumbers(00);
0101 
0102     /** Converts chapter and other titles into text. */
0103     private final LatexList2Text transform = new LatexList2Text();
0104 
0105     /**
0106      * These methods are called if a node is visited. To start the whole process just call
0107      {@link #accept(Qedeq)}.
0108      */
0109     private QedeqVisitor visitor;
0110 
0111     /** Is sub node traverse currently blocked? */
0112     private boolean blocked;
0113 
0114     /** Currently visited node element of QEDEQ module. Might be <code>null</code>. */
0115     private Node node;
0116 
0117     /** Maps local {@link ruleName}s to local {@link RuleKey}s. */
0118     private Map ruleExistence;
0119 
0120     /**
0121      * Constructor.
0122      *
0123      @param   globalContext   Module location information.
0124      @param   visitor         These methods are called if a node is visited.
0125      */
0126     public QedeqNotNullTraverser(final ModuleAddress globalContext, final QedeqVisitor visitor) {
0127         currentContext = globalContext.createModuleContext();
0128         this.visitor = visitor;
0129     }
0130 
0131     /**
0132      * Constructor.
0133      *
0134      @param   globalContext   Module location information.
0135      */
0136     public QedeqNotNullTraverser(final ModuleAddress globalContext) {
0137         currentContext = globalContext.createModuleContext();
0138     }
0139 
0140     /**
0141      * Set visitor.
0142      *
0143      @param   visitor         These methods are called if a node is visited.
0144      */
0145     public void setVisitor(final QedeqVisitor visitor) {
0146         this.visitor = visitor;
0147     }
0148 
0149     public void accept(final Qedeq qedeqthrows ModuleDataException {
0150         ruleExistence = new HashMap();
0151         setLocation("started");
0152         if (qedeq == null) {
0153             throw new NullPointerException("null QEDEQ module");
0154         }
0155         data = new QedeqNumbers(
0156             (qedeq.getHeader() != null && qedeq.getHeader().getImportList() != null
0157                 ? qedeq.getHeader().getImportList().size() 0),
0158             (qedeq.getChapterList() != null ? qedeq.getChapterList().size() 0)
0159         );
0160         getCurrentContext().setLocationWithinModule("");
0161         checkForInterrupt();
0162         blocked = false;
0163         final String context = getCurrentContext().getLocationWithinModule();
0164         visitor.visitEnter(qedeq);
0165         if (qedeq.getHeader() != null) {
0166             getCurrentContext().setLocationWithinModule(context + "getHeader()");
0167             accept(qedeq.getHeader());
0168         }
0169         if (qedeq.getChapterList() != null) {
0170             getCurrentContext().setLocationWithinModule(context + "getChapterList()");
0171             accept(qedeq.getChapterList());
0172         }
0173         if (qedeq.getLiteratureItemList() != null) {
0174             getCurrentContext().setLocationWithinModule(context + "getLiteratureItemList()");
0175             accept(qedeq.getLiteratureItemList());
0176         }
0177         setLocationWithinModule(context);
0178         visitor.visitLeave(qedeq);
0179         setLocationWithinModule(context);
0180         setLocation("finished");
0181         data.setFinished(true);
0182     }
0183 
0184     /**
0185      * Check if current thread is interrupted.
0186      *
0187      @throws  InterruptException  We were interrupted.
0188      */
0189     private void checkForInterrupt() throws InterruptException {
0190         if (Thread.interrupted()) {
0191             throw new InterruptException(getCurrentContext());
0192         }
0193     }
0194 
0195     public void accept(final Header headerthrows ModuleDataException {
0196         checkForInterrupt();
0197         if (blocked || header == null) {
0198             return;
0199         }
0200         setLocation("analyzing header");
0201         final String context = getCurrentContext().getLocationWithinModule();
0202         visitor.visitEnter(header);
0203         if (header.getSpecification() != null) {
0204             setLocationWithinModule(context + ".getSpecification()");
0205             accept(header.getSpecification());
0206         }
0207         if (header.getTitle() != null) {
0208             setLocationWithinModule(context + ".getTitle()");
0209             accept(header.getTitle());
0210         }
0211         if (header.getSummary() != null) {
0212             setLocationWithinModule(context + ".getSummary()");
0213             accept(header.getSummary());
0214         }
0215         if (header.getAuthorList() != null) {
0216             setLocationWithinModule(context + ".getAuthorList()");
0217             accept(header.getAuthorList());
0218         }
0219         if (header.getImportList() != null) {
0220             setLocationWithinModule(context + ".getImportList()");
0221             accept(header.getImportList());
0222         }
0223         if (header.getUsedByList() != null) {
0224             setLocationWithinModule(context + ".getUsedByList()");
0225             accept(header.getUsedByList());
0226         }
0227         setLocationWithinModule(context);
0228         visitor.visitLeave(header);
0229         setLocationWithinModule(context);
0230     }
0231 
0232     public void accept(final UsedByList usedByListthrows ModuleDataException {
0233         checkForInterrupt();
0234         if (blocked || usedByList == null) {
0235             return;
0236         }
0237         location.push("working on used by list");
0238         final String context = getCurrentContext().getLocationWithinModule();
0239         visitor.visitEnter(usedByList);
0240         for (int i = 0; i < usedByList.size(); i++) {
0241             setLocationWithinModule(context + ".get(" + i + ")");
0242             accept(usedByList.get(i));
0243         }
0244         setLocationWithinModule(context);
0245         visitor.visitLeave(usedByList);
0246         setLocationWithinModule(context);
0247         location.pop();
0248     }
0249 
0250     public void accept(final ImportList importListthrows ModuleDataException {
0251         checkForInterrupt();
0252         if (blocked || importList == null) {
0253             return;
0254         }
0255         location.push("working on import list");
0256         final String context = getCurrentContext().getLocationWithinModule();
0257         visitor.visitEnter(importList);
0258         for (int i = 0; i < importList.size(); i++) {
0259             setLocationWithinModule(context + ".get(" + i + ")");
0260             accept(importList.get(i));
0261         }
0262         setLocationWithinModule(context);
0263         visitor.visitLeave(importList);
0264         setLocationWithinModule(context);
0265         location.pop();
0266     }
0267 
0268     public void accept(final Import impthrows ModuleDataException {
0269         data.increaseImportNumber();
0270         checkForInterrupt();
0271         if (blocked || imp == null) {
0272             return;
0273         }
0274         location.push("import " + data.getImportNumber() ": " + imp.getLabel());
0275         final String context = getCurrentContext().getLocationWithinModule();
0276         visitor.visitEnter(imp);
0277         if (imp.getSpecification() != null) {
0278             setLocationWithinModule(context + ".getSpecification()");
0279             accept(imp.getSpecification());
0280         }
0281         setLocationWithinModule(context);
0282         visitor.visitLeave(imp);
0283         setLocationWithinModule(context);
0284         location.pop();
0285     }
0286 
0287     public void accept(final Specification specificationthrows ModuleDataException {
0288         checkForInterrupt();
0289         if (blocked || specification == null) {
0290             return;
0291         }
0292         final String context = getCurrentContext().getLocationWithinModule();
0293         visitor.visitEnter(specification);
0294         if (specification.getLocationList() != null) {
0295             setLocationWithinModule(context + ".getLocationList()");
0296             accept(specification.getLocationList());
0297         }
0298         setLocationWithinModule(context);
0299         visitor.visitLeave(specification);
0300         setLocationWithinModule(context);
0301     }
0302 
0303     public void accept(final LocationList locationListthrows ModuleDataException {
0304         checkForInterrupt();
0305         if (blocked || locationList == null) {
0306             return;
0307         }
0308         final String context = getCurrentContext().getLocationWithinModule();
0309         visitor.visitEnter(locationList);
0310         for (int i = 0; i < locationList.size(); i++) {
0311             setLocationWithinModule(context + ".get(" + i + ")");
0312             accept(locationList.get(i));
0313         }
0314         setLocationWithinModule(context);
0315         visitor.visitLeave(locationList);
0316         setLocationWithinModule(context);
0317     }
0318 
0319     public void accept(final Location locationthrows ModuleDataException {
0320         checkForInterrupt();
0321         if (blocked || location == null) {
0322             return;
0323         }
0324         final String context = getCurrentContext().getLocationWithinModule();
0325         visitor.visitEnter(location);
0326         setLocationWithinModule(context);
0327         visitor.visitLeave(location);
0328         setLocationWithinModule(context);
0329     }
0330 
0331     public void accept(final AuthorList authorListthrows ModuleDataException {
0332         checkForInterrupt();
0333         if (blocked || authorList == null) {
0334             return;
0335         }
0336         final String context = getCurrentContext().getLocationWithinModule();
0337         visitor.visitEnter(authorList);
0338         for (int i = 0; i < authorList.size(); i++) {
0339             setLocationWithinModule(context + ".get(" + i + ")");
0340             accept(authorList.get(i));
0341         }
0342         setLocationWithinModule(context);
0343         visitor.visitLeave(authorList);
0344         setLocationWithinModule(context);
0345     }
0346 
0347     public void accept(final Author authorthrows ModuleDataException {
0348         checkForInterrupt();
0349         if (blocked || author == null) {
0350             return;
0351         }
0352         final String context = getCurrentContext().getLocationWithinModule();
0353         visitor.visitEnter(author);
0354         if (author.getName() != null) {
0355             setLocationWithinModule(context + ".getName()");
0356             accept(author.getName());
0357         }
0358         setLocationWithinModule(context);
0359         visitor.visitLeave(author);
0360         setLocationWithinModule(context);
0361     }
0362 
0363     public void accept(final ChapterList chapterListthrows ModuleDataException {
0364         checkForInterrupt();
0365         if (blocked || chapterList == null) {
0366             return;
0367         }
0368         final String context = getCurrentContext().getLocationWithinModule();
0369         visitor.visitEnter(chapterList);
0370         for (int i = 0; i < chapterList.size(); i++) {
0371             setLocationWithinModule(context + ".get(" + i + ")");
0372             accept(chapterList.get(i));
0373         }
0374         setLocationWithinModule(context);
0375         visitor.visitLeave(chapterList);
0376         setLocationWithinModule(context);
0377     }
0378 
0379     public void accept(final Chapter chapterthrows ModuleDataException {
0380         checkForInterrupt();
0381         if (blocked || chapter == null) {
0382             return;
0383         }
0384         data.increaseChapterNumber(
0385                 (chapter.getSectionList() != null ? chapter.getSectionList().size() 0),
0386                 chapter.getNoNumber() == null || !chapter.getNoNumber().booleanValue()
0387             );
0388         if (data.isChapterNumbering()) {
0389             setLocation("Chapter " + data.getChapterNumber() " "
0390                 + transform.transform(chapter.getTitle()));
0391         else {
0392             setLocation(transform.transform(chapter.getTitle()));
0393         }
0394         final String context = getCurrentContext().getLocationWithinModule();
0395         visitor.visitEnter(chapter);
0396         if (chapter.getTitle() != null) {
0397             setLocationWithinModule(context + ".getTitle()");
0398             accept(chapter.getTitle());
0399         }
0400         if (chapter.getIntroduction() != null) {
0401             setLocationWithinModule(context + ".getIntroduction()");
0402             accept(chapter.getIntroduction());
0403         }
0404         if (chapter.getSectionList() != null) {
0405             setLocationWithinModule(context + ".getSectionList()");
0406             accept(chapter.getSectionList());
0407         }
0408         setLocationWithinModule(context);
0409         visitor.visitLeave(chapter);
0410         setLocationWithinModule(context);
0411     }
0412 
0413     public void accept(final LiteratureItemList literatureItemList)
0414             throws ModuleDataException {
0415         checkForInterrupt();
0416         if (blocked || literatureItemList == null) {
0417             return;
0418         }
0419         setLocation("working on literature list");
0420         final String context = getCurrentContext().getLocationWithinModule();
0421         visitor.visitEnter(literatureItemList);
0422         for (int i = 0; i < literatureItemList.size(); i++) {
0423             setLocationWithinModule(context + ".get(" + i + ")");
0424             accept(literatureItemList.get(i));
0425         }
0426         setLocationWithinModule(context);
0427         visitor.visitLeave(literatureItemList);
0428         setLocationWithinModule(context);
0429     }
0430 
0431     public void accept(final LiteratureItem itemthrows ModuleDataException {
0432         checkForInterrupt();
0433         if (blocked || item == null) {
0434             return;
0435         }
0436         final String context = getCurrentContext().getLocationWithinModule();
0437         visitor.visitEnter(item);
0438         if (item.getItem() != null) {
0439             setLocationWithinModule(context + ".getItem()");
0440             accept(item.getItem());
0441         }
0442         setLocationWithinModule(context);
0443         visitor.visitLeave(item);
0444         setLocationWithinModule(context);
0445     }
0446 
0447     public void accept(final SectionList sectionListthrows ModuleDataException {
0448         checkForInterrupt();
0449         if (blocked || sectionList == null) {
0450             return;
0451         }
0452         final String context = getCurrentContext().getLocationWithinModule();
0453         visitor.visitEnter(sectionList);
0454         for (int i = 0; i < sectionList.size(); i++) {
0455             setLocationWithinModule(context + ".get(" + i + ")");
0456             accept(sectionList.get(i));
0457         }
0458         setLocationWithinModule(context);
0459         visitor.visitLeave(sectionList);
0460         setLocationWithinModule(context);
0461     }
0462 
0463     public void accept(final Section sectionthrows ModuleDataException {
0464         checkForInterrupt();
0465         if (blocked || section == null) {
0466             return;
0467         }
0468         data.increaseSectionNumber(
0469                 (section.getSubsectionList() != null ? section.getSubsectionList().size() 0),
0470                 section.getNoNumber() == null || !section.getNoNumber().booleanValue()
0471             );
0472         String title = "";
0473         if (data.isChapterNumbering()) {
0474             title += data.getChapterNumber();
0475         }
0476         if (data.isSectionNumbering()) {
0477             title += (title.length() "." ""+ data.getSectionNumber();
0478         }
0479         if (section.getTitle() != null) {
0480             title += " " + transform.transform(section.getTitle());
0481         }
0482         location.push(title);
0483         final String context = getCurrentContext().getLocationWithinModule();
0484         visitor.visitEnter(section);
0485         if (section.getTitle() != null) {
0486             setLocationWithinModule(context + ".getTitle()");
0487             accept(section.getTitle());
0488         }
0489         if (section.getIntroduction() != null) {
0490             setLocationWithinModule(context + ".getIntroduction()");
0491             accept(section.getIntroduction());
0492         }
0493         if (section.getSubsectionList() != null) {
0494             setLocationWithinModule(context + ".getSubsectionList()");
0495             accept(section.getSubsectionList());
0496         }
0497         setLocationWithinModule(context);
0498         visitor.visitLeave(section);
0499         setLocationWithinModule(context);
0500         location.pop();
0501     }
0502 
0503     public void accept(final SubsectionList subsectionListthrows ModuleDataException {
0504         checkForInterrupt();
0505         if (blocked || subsectionList == null) {
0506             return;
0507         }
0508         final String context = getCurrentContext().getLocationWithinModule();
0509         visitor.visitEnter(subsectionList);
0510         for (int i = 0; i < subsectionList.size(); i++) {
0511             setLocationWithinModule(context + ".get(" + i + ")");
0512             // TODO 20130131 m31: variation here hard coded
0513             // 20050608: here the Subsection context is type dependently specified
0514             if (subsectionList.get(iinstanceof Subsection) {
0515                 setLocationWithinModule(context + ".get(" + i + ").getSubsection()");
0516                 accept((SubsectionsubsectionList.get(i));
0517             else if (subsectionList.get(iinstanceof Node) {
0518                 setLocationWithinModule(context + ".get(" + i + ").getNode()");
0519                 accept((NodesubsectionList.get(i));
0520             else if (subsectionList.get(i== null) {
0521                 // ignore
0522             else {
0523                 throw new IllegalArgumentException("unexpected subsection type: "
0524                     + subsectionList.get(i).getClass());
0525             }
0526         }
0527         setLocationWithinModule(context);
0528         visitor.visitLeave(subsectionList);
0529         setLocationWithinModule(context);
0530     }
0531 
0532     public void accept(final Subsection subsectionthrows ModuleDataException {
0533         checkForInterrupt();
0534         if (blocked || subsection == null) {
0535             return;
0536         }
0537         data.increaseSubsectionNumber();
0538         String title = "";
0539         if (data.isChapterNumbering()) {
0540             title += data.getChapterNumber();
0541         }
0542         if (data.isSectionNumbering()) {
0543             title += (title.length() "." ""+ data.getSectionNumber();
0544         }
0545         title += (title.length() "." ""+ data.getSubsectionNumber();
0546         if (subsection.getTitle() != null) {
0547             title += " " + transform.transform(subsection.getTitle());
0548         }
0549         title = title + " [" + subsection.getId() "]";
0550         location.push(title);
0551         final String context = getCurrentContext().getLocationWithinModule();
0552         visitor.visitEnter(subsection);
0553         if (subsection.getTitle() != null) {
0554             setLocationWithinModule(context + ".getTitle()");
0555             accept(subsection.getTitle());
0556         }
0557         if (subsection.getLatex() != null) {
0558             setLocationWithinModule(context + ".getLatex()");
0559             accept(subsection.getLatex());
0560         }
0561         setLocationWithinModule(context);
0562         visitor.visitLeave(subsection);
0563         setLocationWithinModule(context);
0564         location.pop();
0565     }
0566 
0567     public void accept(final Node nodethrows ModuleDataException {
0568         checkForInterrupt();
0569         data.increaseNodeNumber();
0570         if (blocked || node == null) {
0571             return;
0572         }
0573         this.node = node;
0574         String title = "";
0575         if (node.getTitle() != null) {
0576             title = transform.transform(node.getTitle());
0577         }
0578         title = title + " [" + node.getId() "]";
0579         location.push(title);
0580         final String context = getCurrentContext().getLocationWithinModule();
0581         visitor.visitEnter(node);
0582         if (node.getName() != null) {
0583             setLocationWithinModule(context + ".getName()");
0584             accept(node.getName());
0585         }
0586         if (node.getTitle() != null) {
0587             setLocationWithinModule(context + ".getTitle()");
0588             accept(node.getTitle());
0589         }
0590         if (node.getPrecedingText() != null) {
0591             setLocationWithinModule(context + ".getPrecedingText()");
0592             accept(node.getPrecedingText());
0593         }
0594         if (node.getNodeType() != null) {
0595             setLocationWithinModule(context + ".getNodeType()");
0596             if (node.getNodeType() instanceof Axiom) {
0597                 setLocationWithinModule(context + ".getNodeType().getAxiom()");
0598                 accept((Axiomnode.getNodeType());
0599             else if (node.getNodeType() instanceof InitialPredicateDefinition) {
0600                 setLocationWithinModule(context + ".getNodeType().getInitialPredicateDefinition()");
0601                 accept((InitialPredicateDefinitionnode.getNodeType());
0602             else if (node.getNodeType() instanceof PredicateDefinition) {
0603                 setLocationWithinModule(context + ".getNodeType().getPredicateDefinition()");
0604                 accept((PredicateDefinitionnode.getNodeType());
0605             else if (node.getNodeType() instanceof InitialFunctionDefinition) {
0606                 setLocationWithinModule(context + ".getNodeType().getInitialFunctionDefinition()");
0607                 accept((InitialFunctionDefinitionnode.getNodeType());
0608             else if (node.getNodeType() instanceof FunctionDefinition) {
0609                 setLocationWithinModule(context + ".getNodeType().getFunctionDefinition()");
0610                 accept((FunctionDefinitionnode.getNodeType());
0611             else if (node.getNodeType() instanceof Proposition) {
0612                 setLocationWithinModule(context + ".getNodeType().getProposition()");
0613                 accept((Propositionnode.getNodeType());
0614             else if (node.getNodeType() instanceof Rule) {
0615                 setLocationWithinModule(context + ".getNodeType().getRule()");
0616                 accept((Rulenode.getNodeType());
0617             else {
0618                 throw new IllegalArgumentException("unexpected node type: "
0619                     + node.getNodeType().getClass());
0620             }
0621         }
0622         if (node.getSucceedingText() != null) {
0623             setLocationWithinModule(context + ".getSucceedingText()");
0624             accept(node.getSucceedingText());
0625         }
0626         setLocationWithinModule(context);
0627         visitor.visitLeave(node);
0628         setLocationWithinModule(context);
0629         location.pop();
0630         this.node = null;
0631     }
0632 
0633     public void accept(final Axiom axiomthrows ModuleDataException {
0634         checkForInterrupt();
0635         if (blocked || axiom == null) {
0636             return;
0637         }
0638         data.increaseAxiomNumber();
0639         location.set(location.size() 1"Axiom " + data.getAxiomNumber() " "
0640             (Stringlocation.lastElement());
0641         final String context = getCurrentContext().getLocationWithinModule();
0642         visitor.visitEnter(axiom);
0643         if (axiom.getFormula() != null) {
0644             setLocationWithinModule(context + ".getFormula()");
0645             accept(axiom.getFormula());
0646         }
0647         if (axiom.getDescription() != null) {
0648             setLocationWithinModule(context + ".getDescription()");
0649             accept(axiom.getDescription());
0650         }
0651         setLocationWithinModule(context);
0652         visitor.visitLeave(axiom);
0653         setLocationWithinModule(context);
0654     }
0655 
0656     public void accept(final PredicateDefinition definition)
0657             throws ModuleDataException {
0658         checkForInterrupt();
0659         if (blocked || definition == null) {
0660             return;
0661         }
0662         data.increasePredicateDefinitionNumber();
0663         location.set(location.size() 1"Definition " (data.getPredicateDefinitionNumber()
0664              + data.getFunctionDefinitionNumber()) " "
0665              (Stringlocation.lastElement());
0666         final String context = getCurrentContext().getLocationWithinModule();
0667         visitor.visitEnter(definition);
0668         if (definition.getFormula() != null) {
0669             setLocationWithinModule(context + ".getFormula()");
0670             accept(definition.getFormula());
0671         }
0672         if (definition.getDescription() != null) {
0673             setLocationWithinModule(context + ".getDescription()");
0674             accept(definition.getDescription());
0675         }
0676         setLocationWithinModule(context);
0677         visitor.visitLeave(definition);
0678         setLocationWithinModule(context);
0679     }
0680 
0681     public void accept(final InitialPredicateDefinition definition)
0682             throws ModuleDataException {
0683         checkForInterrupt();
0684         if (blocked || definition == null) {
0685             return;
0686         }
0687         data.increasePredicateDefinitionNumber();
0688         location.set(location.size() 1"Definition "
0689                 (data.getPredicateDefinitionNumber() + data
0690                         .getFunctionDefinitionNumber()) " "
0691                 (Stringlocation.lastElement());
0692         final String context = getCurrentContext().getLocationWithinModule();
0693         visitor.visitEnter(definition);
0694         if (definition.getPredCon() != null) {
0695             setLocationWithinModule(context + ".getPredCon()");
0696             accept(definition.getPredCon());
0697         }
0698         if (definition.getDescription() != null) {
0699             setLocationWithinModule(context + ".getDescription()");
0700             accept(definition.getDescription());
0701         }
0702         setLocationWithinModule(context);
0703         visitor.visitLeave(definition);
0704         setLocationWithinModule(context);
0705     }
0706 
0707     public void accept(final InitialFunctionDefinition definitionthrows ModuleDataException {
0708         checkForInterrupt();
0709         if (blocked || definition == null) {
0710             return;
0711         }
0712         data.increaseFunctionDefinitionNumber();
0713         location.set(location.size() 1"Definition " (data.getFunctionDefinitionNumber()
0714                 + data.getFunctionDefinitionNumber()) " "
0715                 (Stringlocation.lastElement());
0716         final String context = getCurrentContext().getLocationWithinModule();
0717         visitor.visitEnter(definition);
0718         if (definition.getFunCon() != null) {
0719             setLocationWithinModule(context + ".getFunCon()");
0720             accept(definition.getFunCon());
0721         }
0722         if (definition.getDescription() != null) {
0723             setLocationWithinModule(context + ".getDescription()");
0724             accept(definition.getDescription());
0725         }
0726         setLocationWithinModule(context);
0727         visitor.visitLeave(definition);
0728         setLocationWithinModule(context);
0729     }
0730 
0731     public void accept(final FunctionDefinition definitionthrows ModuleDataException {
0732         checkForInterrupt();
0733         if (blocked || definition == null) {
0734             return;
0735         }
0736         data.increaseFunctionDefinitionNumber();
0737         location.set(location.size() 1"Definition " (data.getFunctionDefinitionNumber()
0738                 + data.getFunctionDefinitionNumber()) " "
0739                 (Stringlocation.lastElement());
0740         final String context = getCurrentContext().getLocationWithinModule();
0741         visitor.visitEnter(definition);
0742         if (definition.getFormula() != null) {
0743             setLocationWithinModule(context + ".getFormula()");
0744             accept(definition.getFormula());
0745         }
0746         if (definition.getDescription() != null) {
0747             setLocationWithinModule(context + ".getDescription()");
0748             accept(definition.getDescription());
0749         }
0750         setLocationWithinModule(context);
0751         visitor.visitLeave(definition);
0752         setLocationWithinModule(context);
0753     }
0754 
0755     public void accept(final Proposition propositionthrows ModuleDataException {
0756         checkForInterrupt();
0757         if (blocked || proposition == null) {
0758             return;
0759         }
0760         data.increasePropositionNumber();
0761         location.set(location.size() 1"Proposition " + data.getPropositionNumber() " "
0762                 (Stringlocation.lastElement());
0763         final String context = getCurrentContext().getLocationWithinModule();
0764         visitor.visitEnter(proposition);
0765         if (proposition.getFormula() != null) {
0766             setLocationWithinModule(context + ".getFormula()");
0767             accept(proposition.getFormula());
0768         }
0769         if (proposition.getDescription() != null) {
0770             setLocationWithinModule(context + ".getDescription()");
0771             accept(proposition.getDescription());
0772         }
0773         if (proposition.getProofList() != null) {
0774             setLocationWithinModule(context + ".getProofList()");
0775             accept(proposition.getProofList());
0776         }
0777         if (proposition.getFormalProofList() != null) {
0778             setLocationWithinModule(context + ".getFormalProofList()");
0779             accept(proposition.getFormalProofList());
0780         }
0781         setLocationWithinModule(context);
0782         visitor.visitLeave(proposition);
0783         setLocationWithinModule(context);
0784     }
0785 
0786     public void accept(final Rule rulethrows ModuleDataException {
0787         checkForInterrupt();
0788         if (blocked || rule == null) {
0789             return;
0790         }
0791         data.increaseRuleNumber();
0792         location.set(location.size() 1"Rule " + data.getRuleNumber() " "
0793                 (Stringlocation.lastElement());
0794         final String context = getCurrentContext().getLocationWithinModule();
0795         visitor.visitEnter(rule);
0796         if (rule.getLinkList() != null) {
0797             setLocationWithinModule(context + ".getLinkList()");
0798             accept(rule.getLinkList());
0799         }
0800         if (rule.getDescription() != null) {
0801             setLocationWithinModule(context + ".getDescription()");
0802             accept(rule.getDescription());
0803         }
0804         if (rule.getChangedRuleList() != null) {
0805             setLocationWithinModule(context + ".getChangedRuleList()");
0806             accept(rule.getChangedRuleList());
0807         }
0808         if (rule.getProofList() != null) {
0809             setLocationWithinModule(context + ".getProofList()");
0810             accept(rule.getProofList());
0811         }
0812         setLocationWithinModule(context);
0813         visitor.visitLeave(rule);
0814         setLocationWithinModule(context);
0815         final RuleKey newRuleKey = new RuleKey(rule.getName(), rule.getVersion());
0816         ruleExistence.put(rule.getName(), newRuleKey);
0817     }
0818 
0819     public void accept(final ChangedRuleList listthrows ModuleDataException {
0820         checkForInterrupt();
0821         if (blocked || list == null) {
0822             return;
0823         }
0824         final String context = getCurrentContext().getLocationWithinModule();
0825         visitor.visitEnter(list);
0826         setLocationWithinModule(context);
0827         for (int i = 0; i < list.size(); i++) {
0828             setLocationWithinModule(context + ".get(" + i + ")");
0829             accept(list.get(i));
0830         }
0831         setLocationWithinModule(context);
0832         visitor.visitLeave(list);
0833         setLocationWithinModule(context);
0834     }
0835 
0836     public void accept(final ChangedRule rulethrows ModuleDataException {
0837         checkForInterrupt();
0838         if (blocked || rule == null) {
0839             return;
0840         }
0841         data.increaseRuleNumber();
0842         location.set(location.size() 1"Rule " + data.getRuleNumber() " "
0843                 (Stringlocation.lastElement());
0844         final String context = getCurrentContext().getLocationWithinModule();
0845         visitor.visitEnter(rule);
0846         if (rule.getDescription() != null) {
0847             setLocationWithinModule(context + ".getDescription()");
0848             accept(rule.getDescription());
0849         }
0850         setLocationWithinModule(context);
0851         visitor.visitLeave(rule);
0852         setLocationWithinModule(context);
0853         final RuleKey newRuleKey = new RuleKey(rule.getName(), rule.getVersion());
0854         ruleExistence.put(rule.getName(), newRuleKey);
0855     }
0856 
0857     public void accept(final LinkList linkListthrows ModuleDataException {
0858         checkForInterrupt();
0859         if (blocked || linkList == null) {
0860             return;
0861         }
0862         final String context = getCurrentContext().getLocationWithinModule();
0863         visitor.visitEnter(linkList);
0864         setLocationWithinModule(context);
0865         visitor.visitLeave(linkList);
0866         setLocationWithinModule(context);
0867     }
0868 
0869     public void accept(final ProofList proofListthrows ModuleDataException {
0870         checkForInterrupt();
0871         if (blocked || proofList == null) {
0872             return;
0873         }
0874         final String context = getCurrentContext().getLocationWithinModule();
0875         visitor.visitEnter(proofList);
0876         for (int i = 0; i < proofList.size(); i++) {
0877             setLocationWithinModule(context + ".get(" + i + ")");
0878             accept(proofList.get(i));
0879         }
0880         setLocationWithinModule(context);
0881         visitor.visitLeave(proofList);
0882         setLocationWithinModule(context);
0883     }
0884 
0885     public void accept(final Proof proofthrows ModuleDataException {
0886         checkForInterrupt();
0887         if (blocked || proof == null) {
0888             return;
0889         }
0890         final String context = getCurrentContext().getLocationWithinModule();
0891         visitor.visitEnter(proof);
0892         if (proof.getNonFormalProof() != null) {
0893             setLocationWithinModule(context + ".getNonFormalProof()");
0894             accept(proof.getNonFormalProof());
0895         }
0896         setLocationWithinModule(context);
0897         visitor.visitLeave(proof);
0898         setLocationWithinModule(context);
0899     }
0900 
0901     public void accept(final FormalProofList proofListthrows ModuleDataException {
0902         checkForInterrupt();
0903         if (blocked || proofList == null) {
0904             return;
0905         }
0906         final String context = getCurrentContext().getLocationWithinModule();
0907         visitor.visitEnter(proofList);
0908         for (int i = 0; i < proofList.size(); i++) {
0909             setLocationWithinModule(context + ".get(" + i + ")");
0910             accept(proofList.get(i));
0911         }
0912         setLocationWithinModule(context);
0913         visitor.visitLeave(proofList);
0914         setLocationWithinModule(context);
0915     }
0916 
0917     public void accept(final FormalProof proofthrows ModuleDataException {
0918         checkForInterrupt();
0919         if (blocked || proof == null) {
0920             return;
0921         }
0922         final String context = getCurrentContext().getLocationWithinModule();
0923         visitor.visitEnter(proof);
0924         if (proof.getPrecedingText() != null) {
0925             setLocationWithinModule(context + ".getPrecedingText()");
0926             accept(proof.getFormalProofLineList());
0927         }
0928         if (proof.getFormalProofLineList() != null) {
0929             setLocationWithinModule(context + ".getFormalProofLineList()");
0930             accept(proof.getFormalProofLineList());
0931         }
0932         if (proof.getSucceedingText() != null) {
0933             setLocationWithinModule(context + ".getSucceedingText()");
0934             accept(proof.getFormalProofLineList());
0935         }
0936         setLocationWithinModule(context);
0937         visitor.visitLeave(proof);
0938         setLocationWithinModule(context);
0939     }
0940 
0941     public void accept(final FormalProofLineList proofLineListthrows ModuleDataException {
0942         checkForInterrupt();
0943         if (blocked || proofLineList == null) {
0944             return;
0945         }
0946         final String context = getCurrentContext().getLocationWithinModule();
0947         visitor.visitEnter(proofLineList);
0948         for (int i = 0; i < proofLineList.size(); i++) {
0949             setLocationWithinModule(context + ".get(" + i + ")");
0950             if (proofLineList.get(iinstanceof ConditionalProof) {
0951                 accept((ConditionalProofproofLineList.get(i));
0952             else {
0953                 accept(proofLineList.get(i));
0954             }
0955         }
0956         setLocationWithinModule(context);
0957         visitor.visitLeave(proofLineList);
0958         setLocationWithinModule(context);
0959     }
0960 
0961     public void accept(final FormalProofLine proofLinethrows ModuleDataException {
0962         checkForInterrupt();
0963         if (blocked || proofLine == null) {
0964             return;
0965         }
0966         final String context = getCurrentContext().getLocationWithinModule();
0967         visitor.visitEnter(proofLine);
0968         if (proofLine.getFormula() != null) {
0969             setLocationWithinModule(context + ".getFormula()");
0970             accept(proofLine.getFormula());
0971         }
0972         if (proofLine.getReason() != null) {
0973             setLocationWithinModule(context + ".getReason()");
0974             accept(proofLine.getReason());
0975         }
0976         setLocationWithinModule(context);
0977         visitor.visitLeave(proofLine);
0978         setLocationWithinModule(context);
0979     }
0980 
0981     public void accept(final Reason reasonthrows ModuleDataException {
0982         checkForInterrupt();
0983         if (blocked || reason == null) {
0984             return;
0985         }
0986         final String context = getCurrentContext().getLocationWithinModule();
0987         visitor.visitEnter(reason);
0988         if (reason instanceof ModusPonens) {
0989             setLocationWithinModule(context + ".getModusPonens()");
0990             accept(((ModusPonensreason).getModusPonens());
0991         else if (reason instanceof Add) {
0992             setLocationWithinModule(context + ".getAdd()");
0993             accept(((Addreason).getAdd());
0994         else if (reason instanceof Rename) {
0995             setLocationWithinModule(context + ".getRename()");
0996             accept(((Renamereason).getRename());
0997         else if (reason instanceof SubstFree) {
0998             setLocationWithinModule(context + ".getSubstFree()");
0999             accept(((SubstFreereason).getSubstFree());
1000         else if (reason instanceof SubstFunc) {
1001             setLocationWithinModule(context + ".getSubstFunc()");
1002             accept(((SubstFuncreason).getSubstFunc());
1003         else if (reason instanceof SubstPred) {
1004             setLocationWithinModule(context + ".getSubstPred()");
1005             accept(((SubstPredreason).getSubstPred());
1006         else if (reason instanceof Existential) {
1007             setLocationWithinModule(context + ".getExistential()");
1008             accept(((Existentialreason).getExistential());
1009         else if (reason instanceof Universal) {
1010             setLocationWithinModule(context + ".getUniversal()");
1011             accept(((Universalreason).getUniversal());
1012         else if (reason instanceof ConditionalProof) {
1013             throw new IllegalArgumentException(
1014                 "proof line shall not have a conditional proof as a reason, instead the proof line "
1015                 "itself should be the conditional proof!");
1016         else {
1017             throw new IllegalArgumentException("unexpected reason type: "
1018                 + reason.getClass());
1019         }
1020         setLocationWithinModule(context);
1021         visitor.visitLeave(reason);
1022         setLocationWithinModule(context);
1023     }
1024 
1025     public void accept(final ModusPonens reasonthrows ModuleDataException {
1026         checkForInterrupt();
1027         if (blocked || reason == null) {
1028             return;
1029         }
1030         final String context = getCurrentContext().getLocationWithinModule();
1031         visitor.visitEnter(reason);
1032         setLocationWithinModule(context);
1033         visitor.visitLeave(reason);
1034         setLocationWithinModule(context);
1035     }
1036 
1037     public void accept(final Add reasonthrows ModuleDataException {
1038         checkForInterrupt();
1039         if (blocked || reason == null) {
1040             return;
1041         }
1042         final String context = getCurrentContext().getLocationWithinModule();
1043         visitor.visitEnter(reason);
1044         setLocationWithinModule(context);
1045         visitor.visitLeave(reason);
1046         setLocationWithinModule(context);
1047     }
1048 
1049     public void accept(final Rename reasonthrows ModuleDataException {
1050         checkForInterrupt();
1051         if (blocked || reason == null) {
1052             return;
1053         }
1054         final String context = getCurrentContext().getLocationWithinModule();
1055         visitor.visitEnter(reason);
1056         if (reason.getOriginalSubjectVariable() != null) {
1057             setLocationWithinModule(context + ".getOriginalSubjectVariable()");
1058             accept(reason.getOriginalSubjectVariable());
1059         }
1060         if (reason.getReplacementSubjectVariable() != null) {
1061             setLocationWithinModule(context + ".getReplacementSubjectVariable()");
1062             accept(reason.getReplacementSubjectVariable());
1063         }
1064         setLocationWithinModule(context);
1065         visitor.visitLeave(reason);
1066         setLocationWithinModule(context);
1067     }
1068 
1069     public void accept(final SubstFree reasonthrows ModuleDataException {
1070         checkForInterrupt();
1071         if (blocked || reason == null) {
1072             return;
1073         }
1074         final String context = getCurrentContext().getLocationWithinModule();
1075         visitor.visitEnter(reason);
1076         if (reason.getSubjectVariable() != null) {
1077             setLocationWithinModule(context + ".getSubjectVariable()");
1078             accept(reason.getSubjectVariable());
1079         }
1080         if (reason.getSubstituteTerm() != null) {
1081             setLocationWithinModule(context + ".getSubstituteTerm()");
1082             accept(new TermVo(reason.getSubstituteTerm()));
1083         }
1084         setLocationWithinModule(context);
1085         visitor.visitLeave(reason);
1086         setLocationWithinModule(context);
1087     }
1088 
1089     public void accept(final SubstFunc reasonthrows ModuleDataException {
1090         checkForInterrupt();
1091         if (blocked || reason == null) {
1092             return;
1093         }
1094         final String context = getCurrentContext().getLocationWithinModule();
1095         visitor.visitEnter(reason);
1096         if (reason.getFunctionVariable() != null) {
1097             setLocationWithinModule(context + ".getFunctionVariable()");
1098             accept(reason.getFunctionVariable());
1099         }
1100         if (reason.getSubstituteTerm() != null) {
1101             setLocationWithinModule(context + ".getSubstituteTerm()");
1102             accept(new TermVo(reason.getSubstituteTerm()));
1103         }
1104         setLocationWithinModule(context);
1105         visitor.visitLeave(reason);
1106         setLocationWithinModule(context);
1107     }
1108 
1109     public void accept(final SubstPred reasonthrows ModuleDataException {
1110         checkForInterrupt();
1111         if (blocked || reason == null) {
1112             return;
1113         }
1114         final String context = getCurrentContext().getLocationWithinModule();
1115         visitor.visitEnter(reason);
1116         if (reason.getPredicateVariable() != null) {
1117             setLocationWithinModule(context + ".getPredicateVariable()");
1118             accept(reason.getPredicateVariable());
1119         }
1120         if (reason.getSubstituteFormula() != null) {
1121             setLocationWithinModule(context + ".getSubstituteFormula()");
1122             accept(new FormulaVo(reason.getSubstituteFormula()));
1123         }
1124         setLocationWithinModule(context);
1125         visitor.visitLeave(reason);
1126         setLocationWithinModule(context);
1127     }
1128 
1129     public void accept(final Existential reasonthrows ModuleDataException {
1130         checkForInterrupt();
1131         if (blocked || reason == null) {
1132             return;
1133         }
1134         final String context = getCurrentContext().getLocationWithinModule();
1135         visitor.visitEnter(reason);
1136         if (reason.getSubjectVariable() != null) {
1137             setLocationWithinModule(context + ".getSubjectVariable()");
1138             accept(reason.getSubjectVariable());
1139         }
1140         setLocationWithinModule(context);
1141         visitor.visitLeave(reason);
1142         setLocationWithinModule(context);
1143     }
1144 
1145     public void accept(final Universal reasonthrows ModuleDataException {
1146         checkForInterrupt();
1147         if (blocked || reason == null) {
1148             return;
1149         }
1150         final String context = getCurrentContext().getLocationWithinModule();
1151         visitor.visitEnter(reason);
1152         if (reason.getSubjectVariable() != null) {
1153             setLocationWithinModule(context + ".getSubjectVariable()");
1154             accept(reason.getSubjectVariable());
1155         }
1156         setLocationWithinModule(context);
1157         visitor.visitLeave(reason);
1158         setLocationWithinModule(context);
1159     }
1160 
1161     public void accept(final ConditionalProof reasonthrows ModuleDataException {
1162         checkForInterrupt();
1163         if (blocked || reason == null) {
1164             return;
1165         }
1166         final String context = getCurrentContext().getLocationWithinModule();
1167         visitor.visitEnter(reason);
1168         if (reason.getHypothesis() != null) {
1169             setLocationWithinModule(context + ".getHypothesis()");
1170             accept(reason.getHypothesis());
1171         }
1172         if (reason.getFormalProofLineList() != null) {
1173             setLocationWithinModule(context + ".getFormalProofLineList()");
1174             accept(reason.getFormalProofLineList());
1175         }
1176         if (reason.getConclusion() != null) {
1177             setLocationWithinModule(context + ".getConclusion()");
1178             accept(reason.getConclusion());
1179         }
1180         setLocationWithinModule(context);
1181         visitor.visitLeave(reason);
1182         setLocationWithinModule(context);
1183     }
1184 
1185     public void accept(final Hypothesis hypothesisthrows ModuleDataException {
1186         checkForInterrupt();
1187         if (blocked || hypothesis == null) {
1188             return;
1189         }
1190         final String context = getCurrentContext().getLocationWithinModule();
1191         visitor.visitEnter(hypothesis);
1192         if (hypothesis.getFormula() != null) {
1193             setLocationWithinModule(context + ".getFormula()");
1194             accept(hypothesis.getFormula());
1195         }
1196         setLocationWithinModule(context);
1197         visitor.visitLeave(hypothesis);
1198         setLocationWithinModule(context);
1199     }
1200 
1201     public void accept(final Conclusion conclusionthrows ModuleDataException {
1202         checkForInterrupt();
1203         if (blocked || conclusion == null) {
1204             return;
1205         }
1206         final String context = getCurrentContext().getLocationWithinModule();
1207         visitor.visitEnter(conclusion);
1208         if (conclusion.getFormula() != null) {
1209             setLocationWithinModule(context + ".getFormula()");
1210             accept(conclusion.getFormula());
1211         }
1212         setLocationWithinModule(context);
1213         visitor.visitLeave(conclusion);
1214         setLocationWithinModule(context);
1215     }
1216 
1217     public void accept(final Formula formulathrows ModuleDataException {
1218         checkForInterrupt();
1219         if (blocked || formula == null) {
1220             return;
1221         }
1222         final String context = getCurrentContext().getLocationWithinModule();
1223         visitor.visitEnter(formula);
1224         if (formula.getElement() != null) {
1225             setLocationWithinModule(context + ".getElement()");
1226             accept(formula.getElement());
1227         }
1228         setLocationWithinModule(context);
1229         visitor.visitLeave(formula);
1230         setLocationWithinModule(context);
1231     }
1232 
1233     public void accept(final Term termthrows ModuleDataException {
1234         checkForInterrupt();
1235         if (blocked || term == null) {
1236             return;
1237         }
1238         final String context = getCurrentContext().getLocationWithinModule();
1239         visitor.visitEnter(term);
1240         if (term.getElement() != null) {
1241             setLocationWithinModule(context + ".getElement()");
1242             accept(term.getElement());
1243         }
1244         setLocationWithinModule(context);
1245         visitor.visitLeave(term);
1246         setLocationWithinModule(context);
1247     }
1248 
1249     public void accept(final Element elementthrows ModuleDataException {
1250         checkForInterrupt();
1251         if (blocked || element == null) {
1252             return;
1253         }
1254         final String context = getCurrentContext().getLocationWithinModule();
1255         if (element.isList()) {
1256             setLocationWithinModule(context + ".getList()");
1257             accept(element.getList());
1258         else if (element.isAtom()) {
1259             setLocationWithinModule(context + ".getAtom()");
1260             accept(element.getAtom());
1261         else {
1262             throw new IllegalArgumentException("unexpected element type: "
1263                 + element.toString());
1264         }
1265         setLocationWithinModule(context);
1266     }
1267 
1268     public void accept(final Atom atomthrows ModuleDataException {
1269         checkForInterrupt();
1270         if (blocked || atom == null) {
1271             return;
1272         }
1273         final String context = getCurrentContext().getLocationWithinModule();
1274         visitor.visitEnter(atom);
1275         setLocationWithinModule(context);
1276         visitor.visitLeave(atom);
1277         setLocationWithinModule(context);
1278     }
1279 
1280     public void accept(final ElementList listthrows ModuleDataException {
1281         checkForInterrupt();
1282         if (blocked || list == null) {
1283             return;
1284         }
1285         final String context = getCurrentContext().getLocationWithinModule();
1286         visitor.visitEnter(list);
1287         for (int i = 0; i < list.size(); i++) {
1288             setLocationWithinModule(context + ".getElement(" + i + ")");
1289             accept(list.getElement(i));
1290         }
1291         setLocationWithinModule(context);
1292         visitor.visitLeave(list);
1293         setLocationWithinModule(context);
1294     }
1295 
1296     public void accept(final LatexList latexListthrows ModuleDataException {
1297         checkForInterrupt();
1298         if (blocked || latexList == null) {
1299             return;
1300         }
1301         final String context = getCurrentContext().getLocationWithinModule();
1302         visitor.visitEnter(latexList);
1303         for (int i = 0; i < latexList.size(); i++) {
1304             setLocationWithinModule(context + ".get(" + i + ")");
1305             accept(latexList.get(i));
1306         }
1307         setLocationWithinModule(context);
1308         visitor.visitLeave(latexList);
1309         setLocationWithinModule(context);
1310     }
1311 
1312     public void accept(final Latex latexthrows ModuleDataException {
1313         checkForInterrupt();
1314         if (blocked || latex == null) {
1315             return;
1316         }
1317         final String context = getCurrentContext().getLocationWithinModule();
1318         visitor.visitEnter(latex);
1319         setLocationWithinModule(context);
1320         visitor.visitLeave(latex);
1321         setLocationWithinModule(context);
1322     }
1323 
1324     /**
1325      * Get node that is currently parsed. Might be <code>null</code>.
1326      *
1327      @return  QEDEQ node were are currently in.
1328      */
1329     public Node getNode() {
1330         return node;
1331     }
1332 
1333     /**
1334      * Set location information where are we within the original module.
1335      *
1336      @param   locationWithinModule    Location within module.
1337      */
1338     public void setLocationWithinModule(final String locationWithinModule) {
1339         getCurrentContext().setLocationWithinModule(locationWithinModule);
1340     }
1341 
1342     public final ModuleContext getCurrentContext() {
1343         return currentContext;
1344     }
1345 
1346     /**
1347      * Is further traversing blocked?
1348      *
1349      @return  Is further traversing blocked?
1350      */
1351     public final boolean getBlocked() {
1352         return blocked;
1353     }
1354 
1355     /**
1356      * Set if further traverse is blocked.
1357      *
1358      @param   blocked Further transversion?
1359      */
1360     public final void setBlocked(final boolean blocked) {
1361         this.blocked = blocked;
1362     }
1363 
1364     /**
1365      * Get calculated visit percentage.
1366      *
1367      @return  Value between 0 and 100.
1368      */
1369     public double getVisitPercentage() {
1370         if (data == null) {
1371             return 0;
1372         }
1373         return data.getVisitPercentage();
1374     }
1375 
1376     /**
1377      * Set absolute location description.
1378      *
1379      @param   text    Description.
1380      */
1381     private void setLocation(final String text) {
1382         location.setSize(0);
1383         location.push(text);
1384     }
1385 
1386     public String getLocationDescription() {
1387         final StringBuffer buffer = new StringBuffer();
1388         for (int i = 0; i < location.size(); i++) {
1389             if (i > 0) {
1390                 buffer.append(" / ");
1391             }
1392             buffer.append(location.get(i));
1393         }
1394         return buffer.toString();
1395     }
1396 
1397     /**
1398      * Get copy of current counters.
1399      *
1400      @return  Values of various counters.
1401      */
1402     public QedeqNumbers getCurrentNumbers() {
1403         return new QedeqNumbers(data);
1404     }
1405 
1406     /**
1407      * Get current (QEDEQ module local) rule version for given rule name.
1408      *
1409      @param   name    Rule name
1410      @return  Current (local) rule version. Might be <code>null</code>.
1411      */
1412     public RuleKey getLocalRuleKey(final String name) {
1413         return (RuleKeyruleExistence.get(name);
1414     }
1415 
1416 }