2 // http://www.saxproject.org
3 // No warranty; no copyright -- use this as you will.
4 // $Id: ErrorHandler.java,v 1.10 2004/03/08 13:01:00 dmegginson Exp $
10 * Basic interface for SAX error handlers.
13 * <em>This module, both source code and documentation, is in the
14 * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
15 * See <a href='http://www.saxproject.org'>http://www.saxproject.org</a>
16 * for further information.
19 * <p>If a SAX application needs to implement customized error
20 * handling, it must implement this interface and then register an
21 * instance with the XML reader using the
22 * {@link org.xml.sax.XMLReader#setErrorHandler setErrorHandler}
23 * method. The parser will then report all errors and warnings
24 * through this interface.</p>
26 * <p><strong>WARNING:</strong> If an application does <em>not</em>
27 * register an ErrorHandler, XML parsing errors will go unreported,
28 * except that <em>SAXParseException</em>s will be thrown for fatal errors.
29 * In order to detect validity errors, an ErrorHandler that does something
30 * with {@link #error error()} calls must be registered.</p>
32 * <p>For XML processing errors, a SAX driver must use this interface
33 * in preference to throwing an exception: it is up to the application
34 * to decide whether to throw an exception for different types of
35 * errors and warnings. Note, however, that there is no requirement that
36 * the parser continue to report additional errors after a call to
37 * {@link #fatalError fatalError}. In other words, a SAX driver class
38 * may throw an exception after reporting any fatalError.
39 * Also parsers may throw appropriate exceptions for non-XML errors.
40 * For example, {@link XMLReader#parse XMLReader.parse()} would throw
41 * an IOException for errors accessing entities or the document.</p>
44 * @author David Megginson
45 * @version 2.0.1+ (sax2r3pre1)
46 * @see org.xml.sax.XMLReader#setErrorHandler
47 * @see org.xml.sax.SAXParseException
49 public interface ErrorHandler {
53 * Receive notification of a warning.
55 * <p>SAX parsers will use this method to report conditions that
56 * are not errors or fatal errors as defined by the XML
57 * recommendation. The default behaviour is to take no
60 * <p>The SAX parser must continue to provide normal parsing events
61 * after invoking this method: it should still be possible for the
62 * application to process the document through to the end.</p>
64 * <p>Filters may use this method to report other, non-XML warnings
67 * @param exception The warning information encapsulated in a
68 * SAX parse exception.
69 * @exception org.xml.sax.SAXException Any SAX exception, possibly
70 * wrapping another exception.
71 * @see org.xml.sax.SAXParseException
73 public abstract void warning (SAXParseException exception)
78 * Receive notification of a recoverable error.
80 * <p>This corresponds to the definition of "error" in section 1.2
81 * of the W3C XML 1.0 Recommendation. For example, a validating
82 * parser would use this callback to report the violation of a
83 * validity constraint. The default behaviour is to take no
86 * <p>The SAX parser must continue to provide normal parsing
87 * events after invoking this method: it should still be possible
88 * for the application to process the document through to the end.
89 * If the application cannot do so, then the parser should report
90 * a fatal error even if the XML recommendation does not require
93 * <p>Filters may use this method to report other, non-XML errors
96 * @param exception The error information encapsulated in a
97 * SAX parse exception.
98 * @exception org.xml.sax.SAXException Any SAX exception, possibly
99 * wrapping another exception.
100 * @see org.xml.sax.SAXParseException
102 public abstract void error (SAXParseException exception)
107 * Receive notification of a non-recoverable error.
109 * <p><strong>There is an apparent contradiction between the
110 * documentation for this method and the documentation for {@link
111 * org.xml.sax.ContentHandler#endDocument}. Until this ambiguity
112 * is resolved in a future major release, clients should make no
113 * assumptions about whether endDocument() will or will not be
114 * invoked when the parser has reported a fatalError() or thrown
115 * an exception.</strong></p>
117 * <p>This corresponds to the definition of "fatal error" in
118 * section 1.2 of the W3C XML 1.0 Recommendation. For example, a
119 * parser would use this callback to report the violation of a
120 * well-formedness constraint.</p>
122 * <p>The application must assume that the document is unusable
123 * after the parser has invoked this method, and should continue
124 * (if at all) only for the sake of collecting additional error
125 * messages: in fact, SAX parsers are free to stop reporting any
126 * other events once this method has been invoked.</p>
128 * @param exception The error information encapsulated in a
129 * SAX parse exception.
130 * @exception org.xml.sax.SAXException Any SAX exception, possibly
131 * wrapping another exception.
132 * @see org.xml.sax.SAXParseException
134 public abstract void fatalError (SAXParseException exception)
139 // end of ErrorHandler.java