Clover Coverage Report
Coverage timestamp: Sa Aug 2 2008 13:56:27 CEST
../../../../../img/srcFileCovDistChart8.png 47% of files have more coverage
16   104   4   4
0   49   0,25   4
4     1  
1    
 
  SaxErrorHandler       Line # 38 16 4 75% 0.75
 
  (134)
 
1    /* $Id: SaxErrorHandler.java,v 1.1 2008/07/26 08:00:50 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.base.trace.Trace;
23    import org.qedeq.kernel.common.DefaultSourceFileExceptionList;
24    import org.qedeq.kernel.common.SourceArea;
25    import org.qedeq.kernel.common.SourceFileException;
26    import org.qedeq.kernel.common.SourcePosition;
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.1 $
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  595 toggle public SaxErrorHandler(final URL url, final DefaultSourceFileExceptionList list) {
59  595 super();
60  595 Trace.param(CLASS, this, "SaxErrorHandler", "url", url);
61  595 this.url = url;
62  595 this.list = list;
63    }
64   
65    /* (non-Javadoc)
66    * @see org.xml.sax.ErrorHandler#warning(org.xml.sax.SAXParseException)
67    */
 
68  0 toggle 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    1), new SourcePosition(url, e.getLineNumber(),
72    e.getColumnNumber())), null);
73  0 Trace.trace(CLASS, this, "warning", e);
74  0 Trace.trace(CLASS, this, "warning", sf);
75  0 list.add(sf);
76    }
77   
78    /* (non-Javadoc)
79    * @see org.xml.sax.ErrorHandler#error(org.xml.sax.SAXParseException)
80    */
 
81  16 toggle public final void error(final SAXParseException e) throws SAXException {
82  16 final SourceFileException sf = new SourceFileException(SAX_PARSER_EXCEPTION, e.getMessage(),
83    e, new SourceArea(url, new SourcePosition(url, e.getLineNumber(),
84    1), new SourcePosition(url, e.getLineNumber(),
85    e.getColumnNumber())), null);
86  16 Trace.trace(CLASS, this, "error", e);
87  16 Trace.trace(CLASS, this, "error", sf);
88  16 list.add(sf);
89    }
90   
91    /* (non-Javadoc)
92    * @see org.xml.sax.ErrorHandler#fatalError(org.xml.sax.SAXParseException)
93    */
 
94  2 toggle public final void fatalError(final SAXParseException e) throws SAXException {
95  2 final SourceFileException sf = new SourceFileException(SAX_PARSER_EXCEPTION, e.getMessage(),
96    e, new SourceArea(url, new SourcePosition(url, e.getLineNumber(),
97    1), new SourcePosition(url, e.getLineNumber(),
98    e.getColumnNumber())), null);
99  2 Trace.trace(CLASS, this, "fatalError", e);
100  2 Trace.trace(CLASS, this, "fatalError", sf);
101  2 list.add(sf);
102    }
103   
104    }