Clover coverage report - QedeqKernelSe Coverage Report
Coverage timestamp: Do Mai 10 2007 03:16:40 CEST
file stats: LOC: 107   Methods: 2
NCLOC: 65   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
LoadXmlOperatorListUtility.java 50% 38,9% 50% 40%
coverage coverage
 1    /* $Id: LoadXmlOperatorListUtility.java,v 1.5 2007/05/10 00:37:52 m31 Exp $
 2    *
 3    * This file is part of the project "Hilbert II" - http://www.qedeq.org
 4    *
 5    * Copyright 2000-2007, 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.FileNotFoundException;
 21    import java.io.IOException;
 22    import java.net.URL;
 23    import java.util.List;
 24   
 25    import javax.xml.parsers.ParserConfigurationException;
 26   
 27    import org.qedeq.kernel.common.XmlFileExceptionList;
 28    import org.qedeq.kernel.trace.Trace;
 29    import org.qedeq.kernel.xml.parser.SaxDefaultHandler;
 30    import org.qedeq.kernel.xml.parser.SaxParser;
 31    import org.qedeq.kernel.xml.parser.DefaultXmlFileExceptionList;
 32    import org.xml.sax.SAXException;
 33    import org.xml.sax.SAXParseException;
 34   
 35   
 36    /**
 37    * Load operator list from an XML file.
 38    *
 39    * @version $Revision: 1.5 $
 40    * @author Michael Meyling
 41    */
 42    public final class LoadXmlOperatorListUtility {
 43   
 44    /**
 45    * Constructor.
 46    */
 47  0 private LoadXmlOperatorListUtility() {
 48    // nothing to do
 49    }
 50   
 51    /**
 52    * Get operator list out of XML file.
 53    *
 54    * @param from Read this XML file.
 55    * @return Operator list.
 56    * @throws XmlFileExceptionList Loading failed.
 57    */
 58  82 public static List getOperatorList(final String from) throws XmlFileExceptionList {
 59  82 final String method = "List getOperatorList(String)";
 60  82 URL url = null;
 61  82 try {
 62  82 Trace.begin(LoadXmlOperatorListUtility.class, method);
 63  82 Trace.param(LoadXmlOperatorListUtility.class, method, "from", from);
 64  82 url = LoadXmlOperatorListUtility.class.getResource("/" + from);
 65  82 if (url == null) {
 66  0 throw new FileNotFoundException(from);
 67    }
 68  82 SaxDefaultHandler handler = new SaxDefaultHandler();
 69  82 ParserHandler simple = new ParserHandler(handler);
 70  82 handler.setBasisDocumentHandler(simple);
 71  82 SaxParser parser = new SaxParser(handler);
 72  82 parser.parse(url);
 73  82 return simple.getOperators();
 74    } catch (RuntimeException e) {
 75  0 Trace.trace(LoadXmlOperatorListUtility.class, method, e);
 76  0 throw new DefaultXmlFileExceptionList(e);
 77    } catch (IOException e) {
 78  0 Trace.trace(LoadXmlOperatorListUtility.class, method, e);
 79  0 throw new DefaultXmlFileExceptionList(e);
 80    } catch (ParserConfigurationException e) {
 81  0 Trace.trace(LoadXmlOperatorListUtility.class, method, e);
 82  0 final DefaultXmlFileExceptionList list = new DefaultXmlFileExceptionList();
 83  0 list.add(e);
 84  0 throw list;
 85    } catch (final SAXParseException e) {
 86  0 Trace.trace(LoadXmlOperatorListUtility.class, method, e);
 87  0 final DefaultXmlFileExceptionList list = new DefaultXmlFileExceptionList();
 88  0 list.add(e);
 89  0 throw list;
 90    } catch (SAXException e) {
 91  0 Trace.trace(LoadXmlOperatorListUtility.class, method, e);
 92  0 final DefaultXmlFileExceptionList list = new DefaultXmlFileExceptionList();
 93  0 list.add(e);
 94  0 throw list;
 95    } catch (javax.xml.parsers.FactoryConfigurationError e) {
 96  0 Trace.trace(LoadXmlOperatorListUtility.class, method, e);
 97  0 final String msg = "SAX Parser not in classpath, "
 98    + "add for example \"xercesImpl.jar\" and \"xml-apis.jar\".";
 99  0 final DefaultXmlFileExceptionList list = new DefaultXmlFileExceptionList();
 100  0 list.add(new IOException(msg));
 101  0 throw list;
 102    } finally {
 103  82 Trace.end(LoadXmlOperatorListUtility.class, method);
 104    }
 105    }
 106   
 107    }