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

COVERAGE SUMMARY FOR SOURCE FILE [LoadXmlOperatorListUtility.java]

nameclass, %method, %block, %line, %
LoadXmlOperatorListUtility.java100% (1/1)50%  (3/6)32%  (60/189)42%  (13.4/32)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class LoadXmlOperatorListUtility100% (1/1)50%  (3/6)32%  (60/189)42%  (13.4/32)
getServiceAction (): String 0%   (0/1)0%   (0/2)0%   (0/1)
getServiceDescription (): String 0%   (0/1)0%   (0/2)0%   (0/1)
getServiceId (): String 0%   (0/1)0%   (0/3)0%   (0/1)
getOperatorList (InternalKernelServices, File): List 100% (1/1)28%  (48/169)41%  (10.6/26)
<static initializer> 100% (1/1)90%  (9/10)90%  (0.9/1)
LoadXmlOperatorListUtility (): void 100% (1/1)100% (3/3)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.xml.handler.parser;
17 
18import java.io.File;
19import java.util.List;
20 
21import javax.xml.parsers.ParserConfigurationException;
22 
23import org.qedeq.base.trace.Trace;
24import org.qedeq.kernel.bo.module.InternalKernelServices;
25import org.qedeq.kernel.se.common.ModuleService;
26import org.qedeq.kernel.se.common.SourceFileExceptionList;
27import org.qedeq.kernel.xml.handler.common.SaxDefaultHandler;
28import org.qedeq.kernel.xml.parser.SaxParser;
29import org.xml.sax.SAXException;
30import org.xml.sax.SAXParseException;
31 
32 
33/**
34 * Load operator list from an XML file.
35 *
36 * @author  Michael Meyling
37 */
38public final class LoadXmlOperatorListUtility implements ModuleService {
39 
40    /** This class. */
41    private static final Class CLASS = LoadXmlOperatorListUtility.class;
42 
43    /**
44     * Constructor.
45     */
46    private LoadXmlOperatorListUtility() {
47        // nothing to do
48    }
49 
50    /**
51     * Get operator list out of XML file.
52     *
53     * @param   services        Kernel services.    TODO m31 20100830: is this really necessary?
54     * @param   from            Read this XML file.
55     * @return  Operator list.
56     * @throws  SourceFileExceptionList    Loading failed.
57     */
58    public static List getOperatorList(final InternalKernelServices services, final File from)
59            throws SourceFileExceptionList {
60        final String method = "List getOperatorList(String)";
61        final LoadXmlOperatorListUtility util = new LoadXmlOperatorListUtility();
62        try {
63            Trace.begin(CLASS, method);
64            Trace.param(CLASS, method, "from", from);
65            SaxDefaultHandler handler = new SaxDefaultHandler(util);
66            ParserHandler simple = new ParserHandler(handler);
67            handler.setBasisDocumentHandler(simple);
68            SaxParser parser = new SaxParser(util, handler);
69            parser.parse(from, null);
70            return simple.getOperators();
71        } catch (RuntimeException e) {
72            Trace.fatal(CLASS, "Programming error.", method, e);
73            throw services.createSourceFileExceptionList(
74                ParserErrors.PARSER_PROGRAMMING_ERROR_CODE,
75                ParserErrors.PARSER_PROGRAMMING_ERROR_TEXT,
76                "" + from, e);
77        } catch (ParserConfigurationException e) {
78            Trace.fatal(CLASS, "Parser configuration error.", method, e);
79            throw services.createSourceFileExceptionList(
80                ParserErrors.PARSER_CONFIGURATION_ERROR_CODE,
81                ParserErrors.PARSER_CONFIGURATION_ERROR_TEXT,
82                "" + from, e);
83        } catch (final SAXParseException e) {
84            Trace.fatal(CLASS, "Configuration error, file corrupt: " + from, method, e);
85            throw services.createSourceFileExceptionList(
86                ParserErrors.XML_FILE_PARSING_FAILED_CODE,
87                ParserErrors.XML_FILE_PARSING_FAILED_TEXT,
88                "" + from, e);
89        } catch (SAXException e) {
90            Trace.fatal(CLASS, "Configuration error, file corrupt: " + from, method, e);
91            throw services.createSourceFileExceptionList(
92                ParserErrors.XML_FILE_PARSING_FAILED_CODE,
93                ParserErrors.XML_FILE_PARSING_FAILED_TEXT,
94                "" + from, e);
95        } catch (javax.xml.parsers.FactoryConfigurationError e) {
96            Trace.trace(CLASS, method, e);
97            throw services.createSourceFileExceptionList(
98                ParserErrors.PARSER_FACTORY_CONFIGURATION_CODE,
99                ParserErrors.PARSER_FACTORY_CONFIGURATION_TEXT,
100                "" + from, new RuntimeException(
101                ParserErrors.PARSER_FACTORY_CONFIGURATION_TEXT, e));
102        } finally {
103            Trace.end(CLASS, method);
104        }
105    }
106 
107    public String getServiceId() {
108        return CLASS.getName();
109    }
110 
111    public String getServiceAction() {
112        return "Operator Loader";
113    }
114 
115    public String getServiceDescription() {
116        return "loads XML descriptoin of mathematical operators";
117    }
118 
119}

[all classes][org.qedeq.kernel.xml.handler.parser]
EMMA 2.1.5320 (stable) (C) Vladimir Roubtsov