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

COVERAGE SUMMARY FOR SOURCE FILE [Qedeq2UnicodeTextExecutor.java]

nameclass, %method, %block, %line, %
Qedeq2UnicodeTextExecutor.java100% (1/1)43%  (3/7)37%  (63/172)40%  (13.9/35)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class Qedeq2UnicodeTextExecutor100% (1/1)43%  (3/7)37%  (63/172)40%  (13.9/35)
executePlugin (InternalModuleServiceCall, Object): Object 0%   (0/1)0%   (0/96)0%   (0/18)
getInterrupted (): boolean 0%   (0/1)0%   (0/4)0%   (0/1)
getLocationDescription (): String 0%   (0/1)0%   (0/4)0%   (0/1)
getVisitPercentage (): double 0%   (0/1)0%   (0/4)0%   (0/1)
<static initializer> 100% (1/1)90%  (9/10)90%  (0.9/1)
Qedeq2UnicodeTextExecutor (ModuleService, KernelQedeqBo, Parameters): void 100% (1/1)100% (31/31)100% (7/7)
generateUtf8 (InternalServiceJob, String, String): String 100% (1/1)100% (23/23)100% (6/6)

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.unicode;
17 
18import java.io.IOException;
19 
20import org.qedeq.base.io.Parameters;
21import org.qedeq.base.io.StringOutput;
22import org.qedeq.base.trace.Trace;
23import org.qedeq.kernel.bo.log.QedeqLog;
24import org.qedeq.kernel.bo.module.InternalModuleServiceCall;
25import org.qedeq.kernel.bo.module.InternalServiceJob;
26import org.qedeq.kernel.bo.module.KernelQedeqBo;
27import org.qedeq.kernel.bo.service.basis.ModuleServicePluginExecutor;
28import org.qedeq.kernel.se.common.ModuleService;
29import org.qedeq.kernel.se.common.SourceFileExceptionList;
30 
31 
32/**
33 * Transfer a QEDEQ module into a UTF-8 text file.
34 * <p>
35 * <b>This is just a quick written generator. This class just generates some text output to be able
36 * to get a visual impression of a QEDEQ module.</b>
37 *
38 * @author  Michael Meyling
39 */
40public final class Qedeq2UnicodeTextExecutor implements ModuleServicePluginExecutor {
41 
42    /** This class. */
43    private static final Class CLASS = Qedeq2UnicodeTextExecutor.class;
44 
45    /** Output goes here. */
46    private StringOutput printer;
47 
48    /** Filter text to get and produce text in this language. */
49    private String language;
50 
51    /** Visitor for producing the text output. */
52    private final Qedeq2UnicodeVisitor visitor;
53 
54 
55    /**
56     * Constructor.
57     *
58     * @param   plugin      This plugin we work for.
59     * @param   prop        QEDEQ BO object.
60     * @param   parameters  Plugin parameter.
61     */
62    Qedeq2UnicodeTextExecutor(final ModuleService plugin, final KernelQedeqBo prop,
63            final Parameters parameters) {
64        language = parameters.getString("language");
65        final boolean info = parameters.getBoolean("info");
66        // automatically line break after this column. 0 means no automatic line breaking
67        int maxColumns = parameters.getInt("maximumColumn");
68        maxColumns = Math.max(10, maxColumns);
69        visitor = new Qedeq2UnicodeVisitor(plugin, prop, info , maxColumns, false, false);
70    }
71 
72    public Object executePlugin(final InternalModuleServiceCall call, final Object data) {
73        final String method = "executePlugin()";
74        String result = "";
75        try {
76            QedeqLog.getInstance().logRequest("Show UTF-8 text", visitor.getKernelQedeqBo().getUrl());
77            result = generateUtf8(call.getInternalServiceProcess(), language, "1");
78            QedeqLog.getInstance().logSuccessfulReply(
79                "UTF-8 text was shown", visitor.getKernelQedeqBo().getUrl());
80        } catch (final SourceFileExceptionList e) {
81            final String msg = "Generation failed";
82            Trace.fatal(CLASS, this, method, msg, e);
83            QedeqLog.getInstance().logFailureReply(msg, visitor.getKernelQedeqBo().getUrl(), e.getMessage());
84        } catch (IOException e) {
85            final String msg = "Generation failed";
86            Trace.fatal(CLASS, this, method, msg, e);
87            QedeqLog.getInstance().logFailureReply(msg, visitor.getKernelQedeqBo().getUrl(), e.getMessage());
88        } catch (final RuntimeException e) {
89            Trace.fatal(CLASS, this, method, "unexpected problem", e);
90            QedeqLog.getInstance().logFailureReply(
91                "Generation failed", visitor.getKernelQedeqBo().getUrl(), "unexpected problem: "
92                + (e.getMessage() != null ? e.getMessage() : e.toString()));
93        }
94        return result;
95    }
96 
97    /**
98     * Gives a UTF-8 representation of given QEDEQ module as InputStream.
99     *
100     * @param   process     We run in this service process.
101     * @param   language    Filter text to get and produce text in this language only.
102     * @param   level       Filter for this detail level. LATER mime 20050205: not supported
103     *                      yet.
104     * @return  Name of generated file.
105     * @throws  SourceFileExceptionList Major problem occurred.
106     * @throws  IOException     File IO failed.
107     */
108    public String generateUtf8(final InternalServiceJob process, final String language,
109            final String level) throws SourceFileExceptionList, IOException {
110 
111        String lan = "en";
112        if (language != null) {
113            lan = language;
114        }
115        printer = new StringOutput();
116 
117        visitor.generateUtf8(process, printer, lan, level);
118        return printer.toString();
119    }
120 
121    public String getLocationDescription() {
122        return visitor.getLocationDescription();
123    }
124 
125    public double getVisitPercentage() {
126        return visitor.getVisitPercentage();
127    }
128 
129    public boolean getInterrupted() {
130        return visitor.getInterrupted();
131    }
132 
133}

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