Clover coverage report - QedeqKernelSe Coverage Report
Coverage timestamp: Do Mrz 27 2008 21:46:26 CET
file stats: LOC: 134   Methods: 8
NCLOC: 52   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
ControlVisitor.java 66,7% 88,2% 100% 87,1%
coverage coverage
 1    /* $Id: ControlVisitor.java,v 1.1 2008/03/27 05:16:24 m31 Exp $
 2    *
 3    * This file is part of the project "Hilbert II" - http://www.qedeq.org
 4    *
 5    * Copyright 2000-2008, Michael Meyling <mime@qedeq.org>.
 6    *
 7    * "Hilbert II" is free software; you can redistribute
 8    * it and/or modify it under the terms of the GNU General Public
 9    * License as published by the Free Software Foundation; either
 10    * version 2 of the License, or (at your option) any later version.
 11    *
 12    * This program is distributed in the hope that it will be useful,
 13    * but WITHOUT ANY WARRANTY; without even the implied warranty of
 14    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 15    * GNU General Public License for more details.
 16    */
 17   
 18    package org.qedeq.kernel.bo.control;
 19   
 20    import org.qedeq.kernel.bo.visitor.AbstractModuleVisitor;
 21    import org.qedeq.kernel.bo.visitor.QedeqNotNullTraverser;
 22    import org.qedeq.kernel.common.DefaultSourceFileExceptionList;
 23    import org.qedeq.kernel.common.ModuleContext;
 24    import org.qedeq.kernel.common.ModuleDataException;
 25    import org.qedeq.kernel.common.SourceFileException;
 26   
 27   
 28    /**
 29    * Basic visitor that gives some error collecting features. Also hides the
 30    * traverser that does the work.
 31    *
 32    * @version $Revision: 1.1 $
 33    * @author Michael Meyling
 34    */
 35    public abstract class ControlVisitor extends AbstractModuleVisitor {
 36   
 37    /** QEDEQ BO object to work on. */
 38    private final KernelQedeqBo prop;
 39   
 40    /** Traverse QEDEQ module with this traverser. */
 41    private final QedeqNotNullTraverser traverser;
 42   
 43    /** List of Exceptions during Module load. */
 44    private DefaultSourceFileExceptionList errorList;
 45   
 46   
 47    /**
 48    * Constructor.
 49    *
 50    * @param prop Internal QedeqBo.
 51    */
 52  472 protected ControlVisitor(final KernelQedeqBo prop) {
 53  472 if (prop.getQedeq() == null) {
 54  0 throw new NullPointerException("Programming error, Module not loaded: "
 55    + prop.getModuleAddress());
 56    }
 57  472 this.prop = prop;
 58  472 this.traverser = new QedeqNotNullTraverser(prop.getModuleAddress(), this);
 59    }
 60   
 61    /**
 62    * Get QedeqBo.
 63    *
 64    * @return QedeqBo.
 65    */
 66  368 protected KernelQedeqBo getQedeqBo() {
 67  368 return this.prop;
 68    }
 69   
 70    /**
 71    * Start traverse of QedeqBo. If during the traverse a {@link ModuleDataException}
 72    * occurs it is thrown till high level and transformed into a
 73    * {@link DefaultSourceFileExceptionList}. Otherwise all collected exceptions
 74    * (via {@link #addModuleDataException(ModuleDataException)} and
 75    * {@link #addSourceFileException(SourceFileException)}) are thrown.
 76    *
 77    * @throws DefaultSourceFileExceptionList All collected exceptions.
 78    */
 79  472 protected void traverse() throws DefaultSourceFileExceptionList {
 80  472 try {
 81  472 this.traverser.accept(this.prop.getQedeq());
 82    } catch (ModuleDataException me) {
 83  22 addModuleDataException(me);
 84    }
 85  472 if (errorList != null) {
 86  29 throw errorList;
 87    }
 88    }
 89   
 90  29825 protected ModuleContext getCurrentContext() {
 91  29825 return this.traverser.getCurrentContext();
 92    }
 93   
 94    /**
 95    * Get list of exceptions that occurred during loading referenced modules.
 96    *
 97    * @return Exception list.
 98    */
 99  301 public DefaultSourceFileExceptionList getSourceFileExceptionList() {
 100  301 return errorList;
 101    }
 102   
 103    /**
 104    * Add exception to error collection.
 105    *
 106    * @param me Exception to be added.
 107    */
 108  29 protected void addModuleDataException(final ModuleDataException me) {
 109  29 addSourceFileException(prop.createSourceFileException(me));
 110    }
 111   
 112    /**
 113    * Add exception to error collection.
 114    *
 115    * @param sf Exception to be added.
 116    */
 117  29 protected void addSourceFileException(final SourceFileException sf) {
 118  29 if (errorList == null) {
 119  29 errorList = new DefaultSourceFileExceptionList(sf);
 120    } else {
 121  0 errorList.add(sf);
 122    }
 123    }
 124   
 125    /**
 126    * Set if further traverse is blocked.
 127    *
 128    * @param blocked Further traverse blocked?
 129    */
 130  13302 protected void setBlocked(final boolean blocked) {
 131  13302 traverser.setBlocked(blocked);
 132    }
 133   
 134    }