12005
|
1 |
/*
|
58247
|
2 |
* Copyright (c) 2004, 2019, Oracle and/or its affiliates. All rights reserved.
|
12005
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
4 |
*
|
|
5 |
* This code is free software; you can redistribute it and/or modify it
|
|
6 |
* under the terms of the GNU General Public License version 2 only, as
|
|
7 |
* published by the Free Software Foundation. Oracle designates this
|
|
8 |
* particular file as subject to the "Classpath" exception as provided
|
|
9 |
* by Oracle in the LICENSE file that accompanied this code.
|
|
10 |
*
|
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that
|
|
15 |
* accompanied this code).
|
|
16 |
*
|
|
17 |
* You should have received a copy of the GNU General Public License version
|
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
20 |
*
|
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
22 |
* or visit www.oracle.com if you need additional information or have any
|
|
23 |
* questions.
|
|
24 |
*/
|
|
25 |
|
|
26 |
package org.xml.sax.ext;
|
|
27 |
|
|
28 |
import java.io.IOException;
|
|
29 |
import org.xml.sax.InputSource;
|
|
30 |
import org.xml.sax.SAXException;
|
|
31 |
import org.xml.sax.helpers.DefaultHandler;
|
|
32 |
|
|
33 |
|
|
34 |
/**
|
|
35 |
* This class extends the SAX2 base handler class to support the
|
|
36 |
* SAX2 {@link LexicalHandler}, {@link DeclHandler}, and
|
|
37 |
* {@link EntityResolver2} extensions. Except for overriding the
|
|
38 |
* original SAX1 {@link DefaultHandler#resolveEntity resolveEntity()}
|
|
39 |
* method the added handler methods just return. Subclassers may
|
|
40 |
* override everything on a method-by-method basis.
|
|
41 |
*
|
|
42 |
* <p> <em>Note:</em> this class might yet learn that the
|
|
43 |
* <em>ContentHandler.setDocumentLocator()</em> call might be passed a
|
|
44 |
* {@link Locator2} object, and that the
|
|
45 |
* <em>ContentHandler.startElement()</em> call might be passed a
|
|
46 |
* {@link Attributes2} object.
|
|
47 |
*
|
25262
|
48 |
* @since 1.5, SAX 2.0 (extensions 1.1 alpha)
|
12005
|
49 |
* @author David Brownell
|
|
50 |
*/
|
|
51 |
public class DefaultHandler2 extends DefaultHandler
|
|
52 |
implements LexicalHandler, DeclHandler, EntityResolver2
|
|
53 |
{
|
|
54 |
/** Constructs a handler which ignores all parsing events. */
|
|
55 |
public DefaultHandler2 () { }
|
|
56 |
|
|
57 |
|
|
58 |
// SAX2 ext-1.0 LexicalHandler
|
|
59 |
|
|
60 |
public void startCDATA ()
|
|
61 |
throws SAXException
|
|
62 |
{}
|
|
63 |
|
|
64 |
public void endCDATA ()
|
|
65 |
throws SAXException
|
|
66 |
{}
|
|
67 |
|
|
68 |
public void startDTD (String name, String publicId, String systemId)
|
|
69 |
throws SAXException
|
|
70 |
{}
|
|
71 |
|
|
72 |
public void endDTD ()
|
|
73 |
throws SAXException
|
|
74 |
{}
|
|
75 |
|
|
76 |
public void startEntity (String name)
|
|
77 |
throws SAXException
|
|
78 |
{}
|
|
79 |
|
|
80 |
public void endEntity (String name)
|
|
81 |
throws SAXException
|
|
82 |
{}
|
|
83 |
|
|
84 |
public void comment (char ch [], int start, int length)
|
|
85 |
throws SAXException
|
|
86 |
{ }
|
|
87 |
|
|
88 |
|
|
89 |
// SAX2 ext-1.0 DeclHandler
|
|
90 |
|
|
91 |
public void attributeDecl (String eName, String aName,
|
|
92 |
String type, String mode, String value)
|
|
93 |
throws SAXException
|
|
94 |
{}
|
|
95 |
|
|
96 |
public void elementDecl (String name, String model)
|
|
97 |
throws SAXException
|
|
98 |
{}
|
|
99 |
|
|
100 |
public void externalEntityDecl (String name,
|
|
101 |
String publicId, String systemId)
|
|
102 |
throws SAXException
|
|
103 |
{}
|
|
104 |
|
|
105 |
public void internalEntityDecl (String name, String value)
|
|
106 |
throws SAXException
|
|
107 |
{}
|
|
108 |
|
|
109 |
// SAX2 ext-1.1 EntityResolver2
|
|
110 |
|
|
111 |
/**
|
|
112 |
* Tells the parser that if no external subset has been declared
|
|
113 |
* in the document text, none should be used.
|
|
114 |
*/
|
|
115 |
public InputSource getExternalSubset (String name, String baseURI)
|
|
116 |
throws SAXException, IOException
|
|
117 |
{ return null; }
|
|
118 |
|
|
119 |
/**
|
|
120 |
* Tells the parser to resolve the systemId against the baseURI
|
|
121 |
* and read the entity text from that resulting absolute URI.
|
|
122 |
* Note that because the older
|
|
123 |
* {@link DefaultHandler#resolveEntity DefaultHandler.resolveEntity()},
|
|
124 |
* method is overridden to call this one, this method may sometimes
|
|
125 |
* be invoked with null <em>name</em> and <em>baseURI</em>, and
|
|
126 |
* with the <em>systemId</em> already absolutized.
|
|
127 |
*/
|
|
128 |
public InputSource resolveEntity (String name, String publicId,
|
|
129 |
String baseURI, String systemId)
|
|
130 |
throws SAXException, IOException
|
|
131 |
{ return null; }
|
|
132 |
|
|
133 |
// SAX1 EntityResolver
|
|
134 |
|
|
135 |
/**
|
|
136 |
* Invokes
|
|
137 |
* {@link EntityResolver2#resolveEntity EntityResolver2.resolveEntity()}
|
|
138 |
* with null entity name and base URI.
|
|
139 |
* You only need to override that method to use this class.
|
|
140 |
*/
|
|
141 |
public InputSource resolveEntity (String publicId, String systemId)
|
|
142 |
throws SAXException, IOException
|
|
143 |
{ return resolveEntity (null, publicId, null, systemId); }
|
|
144 |
}
|