Path: blob/aarch64-shenandoah-jdk8u272-b10/jaxp/src/org/xml/sax/ext/DefaultHandler2.java
48576 views
/*1* Copyright (c) 2004, 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// DefaultHandler2.java - extended DefaultHandler26// http://www.saxproject.org27// Public Domain: no warranty.28// $Id: DefaultHandler2.java,v 1.2 2004/11/03 22:49:08 jsuttor Exp $2930package org.xml.sax.ext;3132import java.io.IOException;33import org.xml.sax.InputSource;34import org.xml.sax.SAXException;35import org.xml.sax.helpers.DefaultHandler;363738/**39* This class extends the SAX2 base handler class to support the40* SAX2 {@link LexicalHandler}, {@link DeclHandler}, and41* {@link EntityResolver2} extensions. Except for overriding the42* original SAX1 {@link DefaultHandler#resolveEntity resolveEntity()}43* method the added handler methods just return. Subclassers may44* override everything on a method-by-method basis.45*46* <blockquote>47* <em>This module, both source code and documentation, is in the48* Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>49* </blockquote>50*51* <p> <em>Note:</em> this class might yet learn that the52* <em>ContentHandler.setDocumentLocator()</em> call might be passed a53* {@link Locator2} object, and that the54* <em>ContentHandler.startElement()</em> call might be passed a55* {@link Attributes2} object.56*57* @since SAX 2.0 (extensions 1.1 alpha)58* @author David Brownell59*/60public class DefaultHandler2 extends DefaultHandler61implements LexicalHandler, DeclHandler, EntityResolver262{63/** Constructs a handler which ignores all parsing events. */64public DefaultHandler2 () { }656667// SAX2 ext-1.0 LexicalHandler6869public void startCDATA ()70throws SAXException71{}7273public void endCDATA ()74throws SAXException75{}7677public void startDTD (String name, String publicId, String systemId)78throws SAXException79{}8081public void endDTD ()82throws SAXException83{}8485public void startEntity (String name)86throws SAXException87{}8889public void endEntity (String name)90throws SAXException91{}9293public void comment (char ch [], int start, int length)94throws SAXException95{ }969798// SAX2 ext-1.0 DeclHandler99100public void attributeDecl (String eName, String aName,101String type, String mode, String value)102throws SAXException103{}104105public void elementDecl (String name, String model)106throws SAXException107{}108109public void externalEntityDecl (String name,110String publicId, String systemId)111throws SAXException112{}113114public void internalEntityDecl (String name, String value)115throws SAXException116{}117118// SAX2 ext-1.1 EntityResolver2119120/**121* Tells the parser that if no external subset has been declared122* in the document text, none should be used.123*/124public InputSource getExternalSubset (String name, String baseURI)125throws SAXException, IOException126{ return null; }127128/**129* Tells the parser to resolve the systemId against the baseURI130* and read the entity text from that resulting absolute URI.131* Note that because the older132* {@link DefaultHandler#resolveEntity DefaultHandler.resolveEntity()},133* method is overridden to call this one, this method may sometimes134* be invoked with null <em>name</em> and <em>baseURI</em>, and135* with the <em>systemId</em> already absolutized.136*/137public InputSource resolveEntity (String name, String publicId,138String baseURI, String systemId)139throws SAXException, IOException140{ return null; }141142// SAX1 EntityResolver143144/**145* Invokes146* {@link EntityResolver2#resolveEntity EntityResolver2.resolveEntity()}147* with null entity name and base URI.148* You only need to override that method to use this class.149*/150public InputSource resolveEntity (String publicId, String systemId)151throws SAXException, IOException152{ return resolveEntity (null, publicId, null, systemId); }153}154155156