Clover coverage report - QedeqKernelSe Coverage Report
Coverage timestamp: So Mrz 11 2007 07:05:19 CET
file stats: LOC: 785   Methods: 40
NCLOC: 678   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
QedeqNotNullTransverser.java 77,7% 93,8% 97,5% 89,2%
coverage coverage
 1    /* $Id: QedeqNotNullTransverser.java,v 1.2 2007/02/25 20:05:36 m31 Exp $
 2    *
 3    * This file is part of the project "Hilbert II" - http://www.qedeq.org
 4    *
 5    * Copyright 2000-2007, Michael Meyling <mime@qedeq.org>.
 6    *
 7    * "Hilbert II" is free software; you can redistribute
 8    * it and/or modify it under the terms of the GNU General Public
 9    * License as published by the Free Software Foundation; either
 10    * version 2 of the License, or (at your option) any later version.
 11    *
 12    * This program is distributed in the hope that it will be useful,
 13    * but WITHOUT ANY WARRANTY; without even the implied warranty of
 14    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 15    * GNU General Public License for more details.
 16    */
 17   
 18    package org.qedeq.kernel.bo.visitor;
 19   
 20    import org.qedeq.kernel.base.list.Atom;
 21    import org.qedeq.kernel.base.list.Element;
 22    import org.qedeq.kernel.base.list.ElementList;
 23    import org.qedeq.kernel.base.module.Author;
 24    import org.qedeq.kernel.base.module.AuthorList;
 25    import org.qedeq.kernel.base.module.Axiom;
 26    import org.qedeq.kernel.base.module.Chapter;
 27    import org.qedeq.kernel.base.module.ChapterList;
 28    import org.qedeq.kernel.base.module.Formula;
 29    import org.qedeq.kernel.base.module.FunctionDefinition;
 30    import org.qedeq.kernel.base.module.Header;
 31    import org.qedeq.kernel.base.module.Import;
 32    import org.qedeq.kernel.base.module.ImportList;
 33    import org.qedeq.kernel.base.module.Latex;
 34    import org.qedeq.kernel.base.module.LatexList;
 35    import org.qedeq.kernel.base.module.LinkList;
 36    import org.qedeq.kernel.base.module.LiteratureItem;
 37    import org.qedeq.kernel.base.module.LiteratureItemList;
 38    import org.qedeq.kernel.base.module.Location;
 39    import org.qedeq.kernel.base.module.LocationList;
 40    import org.qedeq.kernel.base.module.Node;
 41    import org.qedeq.kernel.base.module.PredicateDefinition;
 42    import org.qedeq.kernel.base.module.Proof;
 43    import org.qedeq.kernel.base.module.ProofList;
 44    import org.qedeq.kernel.base.module.Proposition;
 45    import org.qedeq.kernel.base.module.Qedeq;
 46    import org.qedeq.kernel.base.module.Rule;
 47    import org.qedeq.kernel.base.module.Section;
 48    import org.qedeq.kernel.base.module.SectionList;
 49    import org.qedeq.kernel.base.module.Specification;
 50    import org.qedeq.kernel.base.module.Subsection;
 51    import org.qedeq.kernel.base.module.SubsectionList;
 52    import org.qedeq.kernel.base.module.Term;
 53    import org.qedeq.kernel.base.module.UsedByList;
 54    import org.qedeq.kernel.base.module.VariableList;
 55    import org.qedeq.kernel.bo.module.ModuleDataException;
 56    import org.qedeq.kernel.context.ModuleContext;
 57   
 58   
 59    /**
 60    * Traverse QEDEQ module. Calls visitors of {@link org.qedeq.kernel.bo.visitor.QedeqVisitor}
 61    * for non <code>null</code> arguments.
 62    *
 63    * @version $Revision: 1.2 $
 64    * @author Michael Meyling
 65    */
 66    public class QedeqNotNullTransverser implements QedeqTransverser {
 67   
 68    /** Current context during creation. */
 69    private ModuleContext currentContext;
 70   
 71    /**
 72    * These methods are called if a node is visited. To start the whole process just call
 73    * {@link #accept(Qedeq)}.
 74    */
 75    private QedeqVisitor visitor;
 76   
 77    /** Is sub node traversion currently blocked? */
 78    private boolean blocked;
 79   
 80    /**
 81    * Constructor.
 82    *
 83    * @param globalContext Module location information.
 84    * @param visitor These methods are called if a node is visited.
 85    */
 86  26751 public QedeqNotNullTransverser(final String globalContext, final QedeqVisitor visitor) {
 87  26751 currentContext = new ModuleContext(globalContext);
 88  26751 this.visitor = visitor;
 89    }
 90   
 91   
 92  26749 public void accept(final Qedeq qedeq) throws ModuleDataException {
 93  26749 getCurrentContext().setLocationWithinModule("");
 94  26749 blocked = false;
 95  26749 if (qedeq == null) {
 96  0 return;
 97    }
 98  26749 final String context = getCurrentContext().getLocationWithinModule();
 99  26749 visitor.visitEnter(qedeq);
 100  26747 if (qedeq.getHeader() != null) {
 101  26747 getCurrentContext().setLocationWithinModule(context + "getHeader()");
 102  26747 accept(qedeq.getHeader());
 103    }
 104  26283 if (qedeq.getChapterList() != null) {
 105  26283 getCurrentContext().setLocationWithinModule(context + "getChapterList()");
 106  26283 accept(qedeq.getChapterList());
 107    }
 108  231 if (qedeq.getLiteratureItemList() != null) {
 109  194 getCurrentContext().setLocationWithinModule(context + "getLiteratureItemList()");
 110  194 accept(qedeq.getLiteratureItemList());
 111    }
 112  61 setLocationWithinModule(context);
 113  61 visitor.visitLeave(qedeq);
 114  61 setLocationWithinModule(context);
 115    }
 116   
 117  26747 public void accept(final Header header) throws ModuleDataException {
 118  26747 if (blocked || header == null) {
 119  0 return;
 120    }
 121  26747 final String context = getCurrentContext().getLocationWithinModule();
 122  26747 visitor.visitEnter(header);
 123  26723 if (header.getSpecification() != null) {
 124  26723 setLocationWithinModule(context + ".getSpecification()");
 125  26723 accept(header.getSpecification());
 126    }
 127  26618 if (header.getTitle() != null) {
 128  26618 setLocationWithinModule(context + ".getTitle()");
 129  26618 accept(header.getTitle());
 130    }
 131  26572 if (header.getSummary() != null) {
 132  26572 setLocationWithinModule(context + ".getSummary()");
 133  26572 accept(header.getSummary());
 134    }
 135  26526 if (header.getAuthorList() != null) {
 136  26526 setLocationWithinModule(context + ".getAuthorList()");
 137  26526 accept(header.getAuthorList());
 138    }
 139  26454 if (header.getImportList() != null) {
 140  23950 setLocationWithinModule(context + ".getImportList()");
 141  23950 accept(header.getImportList());
 142    }
 143  26338 if (header.getUsedByList() != null) {
 144  2486 setLocationWithinModule(context + ".getUsedByList()");
 145  2486 accept(header.getUsedByList());
 146    }
 147  26283 setLocationWithinModule(context);
 148  26283 visitor.visitLeave(header);
 149  26283 setLocationWithinModule(context);
 150    }
 151   
 152  2486 public void accept(final UsedByList usedByList) throws ModuleDataException {
 153  2486 if (blocked || usedByList == null) {
 154  2403 return;
 155    }
 156  83 final String context = getCurrentContext().getLocationWithinModule();
 157  83 visitor.visitEnter(usedByList);
 158  73 for (int i = 0; i < usedByList.size(); i++) {
 159  73 setLocationWithinModule(context + ".get(" + i + ")");
 160  73 accept(usedByList.get(i));
 161    }
 162  28 setLocationWithinModule(context);
 163  28 visitor.visitLeave(usedByList);
 164  28 setLocationWithinModule(context);
 165    }
 166   
 167  23950 public void accept(final ImportList importList) throws ModuleDataException {
 168  23950 if (blocked || importList == null) {
 169  23769 return;
 170    }
 171  181 final String context = getCurrentContext().getLocationWithinModule();
 172  181 visitor.visitEnter(importList);
 173  169 for (int i = 0; i < importList.size(); i++) {
 174  256 setLocationWithinModule(context + ".get(" + i + ")");
 175  256 accept(importList.get(i));
 176    }
 177  65 setLocationWithinModule(context);
 178  65 visitor.visitLeave(importList);
 179  65 setLocationWithinModule(context);
 180    }
 181   
 182  256 public void accept(final Import imp) throws ModuleDataException {
 183  256 if (blocked || imp == null) {
 184  66 return;
 185    }
 186  190 final String context = getCurrentContext().getLocationWithinModule();
 187  190 visitor.visitEnter(imp);
 188  164 if (imp.getSpecification() != null) {
 189  164 setLocationWithinModule(context + ".getSpecification()");
 190  164 accept(imp.getSpecification());
 191    }
 192  86 setLocationWithinModule(context);
 193  86 visitor.visitLeave(imp);
 194  86 setLocationWithinModule(context);
 195    }
 196   
 197  26960 public void accept(final Specification specification) throws ModuleDataException {
 198  26960 if (blocked || specification == null) {
 199  26251 return;
 200    }
 201  709 final String context = getCurrentContext().getLocationWithinModule();
 202  709 visitor.visitEnter(specification);
 203  609 if (specification.getLocationList() != null) {
 204  609 setLocationWithinModule(context + ".getLocationList()");
 205  609 accept(specification.getLocationList());
 206    }
 207  481 setLocationWithinModule(context);
 208  481 visitor.visitLeave(specification);
 209  481 setLocationWithinModule(context);
 210    }
 211   
 212  609 public void accept(final LocationList locationList) throws ModuleDataException {
 213  609 if (blocked || locationList == null) {
 214  335 return;
 215    }
 216  274 final String context = getCurrentContext().getLocationWithinModule();
 217  274 visitor.visitEnter(locationList);
 218  222 for (int i = 0; i < locationList.size(); i++) {
 219  222 setLocationWithinModule(context + ".get(" + i + ")");
 220  222 accept(locationList.get(i));
 221    }
 222  146 setLocationWithinModule(context);
 223  146 visitor.visitLeave(locationList);
 224  146 setLocationWithinModule(context);
 225    }
 226   
 227  222 public void accept(final Location location) throws ModuleDataException {
 228  222 if (blocked || location == null) {
 229  0 return;
 230    }
 231  222 final String context = getCurrentContext().getLocationWithinModule();
 232  222 visitor.visitEnter(location);
 233  146 setLocationWithinModule(context);
 234  146 visitor.visitLeave(location);
 235  146 setLocationWithinModule(context);
 236    }
 237   
 238  26526 public void accept(final AuthorList authorList) throws ModuleDataException {
 239  26526 if (blocked || authorList == null) {
 240  26215 return;
 241    }
 242  311 final String context = getCurrentContext().getLocationWithinModule();
 243  311 visitor.visitEnter(authorList);
 244  287 for (int i = 0; i < authorList.size(); i++) {
 245  287 setLocationWithinModule(context + ".get(" + i + ")");
 246  287 accept(authorList.get(i));
 247    }
 248  239 setLocationWithinModule(context);
 249  239 visitor.visitLeave(authorList);
 250  239 setLocationWithinModule(context);
 251    }
 252   
 253  287 public void accept(final Author author) throws ModuleDataException {
 254  287 if (blocked || author == null) {
 255  171 return;
 256    }
 257  116 final String context = getCurrentContext().getLocationWithinModule();
 258  116 visitor.visitEnter(author);
 259  81 if (author.getName() != null) {
 260  81 setLocationWithinModule(context + ".getName()");
 261  81 accept(author.getName());
 262    }
 263  68 setLocationWithinModule(context);
 264  68 visitor.visitLeave(author);
 265  68 setLocationWithinModule(context);
 266    }
 267   
 268  26283 public void accept(final ChapterList chapterList) throws ModuleDataException {
 269  26283 if (blocked || chapterList == null) {
 270  0 return;
 271    }
 272  26283 final String context = getCurrentContext().getLocationWithinModule();
 273  26283 visitor.visitEnter(chapterList);
 274  26271 for (int i = 0; i < chapterList.size(); i++) {
 275  107537 setLocationWithinModule(context + ".get(" + i + ")");
 276  107537 accept(chapterList.get(i));
 277    }
 278  231 setLocationWithinModule(context);
 279  231 visitor.visitLeave(chapterList);
 280  231 setLocationWithinModule(context);
 281    }
 282   
 283  107537 public void accept(final Chapter chapter) throws ModuleDataException {
 284  107537 if (blocked || chapter == null) {
 285  1260 return;
 286    }
 287  106277 final String context = getCurrentContext().getLocationWithinModule();
 288  106277 visitor.visitEnter(chapter);
 289  106135 if (chapter.getTitle() != null) {
 290  106135 setLocationWithinModule(context + ".getTitle()");
 291  106135 accept(chapter.getTitle());
 292    }
 293  105889 if (chapter.getIntroduction() != null) {
 294  105886 setLocationWithinModule(context + ".getIntroduction()");
 295  105886 accept(chapter.getIntroduction());
 296    }
 297  105653 if (chapter.getSectionList() != null) {
 298  54027 setLocationWithinModule(context + ".getSectionList()");
 299  54027 accept(chapter.getSectionList());
 300    }
 301  80237 setLocationWithinModule(context);
 302  80237 visitor.visitLeave(chapter);
 303  80237 setLocationWithinModule(context);
 304    }
 305   
 306  194 public void accept(final LiteratureItemList literatureItemList)
 307    throws ModuleDataException {
 308  194 if (blocked || literatureItemList == null) {
 309  0 return;
 310    }
 311  194 final String context = getCurrentContext().getLocationWithinModule();
 312  194 visitor.visitEnter(literatureItemList);
 313  188 for (int i = 0; i < literatureItemList.size(); i++) {
 314  636 setLocationWithinModule(context + ".get(" + i + ")");
 315  636 accept(literatureItemList.get(i));
 316    }
 317  24 setLocationWithinModule(context);
 318  24 visitor.visitLeave(literatureItemList);
 319  24 setLocationWithinModule(context);
 320    }
 321   
 322  636 public void accept(final LiteratureItem item) throws ModuleDataException {
 323  636 if (blocked || item == null) {
 324  0 return;
 325    }
 326  636 final String context = getCurrentContext().getLocationWithinModule();
 327  636 visitor.visitEnter(item);
 328  570 if (item.getItem() != null) {
 329  570 setLocationWithinModule(context + ".getItem()");
 330  570 accept(item.getItem());
 331    }
 332  472 setLocationWithinModule(context);
 333  472 visitor.visitLeave(item);
 334  472 setLocationWithinModule(context);
 335    }
 336   
 337  54027 public void accept(final SectionList sectionList) throws ModuleDataException {
 338  54027 if (blocked || sectionList == null) {
 339  28418 return;
 340    }
 341  25609 final String context = getCurrentContext().getLocationWithinModule();
 342  25609 visitor.visitEnter(sectionList);
 343  25534 for (int i = 0; i < sectionList.size(); i++) {
 344  67597 setLocationWithinModule(context + ".get(" + i + ")");
 345  67597 accept(sectionList.get(i));
 346    }
 347  193 setLocationWithinModule(context);
 348  193 visitor.visitLeave(sectionList);
 349  193 setLocationWithinModule(context);
 350    }
 351   
 352  67597 public void accept(final Section section) throws ModuleDataException {
 353  67597 if (blocked || section == null) {
 354  0 return;
 355    }
 356  67597 final String context = getCurrentContext().getLocationWithinModule();
 357  67597 visitor.visitEnter(section);
 358  67364 if (section.getTitle() != null) {
 359  67364 setLocationWithinModule(context + ".getTitle()");
 360  67364 accept(section.getTitle());
 361    }
 362  66884 if (section.getIntroduction() != null) {
 363  66881 setLocationWithinModule(context + ".getIntroduction()");
 364  66881 accept(section.getIntroduction());
 365    }
 366  66454 if (section.getSubsectionList() != null) {
 367  55002 setLocationWithinModule(context + ".getSubsectionList()");
 368  55002 accept(section.getSubsectionList());
 369    }
 370  42256 setLocationWithinModule(context);
 371  42256 visitor.visitLeave(section);
 372  42256 setLocationWithinModule(context);
 373    }
 374   
 375  55002 public void accept(final SubsectionList subsectionList) throws ModuleDataException {
 376  55002 if (blocked || subsectionList == null) {
 377  30538 return;
 378    }
 379  24464 final String context = getCurrentContext().getLocationWithinModule();
 380  24464 visitor.visitEnter(subsectionList);
 381  24355 for (int i = 0; i < subsectionList.size(); i++) {
 382  133304 setLocationWithinModule(context + ".get(" + i + ")");
 383    // TODO mime 20050608: here the Subsection context is type dependently specified
 384  133304 if (subsectionList.get(i) instanceof Subsection) {
 385  3618 accept((Subsection) subsectionList.get(i));
 386  129686 } else if (subsectionList.get(i) instanceof Node) {
 387  129686 accept((Node) subsectionList.get(i));
 388  0 } else if (subsectionList.get(i) == null) {
 389    // ignore
 390    } else {
 391  0 throw new IllegalArgumentException("unexpected subsection type: "
 392    + subsectionList.get(i).getClass());
 393    }
 394    }
 395  266 setLocationWithinModule(context);
 396  266 visitor.visitLeave(subsectionList);
 397  266 setLocationWithinModule(context);
 398    }
 399   
 400  3618 public void accept(final Subsection subsection) throws ModuleDataException {
 401  3618 if (blocked || subsection == null) {
 402  0 return;
 403    }
 404  3618 final String context = getCurrentContext().getLocationWithinModule();
 405  3618 visitor.visitEnter(subsection);
 406  3524 if (subsection.getTitle() != null) {
 407  1654 setLocationWithinModule(context + ".getTitle()");
 408  1654 accept(subsection.getTitle());
 409    }
 410  3404 if (subsection.getLatex() != null) {
 411  3404 setLocationWithinModule(context + ".getLatex()");
 412  3404 accept(subsection.getLatex());
 413    }
 414  3254 setLocationWithinModule(context);
 415  3254 visitor.visitLeave(subsection);
 416  3254 setLocationWithinModule(context);
 417    }
 418   
 419