001// DefaultHandler2.java - extended DefaultHandler
002// http://www.saxproject.org
003// Public Domain: no warranty.
004// $Id: DefaultHandler2.java,v 1.1 2004/12/23 22:38:42 mark Exp $
005
006package org.xml.sax.ext;
007
008import java.io.IOException;
009import org.xml.sax.InputSource;
010import org.xml.sax.SAXException;
011import org.xml.sax.helpers.DefaultHandler;
012
013
014/**
015 * This class extends the SAX2 base handler class to support the
016 * SAX2 {@link LexicalHandler}, {@link DeclHandler}, and
017 * {@link EntityResolver2} extensions.  Except for overriding the
018 * original SAX1 {@link DefaultHandler#resolveEntity resolveEntity()}
019 * method the added handler methods just return.  Subclassers may
020 * override everything on a method-by-method basis.
021 *
022 * <blockquote>
023 * <em>This module, both source code and documentation, is in the
024 * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
025 * </blockquote>
026 *
027 * <p> <em>Note:</em> this class might yet learn that the
028 * <em>ContentHandler.setDocumentLocator()</em> call might be passed a
029 * {@link Locator2} object, and that the
030 * <em>ContentHandler.startElement()</em> call might be passed a
031 * {@link Attributes2} object.
032 *
033 * @since SAX 2.0 (extensions 1.1 alpha)
034 * @author David Brownell
035 * @version TBS
036 */
037public class DefaultHandler2 extends DefaultHandler
038    implements LexicalHandler, DeclHandler, EntityResolver2
039{
040    /** Constructs a handler which ignores all parsing events. */
041    public DefaultHandler2 () { }
042
043
044    // SAX2 ext-1.0 LexicalHandler
045
046    public void startCDATA ()
047    throws SAXException
048        {}
049
050    public void endCDATA ()
051    throws SAXException
052        {}
053
054    public void startDTD (String name, String publicId, String systemId)
055    throws SAXException
056        {}
057
058    public void endDTD ()
059    throws SAXException
060        {}
061
062    public void startEntity (String name)
063    throws SAXException
064        {}
065
066    public void endEntity (String name)
067    throws SAXException
068        {}
069
070    public void comment (char ch [], int start, int length)
071    throws SAXException
072        { }
073
074
075    // SAX2 ext-1.0 DeclHandler
076
077    public void attributeDecl (String eName, String aName,
078            String type, String mode, String value)
079    throws SAXException
080        {}
081
082    public void elementDecl (String name, String model)
083    throws SAXException
084        {}
085
086    public void externalEntityDecl (String name,
087        String publicId, String systemId)
088    throws SAXException
089        {}
090
091    public void internalEntityDecl (String name, String value)
092    throws SAXException
093        {}
094
095    // SAX2 ext-1.1 EntityResolver2
096
097    /**
098     * Tells the parser that if no external subset has been declared
099     * in the document text, none should be used.
100     */
101    public InputSource getExternalSubset (String name, String baseURI)
102    throws SAXException, IOException
103        { return null; }
104
105    /**
106     * Tells the parser to resolve the systemId against the baseURI
107     * and read the entity text from that resulting absolute URI.
108     * Note that because the older
109     * {@link DefaultHandler#resolveEntity DefaultHandler.resolveEntity()},
110     * method is overridden to call this one, this method may sometimes 
111     * be invoked with null <em>name</em> and <em>baseURI</em>, and
112     * with the <em>systemId</em> already absolutized.
113     */
114    public InputSource resolveEntity (String name, String publicId,
115            String baseURI, String systemId)
116    throws SAXException, IOException
117        { return null; }
118    
119    // SAX1 EntityResolver
120
121    /**
122     * Invokes
123     * {@link EntityResolver2#resolveEntity EntityResolver2.resolveEntity()}
124     * with null entity name and base URI.
125     * You only need to override that method to use this class.
126     */
127    public InputSource resolveEntity (String publicId, String systemId)
128    throws SAXException, IOException
129        { return resolveEntity (null, publicId, null, systemId); }
130}