Clover Coverage Report
Coverage timestamp: Fri May 24 2013 13:47:27 UTC
../../../../../img/srcFileCovDistChart8.png 62% of files have more coverage
17   103   4   4.25
0   49   0.24   4
4     1  
1    
 
  SaxErrorHandler       Line # 34 17 4 76.2% 0.7619048
 
  (490)
 
1    /* This file is part of the project "Hilbert II" - http://www.qedeq.org
2    *
3    * Copyright 2000-2013, Michael Meyling <mime@qedeq.org>.
4    *
5    * "Hilbert II" is free software; you can redistribute
6    * it and/or modify it under the terms of the GNU General Public
7    * License as published by the Free Software Foundation; either
8    * version 2 of the License, or (at your option) any later version.
9    *
10    * This program is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13    * GNU General Public License for more details.
14    */
15   
16    package org.qedeq.kernel.xml.parser;
17   
18    import org.qedeq.base.io.SourceArea;
19    import org.qedeq.base.io.SourcePosition;
20    import org.qedeq.base.trace.Trace;
21    import org.qedeq.kernel.se.common.Plugin;
22    import org.qedeq.kernel.se.common.SourceFileException;
23    import org.qedeq.kernel.se.common.SourceFileExceptionList;
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    * @author Michael Meyling
33    */
 
34    public class SaxErrorHandler implements ErrorHandler {
35   
36    /** This class. */
37    private static final Class CLASS = SaxErrorHandler.class;
38   
39    /** Error code for Exceptions thrown by the SAXParser. */
40    public static final int SAX_PARSER_EXCEPTION = 9001;
41   
42    /** This plugin is currently working. */
43    private final Plugin plugin;
44   
45    /** File that is parsed. */
46    private final String url;
47   
48    /** Collects errors. */
49    private final SourceFileExceptionList list;
50   
51    /**
52    * Constructor.
53    *
54    * @param plugin This plugin generated the error.
55    * @param url URL that is parsed.
56    * @param list Collector for the SAX exceptions.
57    */
 
58  1858 toggle public SaxErrorHandler(final Plugin plugin, final String url,
59    final SourceFileExceptionList list) {
60  1858 super();
61  1858 Trace.param(CLASS, this, "SaxErrorHandler", "url", url);
62  1858 this.plugin = plugin;
63  1858 this.url = url;
64  1858 this.list = list;
65    }
66   
67    /* (non-Javadoc)
68    * @see org.xml.sax.ErrorHandler#warning(org.xml.sax.SAXParseException)
69    */
 
70  0 toggle public final void warning(final SAXParseException e) throws SAXException {
71  0 final SourceFileException sf = new SourceFileException(plugin, SAX_PARSER_EXCEPTION, e.getMessage(),
72    e, new SourceArea(url, new SourcePosition(e.getLineNumber(), 1),
73    new SourcePosition(e.getLineNumber(), e.getColumnNumber())), null);
74  0 Trace.trace(CLASS, this, "warning", e);
75  0 Trace.trace(CLASS, this, "warning", sf);
76  0 list.add(sf);
77    }
78   
79    /* (non-Javadoc)
80    * @see org.xml.sax.ErrorHandler#error(org.xml.sax.SAXParseException)
81    */
 
82  52 toggle public final void error(final SAXParseException e) throws SAXException {
83  52 final SourceFileException sf = new SourceFileException(plugin, SAX_PARSER_EXCEPTION, e.getMessage(),
84    e, new SourceArea(url, new SourcePosition(e.getLineNumber(), 1),
85    new SourcePosition(e.getLineNumber(), e.getColumnNumber())), null);
86  52 Trace.trace(CLASS, this, "error", e);
87  52 Trace.trace(CLASS, this, "error", sf);
88  52 list.add(sf);
89    }
90   
91    /* (non-Javadoc)
92    * @see org.xml.sax.ErrorHandler#fatalError(org.xml.sax.SAXParseException)
93    */
 
94  3 toggle public final void fatalError(final SAXParseException e) throws SAXException {
95  3 final SourceFileException sf = new SourceFileException(plugin, SAX_PARSER_EXCEPTION, e.getMessage(),
96    e, new SourceArea(url, new SourcePosition(e.getLineNumber(), 1),
97    new SourcePosition(e.getLineNumber(), e.getColumnNumber())), null);
98  3 Trace.trace(CLASS, this, "fatalError", e);
99  3 Trace.trace(CLASS, this, "fatalError", sf);
100  3 list.add(sf);
101    }
102   
103    }