EMMA Coverage Report (generated Fri Feb 14 08:28:31 UTC 2014)
[all classes][org.qedeq.kernel.xml.parser]

COVERAGE SUMMARY FOR SOURCE FILE [SaxErrorHandler.java]

nameclass, %method, %block, %line, %
SaxErrorHandler.java100% (1/1)80%  (4/5)72%  (115/160)77%  (16.9/22)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class SaxErrorHandler100% (1/1)80%  (4/5)72%  (115/160)77%  (16.9/22)
warning (SAXParseException): void 0%   (0/1)0%   (0/44)0%   (0/5)
<static initializer> 100% (1/1)90%  (9/10)90%  (0.9/1)
SaxErrorHandler (ModuleService, String, SourceFileExceptionList): void 100% (1/1)100% (18/18)100% (6/6)
error (SAXParseException): void 100% (1/1)100% (44/44)100% (5/5)
fatalError (SAXParseException): void 100% (1/1)100% (44/44)100% (5/5)

1/* This file is part of the project "Hilbert II" - http://www.qedeq.org
2 *
3 * Copyright 2000-2014,  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 
16package org.qedeq.kernel.xml.parser;
17 
18import org.qedeq.base.io.SourceArea;
19import org.qedeq.base.io.SourcePosition;
20import org.qedeq.base.trace.Trace;
21import org.qedeq.kernel.se.common.ModuleService;
22import org.qedeq.kernel.se.common.SourceFileException;
23import org.qedeq.kernel.se.common.SourceFileExceptionList;
24import org.xml.sax.ErrorHandler;
25import org.xml.sax.SAXException;
26import org.xml.sax.SAXParseException;
27 
28 
29/**
30 * Error handler for XML parsing.
31 *
32 * @author  Michael Meyling
33 */
34public 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 ModuleService 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    public SaxErrorHandler(final ModuleService plugin, final String url,
59            final SourceFileExceptionList list) {
60        super();
61        Trace.param(CLASS, this, "SaxErrorHandler", "url", url);
62        this.plugin = plugin;
63        this.url = url;
64        this.list = list;
65    }
66 
67    /* (non-Javadoc)
68     * @see org.xml.sax.ErrorHandler#warning(org.xml.sax.SAXParseException)
69     */
70    public final void warning(final SAXParseException e) throws SAXException {
71        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        Trace.trace(CLASS, this, "warning", e);
75        Trace.trace(CLASS, this, "warning", sf);
76        list.add(sf);
77    }
78 
79    /* (non-Javadoc)
80     * @see org.xml.sax.ErrorHandler#error(org.xml.sax.SAXParseException)
81     */
82    public final void error(final SAXParseException e) throws SAXException {
83        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        Trace.trace(CLASS, this, "error", e);
87        Trace.trace(CLASS, this, "error", sf);
88        list.add(sf);
89    }
90 
91    /* (non-Javadoc)
92     * @see org.xml.sax.ErrorHandler#fatalError(org.xml.sax.SAXParseException)
93     */
94    public final void fatalError(final SAXParseException e) throws SAXException {
95        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        Trace.trace(CLASS, this, "fatalError", e);
99        Trace.trace(CLASS, this, "fatalError", sf);
100        list.add(sf);
101    }
102 
103}

[all classes][org.qedeq.kernel.xml.parser]
EMMA 2.1.5320 (stable) (C) Vladimir Roubtsov