Path: blob/aarch64-shenandoah-jdk8u272-b10/jaxp/src/org/xml/sax/ErrorHandler.java
48534 views
/*1* Copyright (c) 2000, 2005, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425// SAX error handler.26// http://www.saxproject.org27// No warranty; no copyright -- use this as you will.28// $Id: ErrorHandler.java,v 1.2 2004/11/03 22:44:52 jsuttor Exp $2930package org.xml.sax;313233/**34* Basic interface for SAX error handlers.35*36* <blockquote>37* <em>This module, both source code and documentation, is in the38* Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>39* See <a href='http://www.saxproject.org'>http://www.saxproject.org</a>40* for further information.41* </blockquote>42*43* <p>If a SAX application needs to implement customized error44* handling, it must implement this interface and then register an45* instance with the XML reader using the46* {@link org.xml.sax.XMLReader#setErrorHandler setErrorHandler}47* method. The parser will then report all errors and warnings48* through this interface.</p>49*50* <p><strong>WARNING:</strong> If an application does <em>not</em>51* register an ErrorHandler, XML parsing errors will go unreported,52* except that <em>SAXParseException</em>s will be thrown for fatal errors.53* In order to detect validity errors, an ErrorHandler that does something54* with {@link #error error()} calls must be registered.</p>55*56* <p>For XML processing errors, a SAX driver must use this interface57* in preference to throwing an exception: it is up to the application58* to decide whether to throw an exception for different types of59* errors and warnings. Note, however, that there is no requirement that60* the parser continue to report additional errors after a call to61* {@link #fatalError fatalError}. In other words, a SAX driver class62* may throw an exception after reporting any fatalError.63* Also parsers may throw appropriate exceptions for non-XML errors.64* For example, {@link XMLReader#parse XMLReader.parse()} would throw65* an IOException for errors accessing entities or the document.</p>66*67* @since SAX 1.068* @author David Megginson69* @see org.xml.sax.XMLReader#setErrorHandler70* @see org.xml.sax.SAXParseException71*/72public interface ErrorHandler {737475/**76* Receive notification of a warning.77*78* <p>SAX parsers will use this method to report conditions that79* are not errors or fatal errors as defined by the XML80* recommendation. The default behaviour is to take no81* action.</p>82*83* <p>The SAX parser must continue to provide normal parsing events84* after invoking this method: it should still be possible for the85* application to process the document through to the end.</p>86*87* <p>Filters may use this method to report other, non-XML warnings88* as well.</p>89*90* @param exception The warning information encapsulated in a91* SAX parse exception.92* @exception org.xml.sax.SAXException Any SAX exception, possibly93* wrapping another exception.94* @see org.xml.sax.SAXParseException95*/96public abstract void warning (SAXParseException exception)97throws SAXException;9899100/**101* Receive notification of a recoverable error.102*103* <p>This corresponds to the definition of "error" in section 1.2104* of the W3C XML 1.0 Recommendation. For example, a validating105* parser would use this callback to report the violation of a106* validity constraint. The default behaviour is to take no107* action.</p>108*109* <p>The SAX parser must continue to provide normal parsing110* events after invoking this method: it should still be possible111* for the application to process the document through to the end.112* If the application cannot do so, then the parser should report113* a fatal error even if the XML recommendation does not require114* it to do so.</p>115*116* <p>Filters may use this method to report other, non-XML errors117* as well.</p>118*119* @param exception The error information encapsulated in a120* SAX parse exception.121* @exception org.xml.sax.SAXException Any SAX exception, possibly122* wrapping another exception.123* @see org.xml.sax.SAXParseException124*/125public abstract void error (SAXParseException exception)126throws SAXException;127128129/**130* Receive notification of a non-recoverable error.131*132* <p><strong>There is an apparent contradiction between the133* documentation for this method and the documentation for {@link134* org.xml.sax.ContentHandler#endDocument}. Until this ambiguity135* is resolved in a future major release, clients should make no136* assumptions about whether endDocument() will or will not be137* invoked when the parser has reported a fatalError() or thrown138* an exception.</strong></p>139*140* <p>This corresponds to the definition of "fatal error" in141* section 1.2 of the W3C XML 1.0 Recommendation. For example, a142* parser would use this callback to report the violation of a143* well-formedness constraint.</p>144*145* <p>The application must assume that the document is unusable146* after the parser has invoked this method, and should continue147* (if at all) only for the sake of collecting additional error148* messages: in fact, SAX parsers are free to stop reporting any149* other events once this method has been invoked.</p>150*151* @param exception The error information encapsulated in a152* SAX parse exception.153* @exception org.xml.sax.SAXException Any SAX exception, possibly154* wrapping another exception.155* @see org.xml.sax.SAXParseException156*/157public abstract void fatalError (SAXParseException exception)158throws SAXException;159160}161162// end of ErrorHandler.java163164165