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