Path: blob/aarch64-shenandoah-jdk8u272-b10/jaxp/src/org/xml/sax/DocumentHandler.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 document handler.26// http://www.saxproject.org27// No warranty; no copyright -- use this as you will.28// $Id: DocumentHandler.java,v 1.2 2004/11/03 22:44:51 jsuttor Exp $2930package org.xml.sax;3132/**33* Receive notification of general document events.34*35* <blockquote>36* <em>This module, both source code and documentation, is in the37* Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>38* See <a href='http://www.saxproject.org'>http://www.saxproject.org</a>39* for further information.40* </blockquote>41*42* <p>This was the main event-handling interface for SAX1; in43* SAX2, it has been replaced by {@link org.xml.sax.ContentHandler44* ContentHandler}, which provides Namespace support and reporting45* of skipped entities. This interface is included in SAX2 only46* to support legacy SAX1 applications.</p>47*48* <p>The order of events in this interface is very important, and49* mirrors the order of information in the document itself. For50* example, all of an element's content (character data, processing51* instructions, and/or subelements) will appear, in order, between52* the startElement event and the corresponding endElement event.</p>53*54* <p>Application writers who do not want to implement the entire55* interface can derive a class from HandlerBase, which implements56* the default functionality; parser writers can instantiate57* HandlerBase to obtain a default handler. The application can find58* the location of any document event using the Locator interface59* supplied by the Parser through the setDocumentLocator method.</p>60*61* @deprecated This interface has been replaced by the SAX262* {@link org.xml.sax.ContentHandler ContentHandler}63* interface, which includes Namespace support.64* @since SAX 1.065* @author David Megginson66* @see org.xml.sax.Parser#setDocumentHandler67* @see org.xml.sax.Locator68* @see org.xml.sax.HandlerBase69*/70public interface DocumentHandler {717273/**74* Receive an object for locating the origin of SAX document events.75*76* <p>SAX parsers are strongly encouraged (though not absolutely77* required) to supply a locator: if it does so, it must supply78* the locator to the application by invoking this method before79* invoking any of the other methods in the DocumentHandler80* interface.</p>81*82* <p>The locator allows the application to determine the end83* position of any document-related event, even if the parser is84* not reporting an error. Typically, the application will85* use this information for reporting its own errors (such as86* character content that does not match an application's87* business rules). The information returned by the locator88* is probably not sufficient for use with a search engine.</p>89*90* <p>Note that the locator will return correct information only91* during the invocation of the events in this interface. The92* application should not attempt to use it at any other time.</p>93*94* @param locator An object that can return the location of95* any SAX document event.96* @see org.xml.sax.Locator97*/98public abstract void setDocumentLocator (Locator locator);99100101/**102* Receive notification of the beginning of a document.103*104* <p>The SAX parser will invoke this method only once, before any105* other methods in this interface or in DTDHandler (except for106* setDocumentLocator).</p>107*108* @exception org.xml.sax.SAXException Any SAX exception, possibly109* wrapping another exception.110*/111public abstract void startDocument ()112throws SAXException;113114115/**116* Receive notification of the end of a document.117*118* <p>The SAX parser will invoke this method only once, and it will119* be the last method invoked during the parse. The parser shall120* not invoke this method until it has either abandoned parsing121* (because of an unrecoverable error) or reached the end of122* input.</p>123*124* @exception org.xml.sax.SAXException Any SAX exception, possibly125* wrapping another exception.126*/127public abstract void endDocument ()128throws SAXException;129130131/**132* Receive notification of the beginning of an element.133*134* <p>The Parser will invoke this method at the beginning of every135* element in the XML document; there will be a corresponding136* endElement() event for every startElement() event (even when the137* element is empty). All of the element's content will be138* reported, in order, before the corresponding endElement()139* event.</p>140*141* <p>If the element name has a namespace prefix, the prefix will142* still be attached. Note that the attribute list provided will143* contain only attributes with explicit values (specified or144* defaulted): #IMPLIED attributes will be omitted.</p>145*146* @param name The element type name.147* @param atts The attributes attached to the element, if any.148* @exception org.xml.sax.SAXException Any SAX exception, possibly149* wrapping another exception.150* @see #endElement151* @see org.xml.sax.AttributeList152*/153public abstract void startElement (String name, AttributeList atts)154throws SAXException;155156157/**158* Receive notification of the end of an element.159*160* <p>The SAX parser will invoke this method at the end of every161* element in the XML document; there will be a corresponding162* startElement() event for every endElement() event (even when the163* element is empty).</p>164*165* <p>If the element name has a namespace prefix, the prefix will166* still be attached to the name.</p>167*168* @param name The element type name169* @exception org.xml.sax.SAXException Any SAX exception, possibly170* wrapping another exception.171*/172public abstract void endElement (String name)173throws SAXException;174175176/**177* Receive notification of character data.178*179* <p>The Parser will call this method to report each chunk of180* character data. SAX parsers may return all contiguous character181* data in a single chunk, or they may split it into several182* chunks; however, all of the characters in any single event183* must come from the same external entity, so that the Locator184* provides useful information.</p>185*186* <p>The application must not attempt to read from the array187* outside of the specified range.</p>188*189* <p>Note that some parsers will report whitespace using the190* ignorableWhitespace() method rather than this one (validating191* parsers must do so).</p>192*193* @param ch The characters from the XML document.194* @param start The start position in the array.195* @param length The number of characters to read from the array.196* @exception org.xml.sax.SAXException Any SAX exception, possibly197* wrapping another exception.198* @see #ignorableWhitespace199* @see org.xml.sax.Locator200*/201public abstract void characters (char ch[], int start, int length)202throws SAXException;203204205/**206* Receive notification of ignorable whitespace in element content.207*208* <p>Validating Parsers must use this method to report each chunk209* of ignorable whitespace (see the W3C XML 1.0 recommendation,210* section 2.10): non-validating parsers may also use this method211* if they are capable of parsing and using content models.</p>212*213* <p>SAX parsers may return all contiguous whitespace in a single214* chunk, or they may split it into several chunks; however, all of215* the characters in any single event must come from the same216* external entity, so that the Locator provides useful217* information.</p>218*219* <p>The application must not attempt to read from the array220* outside of the specified range.</p>221*222* @param ch The characters from the XML document.223* @param start The start position in the array.224* @param length The number of characters to read from the array.225* @exception org.xml.sax.SAXException Any SAX exception, possibly226* wrapping another exception.227* @see #characters228*/229public abstract void ignorableWhitespace (char ch[], int start, int length)230throws SAXException;231232233/**234* Receive notification of a processing instruction.235*236* <p>The Parser will invoke this method once for each processing237* instruction found: note that processing instructions may occur238* before or after the main document element.</p>239*240* <p>A SAX parser should never report an XML declaration (XML 1.0,241* section 2.8) or a text declaration (XML 1.0, section 4.3.1)242* using this method.</p>243*244* @param target The processing instruction target.245* @param data The processing instruction data, or null if246* none was supplied.247* @exception org.xml.sax.SAXException Any SAX exception, possibly248* wrapping another exception.249*/250public abstract void processingInstruction (String target, String data)251throws SAXException;252253}254255// end of DocumentHandler.java256257258