Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openjdk-multiarch-jdk8u
Path: blob/aarch64-shenandoah-jdk8u272-b10/jaxp/src/org/xml/sax/DocumentHandler.java
48534 views
1
/*
2
* Copyright (c) 2000, 2005, Oracle and/or its affiliates. All rights reserved.
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
// SAX document handler.
27
// http://www.saxproject.org
28
// No warranty; no copyright -- use this as you will.
29
// $Id: DocumentHandler.java,v 1.2 2004/11/03 22:44:51 jsuttor Exp $
30
31
package org.xml.sax;
32
33
/**
34
* Receive notification of general document events.
35
*
36
* <blockquote>
37
* <em>This module, both source code and documentation, is in the
38
* Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
39
* See <a href='http://www.saxproject.org'>http://www.saxproject.org</a>
40
* for further information.
41
* </blockquote>
42
*
43
* <p>This was the main event-handling interface for SAX1; in
44
* SAX2, it has been replaced by {@link org.xml.sax.ContentHandler
45
* ContentHandler}, which provides Namespace support and reporting
46
* of skipped entities. This interface is included in SAX2 only
47
* to support legacy SAX1 applications.</p>
48
*
49
* <p>The order of events in this interface is very important, and
50
* mirrors the order of information in the document itself. For
51
* example, all of an element's content (character data, processing
52
* instructions, and/or subelements) will appear, in order, between
53
* the startElement event and the corresponding endElement event.</p>
54
*
55
* <p>Application writers who do not want to implement the entire
56
* interface can derive a class from HandlerBase, which implements
57
* the default functionality; parser writers can instantiate
58
* HandlerBase to obtain a default handler. The application can find
59
* the location of any document event using the Locator interface
60
* supplied by the Parser through the setDocumentLocator method.</p>
61
*
62
* @deprecated This interface has been replaced by the SAX2
63
* {@link org.xml.sax.ContentHandler ContentHandler}
64
* interface, which includes Namespace support.
65
* @since SAX 1.0
66
* @author David Megginson
67
* @see org.xml.sax.Parser#setDocumentHandler
68
* @see org.xml.sax.Locator
69
* @see org.xml.sax.HandlerBase
70
*/
71
public interface DocumentHandler {
72
73
74
/**
75
* Receive an object for locating the origin of SAX document events.
76
*
77
* <p>SAX parsers are strongly encouraged (though not absolutely
78
* required) to supply a locator: if it does so, it must supply
79
* the locator to the application by invoking this method before
80
* invoking any of the other methods in the DocumentHandler
81
* interface.</p>
82
*
83
* <p>The locator allows the application to determine the end
84
* position of any document-related event, even if the parser is
85
* not reporting an error. Typically, the application will
86
* use this information for reporting its own errors (such as
87
* character content that does not match an application's
88
* business rules). The information returned by the locator
89
* is probably not sufficient for use with a search engine.</p>
90
*
91
* <p>Note that the locator will return correct information only
92
* during the invocation of the events in this interface. The
93
* application should not attempt to use it at any other time.</p>
94
*
95
* @param locator An object that can return the location of
96
* any SAX document event.
97
* @see org.xml.sax.Locator
98
*/
99
public abstract void setDocumentLocator (Locator locator);
100
101
102
/**
103
* Receive notification of the beginning of a document.
104
*
105
* <p>The SAX parser will invoke this method only once, before any
106
* other methods in this interface or in DTDHandler (except for
107
* setDocumentLocator).</p>
108
*
109
* @exception org.xml.sax.SAXException Any SAX exception, possibly
110
* wrapping another exception.
111
*/
112
public abstract void startDocument ()
113
throws SAXException;
114
115
116
/**
117
* Receive notification of the end of a document.
118
*
119
* <p>The SAX parser will invoke this method only once, and it will
120
* be the last method invoked during the parse. The parser shall
121
* not invoke this method until it has either abandoned parsing
122
* (because of an unrecoverable error) or reached the end of
123
* input.</p>
124
*
125
* @exception org.xml.sax.SAXException Any SAX exception, possibly
126
* wrapping another exception.
127
*/
128
public abstract void endDocument ()
129
throws SAXException;
130
131
132
/**
133
* Receive notification of the beginning of an element.
134
*
135
* <p>The Parser will invoke this method at the beginning of every
136
* element in the XML document; there will be a corresponding
137
* endElement() event for every startElement() event (even when the
138
* element is empty). All of the element's content will be
139
* reported, in order, before the corresponding endElement()
140
* event.</p>
141
*
142
* <p>If the element name has a namespace prefix, the prefix will
143
* still be attached. Note that the attribute list provided will
144
* contain only attributes with explicit values (specified or
145
* defaulted): #IMPLIED attributes will be omitted.</p>
146
*
147
* @param name The element type name.
148
* @param atts The attributes attached to the element, if any.
149
* @exception org.xml.sax.SAXException Any SAX exception, possibly
150
* wrapping another exception.
151
* @see #endElement
152
* @see org.xml.sax.AttributeList
153
*/
154
public abstract void startElement (String name, AttributeList atts)
155
throws SAXException;
156
157
158
/**
159
* Receive notification of the end of an element.
160
*
161
* <p>The SAX parser will invoke this method at the end of every
162
* element in the XML document; there will be a corresponding
163
* startElement() event for every endElement() event (even when the
164
* element is empty).</p>
165
*
166
* <p>If the element name has a namespace prefix, the prefix will
167
* still be attached to the name.</p>
168
*
169
* @param name The element type name
170
* @exception org.xml.sax.SAXException Any SAX exception, possibly
171
* wrapping another exception.
172
*/
173
public abstract void endElement (String name)
174
throws SAXException;
175
176
177
/**
178
* Receive notification of character data.
179
*
180
* <p>The Parser will call this method to report each chunk of
181
* character data. SAX parsers may return all contiguous character
182
* data in a single chunk, or they may split it into several
183
* chunks; however, all of the characters in any single event
184
* must come from the same external entity, so that the Locator
185
* provides useful information.</p>
186
*
187
* <p>The application must not attempt to read from the array
188
* outside of the specified range.</p>
189
*
190
* <p>Note that some parsers will report whitespace using the
191
* ignorableWhitespace() method rather than this one (validating
192
* parsers must do so).</p>
193
*
194
* @param ch The characters from the XML document.
195
* @param start The start position in the array.
196
* @param length The number of characters to read from the array.
197
* @exception org.xml.sax.SAXException Any SAX exception, possibly
198
* wrapping another exception.
199
* @see #ignorableWhitespace
200
* @see org.xml.sax.Locator
201
*/
202
public abstract void characters (char ch[], int start, int length)
203
throws SAXException;
204
205
206
/**
207
* Receive notification of ignorable whitespace in element content.
208
*
209
* <p>Validating Parsers must use this method to report each chunk
210
* of ignorable whitespace (see the W3C XML 1.0 recommendation,
211
* section 2.10): non-validating parsers may also use this method
212
* if they are capable of parsing and using content models.</p>
213
*
214
* <p>SAX parsers may return all contiguous whitespace in a single
215
* chunk, or they may split it into several chunks; however, all of
216
* the characters in any single event must come from the same
217
* external entity, so that the Locator provides useful
218
* information.</p>
219
*
220
* <p>The application must not attempt to read from the array
221
* outside of the specified range.</p>
222
*
223
* @param ch The characters from the XML document.
224
* @param start The start position in the array.
225
* @param length The number of characters to read from the array.
226
* @exception org.xml.sax.SAXException Any SAX exception, possibly
227
* wrapping another exception.
228
* @see #characters
229
*/
230
public abstract void ignorableWhitespace (char ch[], int start, int length)
231
throws SAXException;
232
233
234
/**
235
* Receive notification of a processing instruction.
236
*
237
* <p>The Parser will invoke this method once for each processing
238
* instruction found: note that processing instructions may occur
239
* before or after the main document element.</p>
240
*
241
* <p>A SAX parser should never report an XML declaration (XML 1.0,
242
* section 2.8) or a text declaration (XML 1.0, section 4.3.1)
243
* using this method.</p>
244
*
245
* @param target The processing instruction target.
246
* @param data The processing instruction data, or null if
247
* none was supplied.
248
* @exception org.xml.sax.SAXException Any SAX exception, possibly
249
* wrapping another exception.
250
*/
251
public abstract void processingInstruction (String target, String data)
252
throws SAXException;
253
254
}
255
256
// end of DocumentHandler.java
257
258