Path: blob/aarch64-shenandoah-jdk8u272-b10/jaxp/src/org/xml/sax/HandlerBase.java
48534 views
/*1* Copyright (c) 2000, 2006, 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 default handler base class.26// http://www.saxproject.org27// No warranty; no copyright -- use this as you will.28// $Id: HandlerBase.java,v 1.2 2005/06/10 03:50:47 jeffsuttor Exp $2930package org.xml.sax;3132/**33* Default base class for handlers.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 class implements the default behaviour for four SAX143* interfaces: EntityResolver, DTDHandler, DocumentHandler,44* and ErrorHandler. It is now obsolete, but is included in SAX2 to45* support legacy SAX1 applications. SAX2 applications should use46* the {@link org.xml.sax.helpers.DefaultHandler DefaultHandler}47* class instead.</p>48*49* <p>Application writers can extend this class when they need to50* implement only part of an interface; parser writers can51* instantiate this class to provide default handlers when the52* application has not supplied its own.</p>53*54* <p>Note that the use of this class is optional.</p>55*56* @deprecated This class works with the deprecated57* {@link org.xml.sax.DocumentHandler DocumentHandler}58* interface. It has been replaced by the SAX259* {@link org.xml.sax.helpers.DefaultHandler DefaultHandler}60* class.61* @since SAX 1.062* @author David Megginson63* @see org.xml.sax.EntityResolver64* @see org.xml.sax.DTDHandler65* @see org.xml.sax.DocumentHandler66* @see org.xml.sax.ErrorHandler67*/68public class HandlerBase69implements EntityResolver, DTDHandler, DocumentHandler, ErrorHandler70{717273////////////////////////////////////////////////////////////////////74// Default implementation of the EntityResolver interface.75////////////////////////////////////////////////////////////////////7677/**78* Resolve an external entity.79*80* <p>Always return null, so that the parser will use the system81* identifier provided in the XML document. This method implements82* the SAX default behaviour: application writers can override it83* in a subclass to do special translations such as catalog lookups84* or URI redirection.</p>85*86* @param publicId The public identifer, or null if none is87* available.88* @param systemId The system identifier provided in the XML89* document.90* @return The new input source, or null to require the91* default behaviour.92* @exception org.xml.sax.SAXException Any SAX exception, possibly93* wrapping another exception.94* @see org.xml.sax.EntityResolver#resolveEntity95*/96public InputSource resolveEntity (String publicId, String systemId)97throws SAXException98{99return null;100}101102103104////////////////////////////////////////////////////////////////////105// Default implementation of DTDHandler interface.106////////////////////////////////////////////////////////////////////107108109/**110* Receive notification of a notation declaration.111*112* <p>By default, do nothing. Application writers may override this113* method in a subclass if they wish to keep track of the notations114* declared in a document.</p>115*116* @param name The notation name.117* @param publicId The notation public identifier, or null if not118* available.119* @param systemId The notation system identifier.120* @see org.xml.sax.DTDHandler#notationDecl121*/122public void notationDecl (String name, String publicId, String systemId)123{124// no op125}126127128/**129* Receive notification of an unparsed entity declaration.130*131* <p>By default, do nothing. Application writers may override this132* method in a subclass to keep track of the unparsed entities133* declared in a document.</p>134*135* @param name The entity name.136* @param publicId The entity public identifier, or null if not137* available.138* @param systemId The entity system identifier.139* @param notationName The name of the associated notation.140* @see org.xml.sax.DTDHandler#unparsedEntityDecl141*/142public void unparsedEntityDecl (String name, String publicId,143String systemId, String notationName)144{145// no op146}147148149150////////////////////////////////////////////////////////////////////151// Default implementation of DocumentHandler interface.152////////////////////////////////////////////////////////////////////153154155/**156* Receive a Locator object for document events.157*158* <p>By default, do nothing. Application writers may override this159* method in a subclass if they wish to store the locator for use160* with other document events.</p>161*162* @param locator A locator for all SAX document events.163* @see org.xml.sax.DocumentHandler#setDocumentLocator164* @see org.xml.sax.Locator165*/166public void setDocumentLocator (Locator locator)167{168// no op169}170171172/**173* Receive notification of the beginning of the document.174*175* <p>By default, do nothing. Application writers may override this176* method in a subclass to take specific actions at the beginning177* of a document (such as allocating the root node of a tree or178* creating an output file).</p>179*180* @exception org.xml.sax.SAXException Any SAX exception, possibly181* wrapping another exception.182* @see org.xml.sax.DocumentHandler#startDocument183*/184public void startDocument ()185throws SAXException186{187// no op188}189190191/**192* Receive notification of the end of the document.193*194* <p>By default, do nothing. Application writers may override this195* method in a subclass to take specific actions at the end196* of a document (such as finalising a tree or closing an output197* file).</p>198*199* @exception org.xml.sax.SAXException Any SAX exception, possibly200* wrapping another exception.201* @see org.xml.sax.DocumentHandler#endDocument202*/203public void endDocument ()204throws SAXException205{206// no op207}208209210/**211* Receive notification of the start of an element.212*213* <p>By default, do nothing. Application writers may override this214* method in a subclass to take specific actions at the start of215* each element (such as allocating a new tree node or writing216* output to a file).</p>217*218* @param name The element type name.219* @param attributes The specified or defaulted attributes.220* @exception org.xml.sax.SAXException Any SAX exception, possibly221* wrapping another exception.222* @see org.xml.sax.DocumentHandler#startElement223*/224public void startElement (String name, AttributeList attributes)225throws SAXException226{227// no op228}229230231/**232* Receive notification of the end of an element.233*234* <p>By default, do nothing. Application writers may override this235* method in a subclass to take specific actions at the end of236* each element (such as finalising a tree node or writing237* output to a file).</p>238*239* @param name the element name240* @exception org.xml.sax.SAXException Any SAX exception, possibly241* wrapping another exception.242* @see org.xml.sax.DocumentHandler#endElement243*/244public void endElement (String name)245throws SAXException246{247// no op248}249250251/**252* Receive notification of character data inside an element.253*254* <p>By default, do nothing. Application writers may override this255* method to take specific actions for each chunk of character data256* (such as adding the data to a node or buffer, or printing it to257* a file).</p>258*259* @param ch The characters.260* @param start The start position in the character array.261* @param length The number of characters to use from the262* character array.263* @exception org.xml.sax.SAXException Any SAX exception, possibly264* wrapping another exception.265* @see org.xml.sax.DocumentHandler#characters266*/267public void characters (char ch[], int start, int length)268throws SAXException269{270// no op271}272273274/**275* Receive notification of ignorable whitespace in element content.276*277* <p>By default, do nothing. Application writers may override this278* method to take specific actions for each chunk of ignorable279* whitespace (such as adding data to a node or buffer, or printing280* it to a file).</p>281*282* @param ch The whitespace characters.283* @param start The start position in the character array.284* @param length The number of characters to use from the285* character array.286* @exception org.xml.sax.SAXException Any SAX exception, possibly287* wrapping another exception.288* @see org.xml.sax.DocumentHandler#ignorableWhitespace289*/290public void ignorableWhitespace (char ch[], int start, int length)291throws SAXException292{293// no op294}295296297/**298* Receive notification of a processing instruction.299*300* <p>By default, do nothing. Application writers may override this301* method in a subclass to take specific actions for each302* processing instruction, such as setting status variables or303* invoking other methods.</p>304*305* @param target The processing instruction target.306* @param data The processing instruction data, or null if307* none is supplied.308* @exception org.xml.sax.SAXException Any SAX exception, possibly309* wrapping another exception.310* @see org.xml.sax.DocumentHandler#processingInstruction311*/312public void processingInstruction (String target, String data)313throws SAXException314{315// no op316}317318319320////////////////////////////////////////////////////////////////////321// Default implementation of the ErrorHandler interface.322////////////////////////////////////////////////////////////////////323324325/**326* Receive notification of a parser warning.327*328* <p>The default implementation does nothing. Application writers329* may override this method in a subclass to take specific actions330* for each warning, such as inserting the message in a log file or331* printing it to the console.</p>332*333* @param e The warning information encoded as an exception.334* @exception org.xml.sax.SAXException Any SAX exception, possibly335* wrapping another exception.336* @see org.xml.sax.ErrorHandler#warning337* @see org.xml.sax.SAXParseException338*/339public void warning (SAXParseException e)340throws SAXException341{342// no op343}344345346/**347* Receive notification of a recoverable parser error.348*349* <p>The default implementation does nothing. Application writers350* may override this method in a subclass to take specific actions351* for each error, such as inserting the message in a log file or352* printing it to the console.</p>353*354* @param e The warning information encoded as an exception.355* @exception org.xml.sax.SAXException Any SAX exception, possibly356* wrapping another exception.357* @see org.xml.sax.ErrorHandler#warning358* @see org.xml.sax.SAXParseException359*/360public void error (SAXParseException e)361throws SAXException362{363// no op364}365366367/**368* Report a fatal XML parsing error.369*370* <p>The default implementation throws a SAXParseException.371* Application writers may override this method in a subclass if372* they need to take specific actions for each fatal error (such as373* collecting all of the errors into a single report): in any case,374* the application must stop all regular processing when this375* method is invoked, since the document is no longer reliable, and376* the parser may no longer report parsing events.</p>377*378* @param e The error information encoded as an exception.379* @exception org.xml.sax.SAXException Any SAX exception, possibly380* wrapping another exception.381* @see org.xml.sax.ErrorHandler#fatalError382* @see org.xml.sax.SAXParseException383*/384public void fatalError (SAXParseException e)385throws SAXException386{387throw e;388}389390}391392// end of HandlerBase.java393394395