|
|||||||||||||||||||
| Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
| SaxErrorHandler.java | - | 83,3% | 75% | 80% |
|
||||||||||||||
| 1 | /* $Id: SaxErrorHandler.java,v 1.14 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.parser; | |
| 19 | ||
| 20 | import java.net.URL; | |
| 21 | ||
| 22 | import org.qedeq.kernel.common.SyntaxException; | |
| 23 | import org.qedeq.kernel.common.SyntaxExceptionList; | |
| 24 | import org.xml.sax.ErrorHandler; | |
| 25 | import org.xml.sax.SAXException; | |
| 26 | import org.xml.sax.SAXParseException; | |
| 27 | ||
| 28 | ||
| 29 | /** | |
| 30 | * Error handler for XML parsing. | |
| 31 | * | |
| 32 | * @version $Revision: 1.14 $ | |
| 33 | * @author Michael Meyling | |
| 34 | */ | |
| 35 | public class SaxErrorHandler implements ErrorHandler { | |
| 36 | ||
| 37 | /** File that is parsed. */ | |
| 38 | private final URL url; | |
| 39 | ||
| 40 | /** Collects errors. */ | |
| 41 | private final SyntaxExceptionList list; | |
| 42 | ||
| 43 | /** | |
| 44 | * Constructor. | |
| 45 | * | |
| 46 | * @param url URL that is parsed. | |
| 47 | * @param list Collector for the SAX exceptions. | |
| 48 | */ | |
| 49 | 389 | public SaxErrorHandler(final URL url, final SyntaxExceptionList list) { |
| 50 | 389 | super(); |
| 51 | 389 | this.url = url; |
| 52 | 389 | this.list = list; |
| 53 | } | |
| 54 | ||
| 55 | /* (non-Javadoc) | |
| 56 | * @see org.xml.sax.ErrorHandler#warning(org.xml.sax.SAXParseException) | |
| 57 | */ | |
| 58 | 0 | public final void warning(final SAXParseException e) throws SAXException { |
| 59 | 0 | list.add(SyntaxException.createBySAXParseException(e, url)); |
| 60 | } | |
| 61 | ||
| 62 | /* (non-Javadoc) | |
| 63 | * @see org.xml.sax.ErrorHandler#error(org.xml.sax.SAXParseException) | |
| 64 | */ | |
| 65 | 9 | public final void error(final SAXParseException e) throws SAXException { |
| 66 | 9 | list.add(SyntaxException.createBySAXParseException(e, url)); |
| 67 | } | |
| 68 | ||
| 69 | /* (non-Javadoc) | |
| 70 | * @see org.xml.sax.ErrorHandler#fatalError(org.xml.sax.SAXParseException) | |
| 71 | */ | |
| 72 | 1 | public final void fatalError(final SAXParseException e) throws SAXException { |
| 73 | 1 | list.add(SyntaxException.createBySAXParseException(e, url)); |
| 74 | } | |
| 75 | ||
| 76 | } |
|
||||||||||