Clover Coverage Report
Coverage timestamp: Fri May 24 2013 13:47:27 UTC
../../../../../../img/srcFileCovDistChart0.png 96% of files have more coverage
29   133   11   4.83
4   69   0.38   6
6     1.83  
1    
 
  Qedeq2UnicodeTextExecutor       Line # 40 29 11 0% 0.0
 
No Tests
 
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.service.unicode;
17   
18    import java.io.IOException;
19   
20    import org.qedeq.base.io.Parameters;
21    import org.qedeq.base.io.StringOutput;
22    import org.qedeq.base.trace.Trace;
23    import org.qedeq.kernel.bo.log.QedeqLog;
24    import org.qedeq.kernel.bo.module.InternalServiceCall;
25    import org.qedeq.kernel.bo.module.InternalServiceProcess;
26    import org.qedeq.kernel.bo.module.KernelQedeqBo;
27    import org.qedeq.kernel.bo.module.PluginExecutor;
28    import org.qedeq.kernel.se.common.Plugin;
29    import 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    */
 
40    public final class Qedeq2UnicodeTextExecutor implements PluginExecutor {
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  0 toggle Qedeq2UnicodeTextExecutor(final Plugin plugin, final KernelQedeqBo prop,
63    final Parameters parameters) {
64  0 language = parameters.getString("language");
65  0 final boolean info = parameters.getBoolean("info");
66    // automatically line break after this column. 0 means no automatic line breaking
67  0 int maxColumns = parameters.getInt("maximumColumn");
68  0 maxColumns = Math.max(10, maxColumns);
69  0 visitor = new Qedeq2UnicodeVisitor(plugin, prop, info , maxColumns, false, false);
70    }
71   
 
72  0 toggle public Object executePlugin(final InternalServiceCall call, final Object data) {
73  0 final String method = "executePlugin()";
74  0 String result = "";
75  0 try {
76  0 QedeqLog.getInstance().logRequest("Show UTF-8 text", visitor.getQedeqBo().getUrl());
77  0 result = generateUtf8(call.getInternalServiceProcess(), language, "1");
78  0 QedeqLog.getInstance().logSuccessfulReply(
79    "UTF-8 text was shown", visitor.getQedeqBo().getUrl());
80    } catch (final SourceFileExceptionList e) {
81  0 final String msg = "Generation failed";
82  0 Trace.fatal(CLASS, this, method, msg, e);
83  0 QedeqLog.getInstance().logFailureReply(msg, visitor.getQedeqBo().getUrl(), e.getMessage());
84    } catch (IOException e) {
85  0 final String msg = "Generation failed";
86  0 Trace.fatal(CLASS, this, method, msg, e);
87  0 QedeqLog.getInstance().logFailureReply(msg, visitor.getQedeqBo().getUrl(), e.getMessage());
88    } catch (final RuntimeException e) {
89  0 Trace.fatal(CLASS, this, method, "unexpected problem", e);
90  0 QedeqLog.getInstance().logFailureReply(
91    "Generation failed", visitor.getQedeqBo().getUrl(), "unexpected problem: "
92  0 + (e.getMessage() != null ? e.getMessage() : e.toString()));
93    }
94  0 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  0 toggle public String generateUtf8(final InternalServiceProcess process, final String language,
109    final String level) throws SourceFileExceptionList, IOException {
110   
111  0 String lan = "en";
112  0 if (language != null) {
113  0 lan = language;
114    }
115  0 printer = new StringOutput();
116   
117  0 visitor.generateUtf8(process, printer, lan, level);
118  0 return printer.toString();
119    }
120   
 
121  0 toggle public String getLocationDescription() {
122  0 return visitor.getLocationDescription();
123    }
124   
 
125  0 toggle public double getVisitPercentage() {
126  0 return visitor.getVisitPercentage();
127    }
128   
 
129  0 toggle public boolean getInterrupted() {
130  0 return visitor.getInterrupted();
131    }
132   
133    }