KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > xml > sax > ext > DefaultHandler2


1 // DefaultHandler2.java - extended DefaultHandler
2
// http://www.saxproject.org
3
// Public Domain: no warranty.
4
// $Id: DefaultHandler2.java,v 1.1.2.1 2004/05/01 08:34:43 jsuttor Exp $
5

6 package org.xml.sax.ext;
7
8 import java.io.IOException JavaDoc;
9 import org.xml.sax.InputSource JavaDoc;
10 import org.xml.sax.SAXException JavaDoc;
11 import org.xml.sax.helpers.DefaultHandler JavaDoc;
12
13
14 /**
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.
21  *
22  * <blockquote>
23  * <em>This module, both source code and documentation, is in the
24  * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
25  * </blockquote>
26  *
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.
32  *
33  * @since SAX 2.0 (extensions 1.1 alpha)
34  * @author David Brownell
35  * @version TBS
36  */

37 public class DefaultHandler2 extends DefaultHandler JavaDoc
38     implements LexicalHandler JavaDoc, DeclHandler JavaDoc, EntityResolver2 JavaDoc
39 {
40     /** Constructs a handler which ignores all parsing events. */
41     public DefaultHandler2 () { }
42
43
44     // SAX2 ext-1.0 LexicalHandler
45

46     public void startCDATA ()
47     throws SAXException JavaDoc
48     {}
49
50     public void endCDATA ()
51     throws SAXException JavaDoc
52     {}
53
54     public void startDTD (String JavaDoc name, String JavaDoc publicId, String JavaDoc systemId)
55     throws SAXException JavaDoc
56     {}
57
58     public void endDTD ()
59     throws SAXException JavaDoc
60     {}
61
62     public void startEntity (String JavaDoc name)
63     throws SAXException JavaDoc
64     {}
65
66     public void endEntity (String JavaDoc name)
67     throws SAXException JavaDoc
68     {}
69
70     public void comment (char ch [], int start, int length)
71     throws SAXException JavaDoc
72     { }
73
74
75     // SAX2 ext-1.0 DeclHandler
76

77     public void attributeDecl (String JavaDoc eName, String JavaDoc aName,
78         String JavaDoc type, String JavaDoc mode, String JavaDoc value)
79     throws SAXException JavaDoc
80     {}
81
82     public void elementDecl (String JavaDoc name, String JavaDoc model)
83     throws SAXException JavaDoc
84     {}
85
86     public void externalEntityDecl (String JavaDoc name,
87         String JavaDoc publicId, String JavaDoc systemId)
88     throws SAXException JavaDoc
89     {}
90
91     public void internalEntityDecl (String JavaDoc name, String JavaDoc value)
92     throws SAXException JavaDoc
93     {}
94
95     // SAX2 ext-1.1 EntityResolver2
96

97     /**
98      * Tells the parser that if no external subset has been declared
99      * in the document text, none should be used.
100      */

101     public InputSource JavaDoc getExternalSubset (String JavaDoc name, String JavaDoc baseURI)
102     throws SAXException JavaDoc, IOException JavaDoc
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 JavaDoc resolveEntity (String JavaDoc name, String JavaDoc publicId,
115         String JavaDoc baseURI, String JavaDoc systemId)
116     throws SAXException JavaDoc, IOException JavaDoc
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 JavaDoc resolveEntity (String JavaDoc publicId, String JavaDoc systemId)
128     throws SAXException JavaDoc, IOException JavaDoc
129     { return resolveEntity (null, publicId, null, systemId); }
130 }
131
Popular Tags