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

COVERAGE SUMMARY FOR SOURCE FILE [PluginResultManager.java]

nameclass, %method, %block, %line, %
PluginResultManager.java100% (1/1)62%  (5/8)68%  (132/194)68%  (32.9/48)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class PluginResultManager100% (1/1)62%  (5/8)68%  (132/194)68%  (32.9/48)
getPlugins (): ModuleServicePlugin [] 0%   (0/1)0%   (0/9)0%   (0/1)
removeAllResults (): void 0%   (0/1)0%   (0/4)0%   (0/2)
setResult (ModuleServicePlugin, SourceFileExceptionList, SourceFileExceptionL... 0%   (0/1)0%   (0/27)0%   (0/8)
getPluginStateDescription (): String 100% (1/1)70%  (51/73)77%  (13.9/18)
PluginResultManager (): void 100% (1/1)100% (8/8)100% (2/2)
addResult (ModuleService, SourceFileExceptionList, SourceFileExceptionList): ... 100% (1/1)100% (25/25)100% (7/7)
getAllErrors (): SourceFileExceptionList 100% (1/1)100% (24/24)100% (5/5)
getAllWarnings (): SourceFileExceptionList 100% (1/1)100% (24/24)100% (5/5)

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.service.internal;
17 
18import java.util.HashMap;
19import java.util.Iterator;
20import java.util.Map;
21 
22import org.qedeq.kernel.bo.service.basis.ModuleServicePlugin;
23import org.qedeq.kernel.bo.service.basis.ModuleServicePluginResults;
24import org.qedeq.kernel.se.common.ModuleService;
25import org.qedeq.kernel.se.common.SourceFileExceptionList;
26 
27/**
28 * Holds all known QEDEQ modules.
29 */
30public class PluginResultManager {
31 
32    /** Maps plugins to results. */
33    private final Map plugins = new HashMap();
34 
35 
36    /**
37     * Get all used plugins.
38     *
39     * @return  Used plugins.
40     */
41    synchronized ModuleServicePlugin[] getPlugins() {
42        return (ModuleServicePlugin[]) plugins.keySet().toArray(new ModuleServicePlugin[] {});
43    }
44 
45    /**
46     * Clear all plugin results.
47     */
48    public void removeAllResults() {
49        plugins.clear();
50    }
51 
52    /**
53     * Set a plugin execution results.
54     *
55     * @param   plugin      Set results for this plugin.
56     * @param   errors      Plugin errors.
57     * @param   warnings    Plugin warnings.
58     */
59    public synchronized void setResult(final ModuleServicePlugin plugin, final SourceFileExceptionList errors,
60            final SourceFileExceptionList warnings) {
61        ModuleServicePluginResults results = (ModuleServicePluginResults) plugins.get(plugin);
62        if (results == null) {
63            results = new ModuleServicePluginResults();
64            plugins.put(plugin, results);
65        }
66        results.clear();
67        results.addErrors(errors);
68        results.addWarnings(warnings);
69    }
70 
71    /**
72     * Add results of a plugin.
73     *
74     * @param   plugin      Add results for this plugin.
75     * @param   errors      Plugin errors.
76     * @param   warnings    Plugin warnings.
77     */
78    public synchronized void addResult(final ModuleService plugin, final SourceFileExceptionList errors,
79            final SourceFileExceptionList warnings) {
80        ModuleServicePluginResults results = (ModuleServicePluginResults) plugins.get(plugin);
81        if (results == null) {
82            results = new ModuleServicePluginResults();
83            plugins.put(plugin, results);
84        }
85        results.addErrors(errors);
86        results.addWarnings(warnings);
87    }
88 
89    /**
90     * Get all errors that occurred. The resulting object is never <code>null</code>.
91     *
92     * @return  Error list.
93     */
94    public SourceFileExceptionList getAllErrors() {
95        final SourceFileExceptionList errors = new SourceFileExceptionList();
96        Iterator iterator = plugins.keySet().iterator();
97        while (iterator.hasNext()) {
98            errors.add(((ModuleServicePluginResults) plugins.get(iterator.next())).getErrors());
99        }
100        return errors;
101    }
102 
103    /**
104     * Get all warnings that occurred. The resulting object is never <code>null</code>.
105     *
106     * @return  Warnings list.
107     */
108    public SourceFileExceptionList getAllWarnings() {
109        final SourceFileExceptionList warnings = new SourceFileExceptionList();
110        Iterator iterator = plugins.keySet().iterator();
111        while (iterator.hasNext()) {
112            warnings.add(((ModuleServicePluginResults) plugins.get(iterator.next())).getWarnings());
113        }
114        return warnings;
115    }
116 
117    /**
118     * Get plugin states description.
119     *
120     * @return  Textual description of plugin states.
121     */
122    public synchronized String getPluginStateDescription() {
123        final StringBuffer text = new StringBuffer();
124        Iterator iterator = plugins.keySet().iterator();
125        while (iterator.hasNext()) {
126            if (text.length() > 0) {
127                text.append(", ");
128            }
129            final ModuleServicePlugin key = (ModuleServicePlugin) iterator.next();
130            ModuleServicePluginResults result = (ModuleServicePluginResults) plugins.get(key);
131            text.append(key.getServiceAction());
132            text.append(" ");
133            if (result.hasErrors() && result.hasWarnings()) {
134                text.append("has errors and warnings");
135            } else if (result.hasErrors()) {
136                text.append("has errors");
137            } else if (result.hasWarnings()) {
138                text.append("has warnings");
139            } else {
140                text.append("successful");
141            }
142        }
143        return text.toString();
144    }
145 
146}
147 

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