Clover Coverage Report
Coverage timestamp: Fri May 24 2013 13:47:27 UTC
../../../../../img/srcFileCovDistChart7.png 74% of files have more coverage
17   123   14   2.12
6   56   0.82   8
8     1.75  
1    
 
  ModuleEventLog       Line # 33 17 14 71% 0.7096774
 
  (101)
 
1    /* This file is part of the project "Hilbert II" - http://www.qedeq.org
2    *
3    * Copyright 2000-2013, Michael Meyling <mime@qedeq.org>.
4    *
5    * "Hilbert II" is free software; you can redistribute
6    * it and/or modify it under the terms of the GNU General Public
7    * License as published by the Free Software Foundation; either
8    * version 2 of the License, or (at your option) any later version.
9    *
10    * This program is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13    * GNU General Public License for more details.
14    */
15   
16    package org.qedeq.kernel.bo.log;
17   
18    import java.io.PrintStream;
19    import java.util.ArrayList;
20    import java.util.List;
21   
22    import org.qedeq.base.trace.Trace;
23    import org.qedeq.kernel.bo.common.QedeqBo;
24   
25   
26    /**
27    * This class organizes the logging of module events.
28    *
29    * TODO mime 20080317: must this be a singleton?
30    *
31    * @author Michael Meyling
32    */
 
33    public final class ModuleEventLog implements ModuleEventListener {
34   
35    /** This class. */
36    private static final Class CLASS = ModuleEventLog.class;
37   
38    /** The one and only instance. */
39    private static ModuleEventLog instance = new ModuleEventLog();
40   
41    /** The loggers. */
42    private List loggers = new ArrayList();
43   
44   
45    /**
46    * Get instance of Logger.
47    *
48    * @return singleton
49    */
 
50  5281 toggle public static final ModuleEventLog getInstance() {
51  5281 return instance;
52    }
53   
54    /**
55    * Don't use me outside of this class.
56    */
 
57  24 toggle private ModuleEventLog() {
58    // nothing to do
59    }
60   
61    /**
62    * Add listener.
63    *
64    * @param log Add this listener.
65    */
 
66  3 toggle public final void addLog(final ModuleEventListener log) {
67  3 loggers.add(log);
68    }
69   
70    /**
71    * Remove listener.
72    *
73    * @param log Remove this listener.
74    */
 
75  3 toggle public final void removeLog(final ModuleEventListener log) {
76  3 loggers.remove(log);
77    }
78   
79    /**
80    * Add stream listener.
81    *
82    * @param out Put messages into this stream.
83    */
 
84  0 toggle public final void addLog(final PrintStream out) {
85  0 final ModuleEventListener log = new DefaultModuleEventListener(out);
86  0 loggers.add(log);
87    }
88   
 
89  597 toggle public void addModule(final QedeqBo prop) {
90  600 for (int i = 0; i < loggers.size(); i++) {
91  3 try { // we don't know if the ModuleEventListener is free of programming errors...
92  3 ((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  4075 toggle public void stateChanged(final QedeqBo prop) {
101  4132 for (int i = 0; i < loggers.size(); i++) {
102  57 try { // we don't know if the ModuleEventListener is free of programming errors...
103  57 ((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  603 toggle public void removeModule(final QedeqBo prop) {
112  603 for (int i = 0; i < loggers.size(); i++) {
113  0 try { // we don't know if the ModuleEventListener is free of programming errors...
114  0 ((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    }