Clover coverage report - QedeqKernelSe Coverage Report
Coverage timestamp: Do Mrz 27 2008 21:46:26 CET
file stats: LOC: 125   Methods: 8
NCLOC: 56   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
ModuleEventLog.java 100% 70,6% 87,5% 80,6%
coverage coverage
 1    /* $Id: ModuleEventLog.java,v 1.8 2008/03/27 05:16:26 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.log;
 19   
 20    import java.io.PrintStream;
 21    import java.util.ArrayList;
 22    import java.util.List;
 23   
 24    import org.qedeq.kernel.common.QedeqBo;
 25    import org.qedeq.kernel.trace.Trace;
 26   
 27   
 28    /**
 29    * This class organizes the logging of module events.
 30    *
 31    * TODO mime 20080317: must this be a singleton?
 32    *
 33    * @version $Revision: 1.8 $
 34    * @author Michael Meyling
 35    */
 36    public final class ModuleEventLog implements ModuleEventListener {
 37   
 38    /** This class. */
 39    private static final Class CLASS = ModuleEventLog.class;
 40   
 41    /** The one and only instance. */
 42    private static ModuleEventLog instance = new ModuleEventLog();
 43   
 44    /** The loggers. */
 45    private List loggers = new ArrayList();
 46   
 47   
 48    /**
 49    * Get instance of Logger.
 50    *
 51    * @return singleton
 52    */
 53  1342 public static final ModuleEventLog getInstance() {
 54  1342 return instance;
 55    }
 56   
 57    /**
 58    * Don't use me outside of this class.
 59    */
 60  3 private ModuleEventLog() {
 61    }
 62   
 63    /**
 64    * Add listener.
 65    *
 66    * @param log Add this listener.
 67    */
 68  35 public final void addLog(final ModuleEventListener log) {
 69  35 loggers.add(log);
 70    }
 71   
 72    /**
 73    * Remove listener.
 74    *
 75    * @param log Remove this listener.
 76    */
 77  29 public final void removeLog(final ModuleEventListener log) {
 78  29 loggers.remove(log);
 79    }
 80   
 81    /**
 82    * Add stream listener.
 83    *
 84    * @param out Put messages into this stream.
 85    */
 86  0 public final void addLog(final PrintStream out) {
 87  0 final ModuleEventListener log = new DefaultModuleEventListener(out);
 88  0 loggers.add(log);
 89    }
 90   
 91  158 public void addModule(final QedeqBo prop) {
 92  158 for (int i = 0; i < loggers.size(); i++) {
 93  291 try { // we don't know if the ModuleEventListener is free of programming errors...
 94  291 ((ModuleEventListener) loggers.get(i)).addModule(prop);
 95    } catch (RuntimeException e) {
 96  0 Trace.fatal(CLASS, this, "addModule",
 97    "ModuleEventListener throwed RuntimeException", e);
 98    }
 99    }
 100    }
 101   
 102  1092 public void stateChanged(final QedeqBo prop) {
 103  1092 for (int i = 0; i < loggers.size(); i++) {
 104  2013 try { // we don't know if the ModuleEventListener is free of programming errors...
 105  2013 ((ModuleEventListener) loggers.get(i)).stateChanged(prop);
 106    } catch (RuntimeException e) {
 107  0 Trace.fatal(CLASS, this, "stateChanged",
 108    "ModuleEventListener throwed RuntimeException", e);
 109    }
 110    }
 111    }
 112   
 113  28 public void removeModule(final QedeqBo prop) {
 114  28 for (int i = 0; i < loggers.size(); i++) {
 115  84 try { // we don't know if the ModuleEventListener is free of programming errors...
 116  84 ((ModuleEventListener) loggers.get(i)).removeModule(prop);
 117    } catch (RuntimeException e) {
 118  0 Trace.fatal(CLASS, this, "removeModule",
 119    "ModuleEventListener throwed RuntimeException", e);
 120    }
 121    }
 122    }
 123   
 124   
 125    }