Clover Coverage Report
Coverage timestamp: Fri May 24 2013 13:47:27 UTC
../../../../../../img/srcFileCovDistChart5.png 87% of files have more coverage
25   119   10   5
0   74   0.4   5
5     2  
1    
 
  LoadXmlOperatorListUtility       Line # 38 25 10 46.7% 0.46666667
 
  (99)
 
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.xml.handler.parser;
17   
18    import java.io.File;
19    import java.util.List;
20   
21    import javax.xml.parsers.ParserConfigurationException;
22   
23    import org.qedeq.base.trace.Trace;
24    import org.qedeq.kernel.bo.module.InternalKernelServices;
25    import org.qedeq.kernel.se.common.Plugin;
26    import org.qedeq.kernel.se.common.SourceFileExceptionList;
27    import org.qedeq.kernel.xml.handler.common.SaxDefaultHandler;
28    import org.qedeq.kernel.xml.parser.SaxParser;
29    import org.xml.sax.SAXException;
30    import org.xml.sax.SAXParseException;
31   
32   
33    /**
34    * Load operator list from an XML file.
35    *
36    * @author Michael Meyling
37    */
 
38    public final class LoadXmlOperatorListUtility implements Plugin {
39   
40    /** This class. */
41    private static final Class CLASS = LoadXmlOperatorListUtility.class;
42   
43    /**
44    * Constructor.
45    */
 
46  99 toggle 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  99 toggle public static List getOperatorList(final InternalKernelServices services, final File from)
59    throws SourceFileExceptionList {
60  99 final String method = "List getOperatorList(String)";
61  99 final LoadXmlOperatorListUtility util = new LoadXmlOperatorListUtility();
62  99 try {
63  99 Trace.begin(CLASS, method);
64  99 Trace.param(CLASS, method, "from", from);
65  99 SaxDefaultHandler handler = new SaxDefaultHandler(util);
66  99 ParserHandler simple = new ParserHandler(handler);
67  99 handler.setBasisDocumentHandler(simple);
68  99 SaxParser parser = new SaxParser(util, handler);
69  99 parser.parse(from, null);
70  99 return simple.getOperators();
71    } catch (RuntimeException e) {
72  0 Trace.fatal(CLASS, "Programming error.", method, e);
73  0 throw services.createSourceFileExceptionList(
74    ParserErrors.PARSER_PROGRAMMING_ERROR_CODE,
75    ParserErrors.PARSER_PROGRAMMING_ERROR_TEXT,
76    "" + from, e);
77    } catch (ParserConfigurationException e) {
78  0 Trace.fatal(CLASS, "Parser configuration error.", method, e);
79  0 throw services.createSourceFileExceptionList(
80    ParserErrors.PARSER_CONFIGURATION_ERROR_CODE,
81    ParserErrors.PARSER_CONFIGURATION_ERROR_TEXT,
82    "" + from, e);
83    } catch (final SAXParseException e) {
84  0 Trace.fatal(CLASS, "Configuration error, file corrupt: " + from, method, e);
85  0 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  0 Trace.fatal(CLASS, "Configuration error, file corrupt: " + from, method, e);
91  0 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  0 Trace.trace(CLASS, method, e);
97  0 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  99 Trace.end(CLASS, method);
104    }
105    }
106   
 
107  0 toggle public String getServiceId() {
108  0 return CLASS.getName();
109    }
110   
 
111  0 toggle public String getServiceAction() {
112  0 return "Operator Loader";
113    }
114   
 
115  0 toggle public String getServiceDescription() {
116  0 return "loads XML descriptoin of mathematical operators";
117    }
118   
119    }