< prev index next >

src/java.xml/share/classes/org/xml/sax/ErrorHandler.java

Print this page


   1 /*
   2  * Copyright (c) 2000, 2005, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 111      * events after invoking this method: it should still be possible
 112      * for the application to process the document through to the end.
 113      * If the application cannot do so, then the parser should report
 114      * a fatal error even if the XML recommendation does not require
 115      * it to do so.</p>
 116      *
 117      * <p>Filters may use this method to report other, non-XML errors
 118      * as well.</p>
 119      *
 120      * @param exception The error information encapsulated in a
 121      *                  SAX parse exception.
 122      * @exception org.xml.sax.SAXException Any SAX exception, possibly
 123      *            wrapping another exception.
 124      * @see org.xml.sax.SAXParseException
 125      */
 126     public abstract void error (SAXParseException exception)
 127         throws SAXException;
 128 
 129 
 130     /**
 131      * Receive notification of a non-recoverable error.
 132      *
 133      * <p><strong>There is an apparent contradiction between the
 134      * documentation for this method and the documentation for {@link
 135      * org.xml.sax.ContentHandler#endDocument}.  Until this ambiguity
 136      * is resolved in a future major release, clients should make no
 137      * assumptions about whether endDocument() will or will not be
 138      * invoked when the parser has reported a fatalError() or thrown
 139      * an exception.</strong></p>
 140      *
 141      * <p>This corresponds to the definition of "fatal error" in
 142      * section 1.2 of the W3C XML 1.0 Recommendation.  For example, a
 143      * parser would use this callback to report the violation of a
 144      * well-formedness constraint.</p>
 145      *
 146      * <p>The application must assume that the document is unusable
 147      * after the parser has invoked this method, and should continue
 148      * (if at all) only for the sake of collecting additional error
 149      * messages: in fact, SAX parsers are free to stop reporting any
 150      * other events once this method has been invoked.</p>
 151      *
 152      * @param exception The error information encapsulated in a
 153      *                  SAX parse exception.
 154      * @exception org.xml.sax.SAXException Any SAX exception, possibly
 155      *            wrapping another exception.
 156      * @see org.xml.sax.SAXParseException
 157      */
 158     public abstract void fatalError (SAXParseException exception)
 159         throws SAXException;
 160 
 161 }
 162 
 163 // end of ErrorHandler.java
   1 /*
   2  * Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 111      * events after invoking this method: it should still be possible
 112      * for the application to process the document through to the end.
 113      * If the application cannot do so, then the parser should report
 114      * a fatal error even if the XML recommendation does not require
 115      * it to do so.</p>
 116      *
 117      * <p>Filters may use this method to report other, non-XML errors
 118      * as well.</p>
 119      *
 120      * @param exception The error information encapsulated in a
 121      *                  SAX parse exception.
 122      * @exception org.xml.sax.SAXException Any SAX exception, possibly
 123      *            wrapping another exception.
 124      * @see org.xml.sax.SAXParseException
 125      */
 126     public abstract void error (SAXParseException exception)
 127         throws SAXException;
 128 
 129 
 130     /**
 131      * Receive notification of a non-recoverable, fatal error.
 132      *
 133      * <p>
 134      * As defined in section 1.2 of the W3C XML 1.0 Recommendation, fatal errors
 135      * are those that would make it impossible for a parser to continue normal
 136      * processing. These include violation of a well-formedness constraint,
 137      * invalid encoding, and forbidden structural errors as described in the
 138      * W3C XML 1.0 Recommendation.
 139      *
 140      * @apiNote An application must assume that the parser can no longer perform
 141      * normal processing after reporting a fatal error and may stop by throwing
 142      * a {@link SAXException} without calling {@link ContentHandler#endDocument()}.
 143      * In addition, the parser cannot be expected to be able to return accurate
 144      * information about the logical structure on the rest of the document even
 145      * if it may be able to resume parsing.
 146      *
 147      * @implNote After invoking this method, the parser may stop processing by
 148      * throwing a {@link SAXException}, or implement a feature that can direct
 149      * it to continue after a fatal error. In the later case, it may report
 150      * events on the rest of the document without any guarantee of correctness.
 151      *
 152      * @param exception The error information encapsulated in a
 153      *                  {@link SAXParseException}.
 154      * @throws SAXException if the application chooses to discontinue the parsing


 155      */
 156     public abstract void fatalError (SAXParseException exception)
 157         throws SAXException;
 158 
 159 }
 160 
 161 // end of ErrorHandler.java
< prev index next >