f2096ad71dd5ac0cf86df60491d71bcdaa04d701
[jalview.git] / src / org / xml / sax / ext / DefaultHandler2.java
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 $
5
6 package org.xml.sax.ext;
7
8 import java.io.IOException;
9 import org.xml.sax.InputSource;
10 import org.xml.sax.SAXException;
11 import org.xml.sax.helpers.DefaultHandler;
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
38     implements LexicalHandler, DeclHandler, EntityResolver2
39 {
40     /** Constructs a handler which ignores all parsing events. */
41     public DefaultHandler2 () { }
42
43
44     // SAX2 ext-1.0 LexicalHandler
45
46     @Override
47                 public void startCDATA ()
48     throws SAXException
49         {}
50
51     @Override
52                 public void endCDATA ()
53     throws SAXException
54         {}
55
56     @Override
57                 public void startDTD (String name, String publicId, String systemId)
58     throws SAXException
59         {}
60
61     @Override
62                 public void endDTD ()
63     throws SAXException
64         {}
65
66     @Override
67                 public void startEntity (String name)
68     throws SAXException
69         {}
70
71     @Override
72                 public void endEntity (String name)
73     throws SAXException
74         {}
75
76     @Override
77                 public void comment (char ch [], int start, int length)
78     throws SAXException
79         { }
80
81
82     // SAX2 ext-1.0 DeclHandler
83
84     @Override
85                 public void attributeDecl (String eName, String aName,
86             String type, String mode, String value)
87     throws SAXException
88         {}
89
90     @Override
91                 public void elementDecl (String name, String model)
92     throws SAXException
93         {}
94
95     @Override
96                 public void externalEntityDecl (String name,
97         String publicId, String systemId)
98     throws SAXException
99         {}
100
101     @Override
102                 public void internalEntityDecl (String name, String value)
103     throws SAXException
104         {}
105
106     // SAX2 ext-1.1 EntityResolver2
107
108     /**
109      * Tells the parser that if no external subset has been declared
110      * in the document text, none should be used.
111      */
112     @Override
113                 public InputSource getExternalSubset (String name, String baseURI)
114     throws SAXException, IOException
115         { return null; }
116
117     /**
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.
125      */
126     @Override
127                 public InputSource resolveEntity (String name, String publicId,
128             String baseURI, String systemId)
129     throws SAXException, IOException
130         { return null; }
131     
132     // SAX1 EntityResolver
133
134     /**
135      * Invokes
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.
139      */
140     @Override
141                 public InputSource resolveEntity (String publicId, String systemId)
142     throws SAXException, IOException
143         { return resolveEntity (null, publicId, null, systemId); }
144 }