EMMA Coverage Report (generated Fri Feb 14 08:28:31 UTC 2014)
[all classes][org.qedeq.kernel.bo.log]

COVERAGE SUMMARY FOR SOURCE FILE [ModuleEventLog.java]

nameclass, %method, %block, %line, %
ModuleEventLog.java100% (1/1)89%  (8/9)65%  (79/122)64%  (19.7/31)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ModuleEventLog100% (1/1)89%  (8/9)65%  (79/122)64%  (19.7/31)
addLog (PrintStream): void 0%   (0/1)0%   (0/11)0%   (0/3)
removeModule (QedeqBo): void 100% (1/1)32%  (8/25)30%  (1.8/6)
addModule (QedeqBo): void 100% (1/1)72%  (18/25)67%  (4/6)
stateChanged (QedeqBo): void 100% (1/1)72%  (18/25)67%  (4/6)
<static initializer> 100% (1/1)93%  (13/14)96%  (1.9/2)
ModuleEventLog (): void 100% (1/1)100% (8/8)100% (3/3)
addLog (ModuleEventListener): void 100% (1/1)100% (6/6)100% (2/2)
getInstance (): ModuleEventLog 100% (1/1)100% (2/2)100% (1/1)
removeLog (ModuleEventListener): void 100% (1/1)100% (6/6)100% (2/2)

1/* This file is part of the project "Hilbert II" - http://www.qedeq.org
2 *
3 * Copyright 2000-2014,  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 
16package org.qedeq.kernel.bo.log;
17 
18import java.io.PrintStream;
19import java.util.ArrayList;
20import java.util.List;
21 
22import org.qedeq.base.trace.Trace;
23import 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 */
33public 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    public static final ModuleEventLog getInstance() {
51        return instance;
52    }
53 
54    /**
55     * Don't use me outside of this class.
56     */
57    private ModuleEventLog() {
58        // nothing to do
59    }
60 
61    /**
62     * Add listener.
63     *
64     * @param   log Add this listener.
65     */
66    public final void addLog(final ModuleEventListener log) {
67        loggers.add(log);
68    }
69 
70    /**
71     * Remove listener.
72     *
73     * @param   log Remove this listener.
74     */
75    public final void removeLog(final ModuleEventListener log) {
76        loggers.remove(log);
77    }
78 
79    /**
80     * Add stream listener.
81     *
82     * @param   out Put messages into this stream.
83     */
84    public final void addLog(final PrintStream out) {
85        final ModuleEventListener log = new DefaultModuleEventListener(out);
86        loggers.add(log);
87    }
88 
89    public void addModule(final QedeqBo prop) {
90        for (int i = 0; i < loggers.size(); i++) {
91            try {   // we don't know if the ModuleEventListener is free of programming errors...
92                ((ModuleEventListener) loggers.get(i)).addModule(prop);
93            } catch (RuntimeException e) {
94                Trace.fatal(CLASS, this, "addModule",
95                    "ModuleEventListener throwed RuntimeException", e);
96            }
97        }
98    }
99 
100    public void stateChanged(final QedeqBo prop) {
101        for (int i = 0; i < loggers.size(); i++) {
102            try {   // we don't know if the ModuleEventListener is free of programming errors...
103                ((ModuleEventListener) loggers.get(i)).stateChanged(prop);
104            } catch (RuntimeException e) {
105                Trace.fatal(CLASS, this, "stateChanged",
106                    "ModuleEventListener throwed RuntimeException", e);
107            }
108        }
109    }
110 
111    public void removeModule(final QedeqBo prop) {
112        for (int i = 0; i < loggers.size(); i++) {
113            try {   // we don't know if the ModuleEventListener is free of programming errors...
114                ((ModuleEventListener) loggers.get(i)).removeModule(prop);
115            } catch (RuntimeException e) {
116                Trace.fatal(CLASS, this, "removeModule",
117                    "ModuleEventListener throwed RuntimeException", e);
118            }
119        }
120    }
121 
122 
123}

[all classes][org.qedeq.kernel.bo.log]
EMMA 2.1.5320 (stable) (C) Vladimir Roubtsov