1 // DefaultHandler2.java - extended DefaultHandler
2 // http://www.saxproject.org
3 // Public Domain: no warranty.
4 // $Id: DefaultHandler2.java,v 1.3 2002/01/12 19:04:19 dbrownell Exp $
6 package org.xml.sax.ext;
8 import java.io.IOException;
9 import org.xml.sax.InputSource;
10 import org.xml.sax.SAXException;
11 import org.xml.sax.helpers.DefaultHandler;
15 * This class extends the SAX2 base handler class to support the
16 * SAX2 {@link LexicalHandler}, {@link DeclHandler}, and
17 * {@link EntityResolver2} extensions. Except for overriding the
18 * original SAX1 {@link DefaultHandler#resolveEntity resolveEntity()}
19 * method the added handler methods just return. Subclassers may
20 * override everything on a method-by-method basis.
23 * <em>This module, both source code and documentation, is in the
24 * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
27 * <p> <em>Note:</em> this class might yet learn that the
28 * <em>ContentHandler.setDocumentLocator()</em> call might be passed a
29 * {@link Locator2} object, and that the
30 * <em>ContentHandler.startElement()</em> call might be passed a
31 * {@link Attributes2} object.
33 * @since SAX 2.0 (extensions 1.1 alpha)
34 * @author David Brownell
37 public class DefaultHandler2 extends DefaultHandler
38 implements LexicalHandler, DeclHandler, EntityResolver2
40 /** Constructs a handler which ignores all parsing events. */
41 public DefaultHandler2 () { }
44 // SAX2 ext-1.0 LexicalHandler
47 public void startCDATA ()
52 public void endCDATA ()
57 public void startDTD (String name, String publicId, String systemId)
67 public void startEntity (String name)
72 public void endEntity (String name)
77 public void comment (char ch [], int start, int length)
82 // SAX2 ext-1.0 DeclHandler
85 public void attributeDecl (String eName, String aName,
86 String type, String mode, String value)
91 public void elementDecl (String name, String model)
96 public void externalEntityDecl (String name,
97 String publicId, String systemId)
102 public void internalEntityDecl (String name, String value)
106 // SAX2 ext-1.1 EntityResolver2
109 * Tells the parser that if no external subset has been declared
110 * in the document text, none should be used.
113 public InputSource getExternalSubset (String name, String baseURI)
114 throws SAXException, IOException
118 * Tells the parser to resolve the systemId against the baseURI
119 * and read the entity text from that resulting absolute URI.
120 * Note that because the older
121 * {@link DefaultHandler#resolveEntity DefaultHandler.resolveEntity()},
122 * method is overridden to call this one, this method may sometimes
123 * be invoked with null <em>name</em> and <em>baseURI</em>, and
124 * with the <em>systemId</em> already absolutized.
127 public InputSource resolveEntity (String name, String publicId,
128 String baseURI, String systemId)
129 throws SAXException, IOException
132 // SAX1 EntityResolver
136 * {@link EntityResolver2#resolveEntity EntityResolver2.resolveEntity()}
137 * with null entity name and base URI.
138 * You only need to override that method to use this class.
141 public InputSource resolveEntity (String publicId, String systemId)
142 throws SAXException, IOException
143 { return resolveEntity (null, publicId, null, systemId); }