Class | Line # | Actions | |||||
---|---|---|---|---|---|---|---|
DocumentErrorHandler | 26 | 6 | 0% | 3 | 9 |
1 | /* | |
2 | * See the NOTICE file distributed with this work for additional | |
3 | * information regarding copyright ownership. | |
4 | * | |
5 | * This is free software; you can redistribute it and/or modify it | |
6 | * under the terms of the GNU Lesser General Public License as | |
7 | * published by the Free Software Foundation; either version 2.1 of | |
8 | * the License, or (at your option) any later version. | |
9 | * | |
10 | * This software 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 GNU | |
13 | * Lesser General Public License for more details. | |
14 | * | |
15 | * You should have received a copy of the GNU Lesser General Public | |
16 | * License along with this software; if not, write to the Free | |
17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | |
18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. | |
19 | */ | |
20 | package com.xpn.xwiki.doc; | |
21 | ||
22 | import org.xml.sax.ErrorHandler; | |
23 | import org.xml.sax.SAXException; | |
24 | import org.xml.sax.SAXParseException; | |
25 | ||
26 | public class DocumentErrorHandler implements ErrorHandler | |
27 | { | |
28 | /** | |
29 | * Receive notification of a recoverable error. | |
30 | * <p> | |
31 | * This corresponds to the definition of "error" in section 1.2 of the W3C XML 1.0 Recommendation. For example, a | |
32 | * validating parser would use this callback to report the violation of a validity constraint. The default behaviour | |
33 | * is to take no action. | |
34 | * <p> | |
35 | * The SAX parser must continue to provide normal parsing events after invoking this method: it should still be | |
36 | * possible for the application to process the document through to the end. If the application cannot do so, then | |
37 | * the parser should report a fatal error even if the XML 1.0 recommendation does not require it to do so. | |
38 | * <p> | |
39 | * Filters may use this method to report other, non-XML errors as well. | |
40 | * | |
41 | * @param exception The error information encapsulated in a SAX parse exception. | |
42 | * @throws org.xml.sax.SAXException Any SAX exception, possibly wrapping another exception. | |
43 | * @see org.xml.sax.SAXParseException | |
44 | */ | |
45 | 0 | @Override |
46 | public void error(SAXParseException exception) throws SAXException | |
47 | { | |
48 | 0 | System.out.println("Error: "); |
49 | 0 | exception.printStackTrace(); |
50 | // To change body of implemented methods use File | Settings | File Templates. | |
51 | } | |
52 | ||
53 | /** | |
54 | * Receive notification of a non-recoverable error. | |
55 | * <p> | |
56 | * This corresponds to the definition of "fatal error" in section 1.2 of the W3C XML 1.0 Recommendation. For | |
57 | * example, a parser would use this callback to report the violation of a well-formedness constraint. | |
58 | * <p> | |
59 | * The application must assume that the document is unusable after the parser has invoked this method, and should | |
60 | * continue (if at all) only for the sake of collecting addition error messages: in fact, SAX parsers are free to | |
61 | * stop reporting any other events once this method has been invoked. | |
62 | * | |
63 | * @param exception The error information encapsulated in a SAX parse exception. | |
64 | * @throws org.xml.sax.SAXException Any SAX exception, possibly wrapping another exception. | |
65 | * @see org.xml.sax.SAXParseException | |
66 | */ | |
67 | 0 | @Override |
68 | public void fatalError(SAXParseException exception) throws SAXException | |
69 | { | |
70 | 0 | System.out.println("Fatal Error: "); |
71 | 0 | exception.printStackTrace(); |
72 | // To change body of implemented methods use File | Settings | File Templates. | |
73 | } | |
74 | ||
75 | /** | |
76 | * Receive notification of a warning. | |
77 | * <p> | |
78 | * SAX parsers will use this method to report conditions that are not errors or fatal errors as defined by the XML | |
79 | * 1.0 recommendation. The default behaviour is to take no action. | |
80 | * <p> | |
81 | * The SAX parser must continue to provide normal parsing events after invoking this method: it should still be | |
82 | * possible for the application to process the document through to the end. | |
83 | * <p> | |
84 | * Filters may use this method to report other, non-XML warnings as well. | |
85 | * | |
86 | * @param exception The warning information encapsulated in a SAX parse exception. | |
87 | * @throws org.xml.sax.SAXException Any SAX exception, possibly wrapping another exception. | |
88 | * @see org.xml.sax.SAXParseException | |
89 | */ | |
90 | 0 | @Override |
91 | public void warning(SAXParseException exception) throws SAXException | |
92 | { | |
93 | 0 | System.out.println("Warning: "); |
94 | 0 | exception.printStackTrace(); |
95 | // To change body of implemented methods use File | Settings | File Templates. | |
96 | } | |
97 | } |