Clover coverage report - QedeqKernelSe Coverage Report
Coverage timestamp: Do Mrz 27 2008 21:46:26 CET
file stats: LOC: 101   Methods: 4
NCLOC: 46   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
SaxErrorHandler.java - 75% 75% 75%
coverage coverage
 1    /* $Id: SaxErrorHandler.java,v 1.17 2008/03/27 05:16:29 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.parser;
 19   
 20    import java.net.URL;
 21   
 22    import org.qedeq.kernel.common.DefaultSourceFileExceptionList;
 23    import org.qedeq.kernel.common.SourceArea;
 24    import org.qedeq.kernel.common.SourceFileException;
 25    import org.qedeq.kernel.common.SourcePosition;
 26    import org.qedeq.kernel.trace.Trace;
 27    import org.xml.sax.ErrorHandler;
 28    import org.xml.sax.SAXException;
 29    import org.xml.sax.SAXParseException;
 30   
 31   
 32    /**
 33    * Error handler for XML parsing.
 34    *
 35    * @version $Revision: 1.17 $
 36    * @author Michael Meyling
 37    */
 38    public class SaxErrorHandler implements ErrorHandler {
 39   
 40    /** This class. */
 41    private static final Class CLASS = SaxErrorHandler.class;
 42   
 43    /** Error code for Exceptions thrown by the SAXParser. */
 44    public static final int SAX_PARSER_EXCEPTION = 9001;
 45   
 46    /** File that is parsed. */
 47    private final URL url;
 48   
 49    /** Collects errors. */
 50    private final DefaultSourceFileExceptionList list;
 51   
 52    /**
 53    * Constructor.
 54    *
 55    * @param url URL that is parsed.
 56    * @param list Collector for the SAX exceptions.
 57    */
 58  671 public SaxErrorHandler(final URL url, final DefaultSourceFileExceptionList list) {
 59  671 super();
 60  671 Trace.param(CLASS, this, "SaxErrorHandler", "url", url);
 61  671 this.url = url;
 62  671 this.list = list;
 63    }
 64   
 65    /* (non-Javadoc)
 66    * @see org.xml.sax.ErrorHandler#warning(org.xml.sax.SAXParseException)
 67    */
 68  0 public final void warning(final SAXParseException e) throws SAXException {
 69  0 final SourceFileException sf = new SourceFileException(SAX_PARSER_EXCEPTION, e.getMessage(),
 70    e, new SourceArea(url, new SourcePosition(url, e.getLineNumber(),
 71    e.getColumnNumber()), null), null);
 72  0 Trace.trace(CLASS, this, "warning", e);
 73  0 Trace.trace(CLASS, this, "warning", sf);
 74  0 list.add(sf);
 75    }
 76   
 77    /* (non-Javadoc)
 78    * @see org.xml.sax.ErrorHandler#error(org.xml.sax.SAXParseException)
 79    */
 80  45 public final void error(final SAXParseException e) throws SAXException {
 81  45 final SourceFileException sf = new SourceFileException(SAX_PARSER_EXCEPTION, e.getMessage(),
 82    e, new SourceArea(url, new SourcePosition(url, e.getLineNumber(),
 83    e.getColumnNumber()), null), null);
 84  45 Trace.trace(CLASS, this, "error", e);
 85  45 Trace.trace(CLASS, this, "error", sf);
 86  45 list.add(sf);
 87    }
 88   
 89    /* (non-Javadoc)
 90    * @see org.xml.sax.ErrorHandler#fatalError(org.xml.sax.SAXParseException)
 91    */
 92  5 public final void fatalError(final SAXParseException e) throws SAXException {
 93  5 final SourceFileException sf = new SourceFileException(SAX_PARSER_EXCEPTION, e.getMessage(),
 94    e, new SourceArea(url, new SourcePosition(url, e.getLineNumber(),
 95    e.getColumnNumber()), null), null);
 96  5 Trace.trace(CLASS, this, "fatalError", e);
 97  5 Trace.trace(CLASS, this, "fatalError", sf);
 98  5 list.add(sf);
 99    }
 100   
 101    }