1 // DefaultHandler2.java - extended DefaultHandler
2 // http://www.saxproject.org
3 // Public Domain: no warranty.
4 // $Id: DefaultHandler2.java,v 1.1 2004/12/23 22:38:42 mark 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
46 public void startCDATA ()
50 public void endCDATA ()
54 public void startDTD (String name, String publicId, String systemId)
62 public void startEntity (String name)
66 public void endEntity (String name)
70 public void comment (char ch [], int start, int length)
75 // SAX2 ext-1.0 DeclHandler
77 public void attributeDecl (String eName, String aName,
78 String type, String mode, String value)
82 public void elementDecl (String name, String model)
86 public void externalEntityDecl (String name,
87 String publicId, String systemId)
91 public void internalEntityDecl (String name, String value)
95 // SAX2 ext-1.1 EntityResolver2
98 * Tells the parser that if no external subset has been declared
99 * in the document text, none should be used.
101 public InputSource getExternalSubset (String name, String baseURI)
102 throws SAXException, IOException
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.
114 public InputSource resolveEntity (String name, String publicId,
115 String baseURI, String systemId)
116 throws SAXException, IOException
119 // SAX1 EntityResolver
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.
127 public InputSource resolveEntity (String publicId, String systemId)
128 throws SAXException, IOException
129 { return resolveEntity (null, publicId, null, systemId); }