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 [Element2Utf8Impl.java]

nameclass, %method, %block, %line, %
Element2Utf8Impl.java100% (1/1)100% (3/3)100% (62/62)100% (13/13)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class Element2Utf8Impl100% (1/1)100% (3/3)100% (62/62)100% (13/13)
Element2Utf8Impl (Element2LatexImpl): void 100% (1/1)100% (6/6)100% (3/3)
getUtf8 (Element): String 100% (1/1)100% (7/7)100% (1/1)
getUtf8 (Element, int): String [] 100% (1/1)100% (49/49)100% (9/9)

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.ArrayList;
19import java.util.List;
20 
21import org.apache.commons.lang.ArrayUtils;
22import org.qedeq.base.utility.StringUtility;
23import org.qedeq.kernel.bo.common.Element2Utf8;
24import org.qedeq.kernel.bo.service.unicode.Latex2UnicodeParser;
25import org.qedeq.kernel.se.base.list.Element;
26 
27 
28/**
29 * Transfer a QEDEQ formulas into UTF-8 text.
30 *
31 * @author  Michael Meyling
32 */
33public final class Element2Utf8Impl implements Element2Utf8 {
34 
35    /** We use this converter. */
36    private Element2LatexImpl converter;
37 
38    /**
39     * Constructor.
40     *
41     * @param   converter   This converter can produce at least LaTeX.
42     */
43    public Element2Utf8Impl(final Element2LatexImpl converter) {
44        this.converter = converter;
45    }
46 
47    public String getUtf8(final Element element) {
48        return getUtf8(element, 0)[0];
49    }
50 
51    public String[] getUtf8(final Element element, final int maxCols) {
52        final String result = Latex2UnicodeParser.transform(null, converter.getLatex(element), 0);
53        if (maxCols <= 0 || result.length()  < maxCols) {
54            return new String[] {result};
55        }
56        final List list = new ArrayList();
57        int index = 0;
58        while (index < result.length()) {
59            list.add(StringUtility.substring(result, index, maxCols));
60            index += maxCols;
61        }
62        return (String[]) list.toArray(ArrayUtils.EMPTY_STRING_ARRAY);
63    }
64 
65}

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