Clover Coverage Report
Coverage timestamp: Sa Aug 2 2008 13:56:27 CEST
../../../../../../img/srcFileCovDistChart5.png 74% of files have more coverage
26   100   7   13
0   56   0,27   2
2     3,5  
1    
 
  LoadXmlOperatorListUtility       Line # 40 26 7 42,9% 0.42857143
 
  (92)
 
1    /* $Id: LoadXmlOperatorListUtility.java,v 1.1 2008/07/26 08:00:52 m31 Exp $
2    *
3    * This file is part of the project "Hilbert II" - http://www.qedeq.org
4    *
5    * Copyright 2000-2008, Michael Meyling <mime@qedeq.org>.
6    *
7    * "Hilbert II" is free software; you can redistribute
8    * it and/or modify it under the terms of the GNU General Public
9    * License as published by the Free Software Foundation; either
10    * version 2 of the License, or (at your option) any later version.
11    *
12    * This program is distributed in the hope that it will be useful,
13    * but WITHOUT ANY WARRANTY; without even the implied warranty of
14    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15    * GNU General Public License for more details.
16    */
17   
18    package org.qedeq.kernel.xml.handler.parser;
19   
20    import java.io.File;
21    import java.util.List;
22   
23    import javax.xml.parsers.ParserConfigurationException;
24   
25    import org.qedeq.base.trace.Trace;
26    import org.qedeq.kernel.common.DefaultSourceFileExceptionList;
27    import org.qedeq.kernel.common.SourceFileExceptionList;
28    import org.qedeq.kernel.xml.parser.SaxDefaultHandler;
29    import org.qedeq.kernel.xml.parser.SaxParser;
30    import org.xml.sax.SAXException;
31    import org.xml.sax.SAXParseException;
32   
33   
34    /**
35    * Load operator list from an XML file.
36    *
37    * @version $Revision: 1.1 $
38    * @author Michael Meyling
39    */
 
40    public final class LoadXmlOperatorListUtility {
41   
42    /** This class. */
43    private static final Class CLASS = LoadXmlOperatorListUtility.class;
44   
45    /**
46    * Constructor.
47    */
 
48  0 toggle private LoadXmlOperatorListUtility() {
49    // nothing to do
50    }
51   
52    /**
53    * Get operator list out of XML file.
54    *
55    * @param from Read this XML file.
56    * @return Operator list.
57    * @throws SourceFileExceptionList Loading failed.
58    */
 
59  92 toggle public static List getOperatorList(final File from) throws SourceFileExceptionList {
60  92 final String method = "List getOperatorList(String)";
61  92 try {
62  92 Trace.begin(CLASS, method);
63  92 Trace.param(CLASS, method, "from", from);
64  92 SaxDefaultHandler handler = new SaxDefaultHandler();
65  92 ParserHandler simple = new ParserHandler(handler);
66  92 handler.setBasisDocumentHandler(simple);
67  92 SaxParser parser = new SaxParser(handler);
68  92 parser.parse(from, null);
69  92 return simple.getOperators();
70    } catch (RuntimeException e) {
71  0 Trace.trace(CLASS, method, e);
72  0 throw new DefaultSourceFileExceptionList(e);
73    } catch (ParserConfigurationException e) {
74  0 Trace.trace(CLASS, method, e);
75  0 final DefaultSourceFileExceptionList list = new DefaultSourceFileExceptionList(
76    new RuntimeException(e)); // TODO mime 20080404: search for better solution
77  0 throw list;
78    } catch (final SAXParseException e) {
79  0 Trace.trace(CLASS, method, e);
80  0 final DefaultSourceFileExceptionList list = new DefaultSourceFileExceptionList(
81    new RuntimeException(e)); // TODO mime 20080404: search for better solution
82  0 throw list;
83    } catch (SAXException e) {
84  0 Trace.trace(CLASS, method, e);
85  0 final DefaultSourceFileExceptionList list = new DefaultSourceFileExceptionList(
86    new RuntimeException(e)); // TODO mime 20080404: search for better solution
87  0 throw list;
88    } catch (javax.xml.parsers.FactoryConfigurationError e) {
89  0 Trace.trace(CLASS, method, e);
90  0 final String msg = "SAX Parser not in classpath, "
91    + "add for example \"xercesImpl.jar\" and \"xml-apis.jar\".";
92  0 final DefaultSourceFileExceptionList list = new DefaultSourceFileExceptionList(
93    new RuntimeException(msg)); // TODO mime 20080404: search for better solution
94  0 throw list;
95    } finally {
96  92 Trace.end(CLASS, method);
97    }
98    }
99   
100    }