Path: blob/aarch64-shenandoah-jdk8u272-b10/jaxp/src/org/xml/sax/Parser.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 parser interface.26// http://www.saxproject.org27// No warranty; no copyright -- use this as you will.28// $Id: Parser.java,v 1.2 2004/11/03 22:55:32 jsuttor Exp $2930package org.xml.sax;3132import java.io.IOException;33import java.util.Locale;343536/**37* Basic interface for SAX (Simple API for XML) parsers.38*39* <blockquote>40* <em>This module, both source code and documentation, is in the41* Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>42* See <a href='http://www.saxproject.org'>http://www.saxproject.org</a>43* for further information.44* </blockquote>45*46* <p>This was the main event supplier interface for SAX1; it has47* been replaced in SAX2 by {@link org.xml.sax.XMLReader XMLReader},48* which includes Namespace support and sophisticated configurability49* and extensibility.</p>50*51* <p>All SAX1 parsers must implement this basic interface: it allows52* applications to register handlers for different types of events53* and to initiate a parse from a URI, or a character stream.</p>54*55* <p>All SAX1 parsers must also implement a zero-argument constructor56* (though other constructors are also allowed).</p>57*58* <p>SAX1 parsers are reusable but not re-entrant: the application59* may reuse a parser object (possibly with a different input source)60* once the first parse has completed successfully, but it may not61* invoke the parse() methods recursively within a parse.</p>62*63* @deprecated This interface has been replaced by the SAX264* {@link org.xml.sax.XMLReader XMLReader}65* interface, which includes Namespace support.66* @since SAX 1.067* @author David Megginson68* @see org.xml.sax.EntityResolver69* @see org.xml.sax.DTDHandler70* @see org.xml.sax.DocumentHandler71* @see org.xml.sax.ErrorHandler72* @see org.xml.sax.HandlerBase73* @see org.xml.sax.InputSource74*/75public interface Parser76{7778/**79* Allow an application to request a locale for errors and warnings.80*81* <p>SAX parsers are not required to provide localisation for errors82* and warnings; if they cannot support the requested locale,83* however, they must throw a SAX exception. Applications may84* not request a locale change in the middle of a parse.</p>85*86* @param locale A Java Locale object.87* @exception org.xml.sax.SAXException Throws an exception88* (using the previous or default locale) if the89* requested locale is not supported.90* @see org.xml.sax.SAXException91* @see org.xml.sax.SAXParseException92*/93public abstract void setLocale (Locale locale)94throws SAXException;959697/**98* Allow an application to register a custom entity resolver.99*100* <p>If the application does not register an entity resolver, the101* SAX parser will resolve system identifiers and open connections102* to entities itself (this is the default behaviour implemented in103* HandlerBase).</p>104*105* <p>Applications may register a new or different entity resolver106* in the middle of a parse, and the SAX parser must begin using107* the new resolver immediately.</p>108*109* @param resolver The object for resolving entities.110* @see EntityResolver111* @see HandlerBase112*/113public abstract void setEntityResolver (EntityResolver resolver);114115116/**117* Allow an application to register a DTD event handler.118*119* <p>If the application does not register a DTD handler, all DTD120* events reported by the SAX parser will be silently121* ignored (this is the default behaviour implemented by122* HandlerBase).</p>123*124* <p>Applications may register a new or different125* handler in the middle of a parse, and the SAX parser must126* begin using the new handler immediately.</p>127*128* @param handler The DTD handler.129* @see DTDHandler130* @see HandlerBase131*/132public abstract void setDTDHandler (DTDHandler handler);133134135/**136* Allow an application to register a document event handler.137*138* <p>If the application does not register a document handler, all139* document events reported by the SAX parser will be silently140* ignored (this is the default behaviour implemented by141* HandlerBase).</p>142*143* <p>Applications may register a new or different handler in the144* middle of a parse, and the SAX parser must begin using the new145* handler immediately.</p>146*147* @param handler The document handler.148* @see DocumentHandler149* @see HandlerBase150*/151public abstract void setDocumentHandler (DocumentHandler handler);152153154/**155* Allow an application to register an error event handler.156*157* <p>If the application does not register an error event handler,158* all error events reported by the SAX parser will be silently159* ignored, except for fatalError, which will throw a SAXException160* (this is the default behaviour implemented by HandlerBase).</p>161*162* <p>Applications may register a new or different handler in the163* middle of a parse, and the SAX parser must begin using the new164* handler immediately.</p>165*166* @param handler The error handler.167* @see ErrorHandler168* @see SAXException169* @see HandlerBase170*/171public abstract void setErrorHandler (ErrorHandler handler);172173174/**175* Parse an XML document.176*177* <p>The application can use this method to instruct the SAX parser178* to begin parsing an XML document from any valid input179* source (a character stream, a byte stream, or a URI).</p>180*181* <p>Applications may not invoke this method while a parse is in182* progress (they should create a new Parser instead for each183* additional XML document). Once a parse is complete, an184* application may reuse the same Parser object, possibly with a185* different input source.</p>186*187* @param source The input source for the top-level of the188* XML document.189* @exception org.xml.sax.SAXException Any SAX exception, possibly190* wrapping another exception.191* @exception java.io.IOException An IO exception from the parser,192* possibly from a byte stream or character stream193* supplied by the application.194* @see org.xml.sax.InputSource195* @see #parse(java.lang.String)196* @see #setEntityResolver197* @see #setDTDHandler198* @see #setDocumentHandler199* @see #setErrorHandler200*/201public abstract void parse (InputSource source)202throws SAXException, IOException;203204205/**206* Parse an XML document from a system identifier (URI).207*208* <p>This method is a shortcut for the common case of reading a209* document from a system identifier. It is the exact210* equivalent of the following:</p>211*212* <pre>213* parse(new InputSource(systemId));214* </pre>215*216* <p>If the system identifier is a URL, it must be fully resolved217* by the application before it is passed to the parser.</p>218*219* @param systemId The system identifier (URI).220* @exception org.xml.sax.SAXException Any SAX exception, possibly221* wrapping another exception.222* @exception java.io.IOException An IO exception from the parser,223* possibly from a byte stream or character stream224* supplied by the application.225* @see #parse(org.xml.sax.InputSource)226*/227public abstract void parse (String systemId)228throws SAXException, IOException;229230}231232// end of Parser.java233234235