Clover coverage report - QedeqKernelSe Coverage Report
Coverage timestamp: So Sep 2 2007 02:40:58 CEST
file stats: LOC: 109   Methods: 7
NCLOC: 49   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
ModuleEventLog.java 66,7% 50% 71,4% 58,6%
coverage coverage
 1    /* $Id: ModuleEventLog.java,v 1.4 2007/09/02 00:13:41 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.4 $
 32    * @author Michael Meyling
 33    */
 34    public final class ModuleEventLog implements ModuleEventListener {
 35   
 36    /** The one and only instance. */
 37    private static ModuleEventLog instance = new ModuleEventLog();
 38   
 39    /** The loggers. */
 40    private List loggers = new ArrayList();
 41   
 42   
 43    /**
 44    * Get instance of Logger.
 45    *
 46    * @return singleton
 47    */
 48  145 public static final ModuleEventLog getInstance() {
 49  145 return instance;
 50    }
 51   
 52   
 53    /**
 54    * Don't use me outside of this class.
 55    */
 56  2 private ModuleEventLog() {
 57    }
 58   
 59    /**
 60    * Add listener.
 61    *
 62    * @param log Add this listener.
 63    */
 64  4 public final void addLog(final ModuleEventListener log) {
 65  4 loggers.add(log);
 66    }
 67   
 68    /**
 69    * Add stream listener.
 70    *
 71    * @param out Put messages into this stream.
 72    */
 73  0 public final void addLog(final PrintStream out) {
 74  0 final ModuleEventListener log = new DefaultModuleEventListener(out);
 75  0 loggers.add(log);
 76    }
 77   
 78  33 public void addModule(final ModuleProperties prop) {
 79  33 for (int i = 0; i < loggers.size(); i++) {
 80  61 try { // we don't know if the ModuleEventListener is free of programming errors...
 81  61 ((ModuleEventListener) loggers.get(i)).addModule(prop);
 82    } catch (RuntimeException e) {
 83  0 Trace.fatal(this, "addModule", "ModuleEventListener throwed RuntimeException", e);
 84    }
 85    }
 86    }
 87   
 88  108 public void stateChanged(final ModuleProperties prop) {
 89  108 for (int i = 0; i < loggers.size(); i++) {
 90  200 try { // we don't know if the ModuleEventListener is free of programming errors...
 91  200 ((ModuleEventListener) loggers.get(i)).stateChanged(prop);
 92    } catch (RuntimeException e) {
 93  0 Trace.fatal(this, "stateChanged", "ModuleEventListener throwed RuntimeException", e);
 94    }
 95    }
 96    }
 97   
 98  0 public void removeModule(final ModuleProperties prop) {
 99  0 for (int i = 0; i < loggers.size(); i++) {
 100  0 try { // we don't know if the ModuleEventListener is free of programming errors...
 101  0 ((ModuleEventListener) loggers.get(i)).removeModule(prop);
 102    } catch (RuntimeException e) {
 103  0 Trace.fatal(this, "removeModule", "ModuleEventListener throwed RuntimeException", e);
 104    }
 105    }
 106    }
 107   
 108   
 109    }