Clover Coverage Report
Coverage timestamp: Sa Aug 2 2008 13:56:27 CEST
../../../../../img/srcFileCovDistChart7.png 62% of files have more coverage
17   125   14   2,12
6   56   0,82   8
8     1,75  
1    
 
  ModuleEventLog       Line # 36 17 14 61,3% 0.61290324
 
  (41)
 
1    /* $Id: ModuleEventLog.java,v 1.1 2008/07/26 07:58:29 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.log;
19   
20    import java.io.PrintStream;
21    import java.util.ArrayList;
22    import java.util.List;
23   
24    import org.qedeq.base.trace.Trace;
25    import org.qedeq.kernel.bo.QedeqBo;
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.1 $
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  1063 toggle public static final ModuleEventLog getInstance() {
54  1063 return instance;
55    }
56   
57    /**
58    * Don't use me outside of this class.
59    */
 
60  8 toggle private ModuleEventLog() {
61    }
62   
63    /**
64    * Add listener.
65    *
66    * @param log Add this listener.
67    */
 
68  39 toggle public final void addLog(final ModuleEventListener log) {
69  39 loggers.add(log);
70    }
71   
72    /**
73    * Remove listener.
74    *
75    * @param log Remove this listener.
76    */
 
77  39 toggle public final void removeLog(final ModuleEventListener log) {
78  39 loggers.remove(log);
79    }
80   
81    /**
82    * Add stream listener.
83    *
84    * @param out Put messages into this stream.
85    */
 
86  0 toggle public final void addLog(final PrintStream out) {
87  0 final ModuleEventListener log = new DefaultModuleEventListener(out);
88  0 loggers.add(log);
89    }
90   
 
91  116 toggle public void addModule(final QedeqBo prop) {
92  227 for (int i = 0; i < loggers.size(); i++) {
93  111 try { // we don't know if the ModuleEventListener is free of programming errors...
94  111 ((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  869 toggle public void stateChanged(final QedeqBo prop) {
103  1715 for (int i = 0; i < loggers.size(); i++) {
104  846 try { // we don't know if the ModuleEventListener is free of programming errors...
105  846 ((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  0 toggle public void removeModule(final QedeqBo prop) {
114  0 for (int i = 0; i < loggers.size(); i++) {
115  0 try { // we don't know if the ModuleEventListener is free of programming errors...
116  0 ((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    }