Clover Coverage Report
Coverage timestamp: Sat Sep 18 2010 04:09:52 UTC
../../../../../../img/srcFileCovDistChart5.png 77% of files have more coverage
25   104   10   5
0   59   0.4   5
5     2  
1    
 
  LoadXmlOperatorListUtility       Line # 38 25 10 46.7% 0.46666667
 
  (92)
 
1    /* This file is part of the project "Hilbert II" - http://www.qedeq.org
2    *
3    * Copyright 2000-2010, 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.common.Plugin;
26    import org.qedeq.kernel.common.SourceFileExceptionList;
27    import org.qedeq.kernel.xml.parser.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  92 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  92 toggle public static List getOperatorList(final InternalKernelServices services, final File from)
59    throws SourceFileExceptionList {
60  92 final String method = "List getOperatorList(String)";
61  92 final LoadXmlOperatorListUtility util = new LoadXmlOperatorListUtility();
62  92 try {
63  92 Trace.begin(CLASS, method);
64  92 Trace.param(CLASS, method, "from", from);
65  92 SaxDefaultHandler handler = new SaxDefaultHandler(util);
66  92 ParserHandler simple = new ParserHandler(handler);
67  92 handler.setBasisDocumentHandler(simple);
68  92 SaxParser parser = new SaxParser(util, handler);
69  92 parser.parse(from, null);
70  92 return simple.getOperators();
71    } catch (RuntimeException e) {
72  0 Trace.fatal(CLASS, "Programming error.", method, e);
73  0 throw services.createSourceFileExceptionList("" + from, e);
74    } catch (ParserConfigurationException e) {
75  0 Trace.fatal(CLASS, "Parser configuration error.", method, e);
76  0 throw services.createSourceFileExceptionList(from + "", e);
77    } catch (final SAXParseException e) {
78  0 Trace.fatal(CLASS, "Configuration error, file corrupt: " + from, method, e);
79  0 throw services.createSourceFileExceptionList("" + from, e);
80    } catch (SAXException e) {
81  0 throw services.createSourceFileExceptionList("" + from, e);
82    } catch (javax.xml.parsers.FactoryConfigurationError e) {
83  0 Trace.trace(CLASS, method, e);
84  0 final String msg = "SAX Parser not in classpath, "
85    + "add for example \"xercesImpl.jar\" and \"xml-apis.jar\".";
86  0 throw services.createSourceFileExceptionList("" + from, new RuntimeException(msg, e));
87    } finally {
88  92 Trace.end(CLASS, method);
89    }
90    }
91   
 
92  0 toggle public String getPluginId() {
93  0 return CLASS.getName();
94    }
95   
 
96  0 toggle public String getPluginName() {
97  0 return "Operator Loader";
98    }
99   
 
100  0 toggle public String getPluginDescription() {
101  0 return "loads XML descriptoin of mathematical operators";
102    }
103   
104    }