Clover coverage report - QedeqKernelSe Coverage Report
Coverage timestamp: Do Mai 10 2007 03:16:40 CEST
file stats: LOC: 105   Methods: 3
NCLOC: 58   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
ModuleDataException2XmlFileException.java 75% 68,2% 66,7% 69%
coverage coverage
 1    /* $Id: ModuleDataException2XmlFileException.java,v 1.2 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.mapper;
 19   
 20    import java.io.IOException;
 21   
 22    import javax.xml.parsers.ParserConfigurationException;
 23   
 24    import org.qedeq.kernel.base.module.Qedeq;
 25    import org.qedeq.kernel.bo.module.ModuleContext;
 26    import org.qedeq.kernel.bo.module.ModuleDataException;
 27    import org.qedeq.kernel.common.SourceArea;
 28    import org.qedeq.kernel.common.XmlFileException;
 29    import org.qedeq.kernel.common.XmlFileExceptionList;
 30    import org.qedeq.kernel.trace.Trace;
 31    import org.qedeq.kernel.xml.parser.DefaultXmlFileExceptionList;
 32    import org.qedeq.kernel.xml.tracker.SimpleXPath;
 33    import org.qedeq.kernel.xml.tracker.XPathLocationFinder;
 34    import org.xml.sax.SAXException;
 35   
 36   
 37    /**
 38    * Converts a {@link org.qedeq.kernel.bo.module.ModuleDataException} into a
 39    * {@link org.qedeq.kernel.common.XmlFileException}.
 40    *
 41    * @version $Revision: 1.2 $
 42    * @author Michael Meyling
 43    */
 44    public final class ModuleDataException2XmlFileException {
 45   
 46    /**
 47    * Constructor.
 48    */
 49  0 private ModuleDataException2XmlFileException() {
 50    // nothing to do
 51    }
 52   
 53  5 public static final XmlFileExceptionList createXmlFileExceptionList(final ModuleDataException
 54    exception, final Qedeq qedeq) {
 55  5 final DefaultXmlFileExceptionList list = new DefaultXmlFileExceptionList();
 56  5 final XmlFileException e = new XmlFileException(exception, createSourceArea(qedeq,
 57    exception.getContext()),
 58    createSourceArea(qedeq, exception.getReferenceContext()));
 59  5 list.add(e);
 60  5 return list;
 61    }
 62   
 63    /**
 64    * Get area in XML source file for QEDEQ module context.
 65    *
 66    * @param qedeq Look at this QEDEQ module.
 67    * @param context Search for this context.
 68    * @return Created file area. Maybe <code>null</code>.
 69    */
 70  10 public static SourceArea createSourceArea(final Qedeq qedeq, final ModuleContext context) {
 71  10 final String method = "createSourceArea(Qedeq, ModuleContext)";
 72  10 if (qedeq == null || context == null) {
 73  3 return null;
 74    }
 75  7 final String xpath;
 76  7 try {
 77  7 xpath = Context2SimpleXPath.getXPath(context, qedeq).toString();
 78    } catch (ModuleDataException e) {
 79  0 Trace.trace(XmlFileException.class, method, e);
 80  0 return null;
 81    };
 82   
 83  7 SimpleXPath find = null;
 84  7 try {
 85  7 find = XPathLocationFinder.getXPathLocation(
 86    context.getModuleLocation(), xpath);
 87  7 if (find.getStartLocation() == null) {
 88  0 return null;
 89    }
 90  7 return new SourceArea(find.getStartLocation().getAddress(),
 91    find.getStartLocation().getLocalAddress(), find.getStartLocation(),
 92    find.getEndLocation());
 93    } catch (ParserConfigurationException e) {
 94  0 Trace.trace(XmlFileException.class, method, e);
 95    } catch (SAXException e) {
 96  0 Trace.trace(XmlFileException.class, method, e);
 97    } catch (IOException e) {
 98  0 Trace.trace(XmlFileException.class, method, e);
 99    }
 100  0 return null;
 101    }
 102   
 103   
 104   
 105    }