1 /*
2 * Copyright (c) 2000, 2019, 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
57 * @see org.xml.sax.EntityResolver
58 * @see org.xml.sax.DTDHandler
59 * @see org.xml.sax.DocumentHandler
60 * @see org.xml.sax.ErrorHandler
61 * @see org.xml.sax.HandlerBase
62 * @see org.xml.sax.InputSource
63 */
64 @Deprecated(since="1.5")
65 public interface Parser
66 {
67
68 /**
69 * Allow an application to request a locale for errors and warnings.
70 *
71 * <p>SAX parsers are not required to provide localisation for errors
72 * and warnings; if they cannot support the requested locale,
73 * however, they must throw a SAX exception. Applications may
74 * not request a locale change in the middle of a parse.</p>
75 *
76 * @param locale A Java Locale object.
77 * @exception org.xml.sax.SAXException Throws an exception
78 * (using the previous or default locale) if the
79 * requested locale is not supported.
80 * @see org.xml.sax.SAXException
81 * @see org.xml.sax.SAXParseException
82 */
83 public abstract void setLocale (Locale locale)
84 throws SAXException;
85
86
87 /**
88 * Allow an application to register a custom entity resolver.
89 *
90 * <p>If the application does not register an entity resolver, the
91 * SAX parser will resolve system identifiers and open connections
92 * to entities itself (this is the default behaviour implemented in
93 * HandlerBase).</p>
94 *
95 * <p>Applications may register a new or different entity resolver
96 * in the middle of a parse, and the SAX parser must begin using
97 * the new resolver immediately.</p>
159 * @see HandlerBase
160 */
161 public abstract void setErrorHandler (ErrorHandler handler);
162
163
164 /**
165 * Parse an XML document.
166 *
167 * <p>The application can use this method to instruct the SAX parser
168 * to begin parsing an XML document from any valid input
169 * source (a character stream, a byte stream, or a URI).</p>
170 *
171 * <p>Applications may not invoke this method while a parse is in
172 * progress (they should create a new Parser instead for each
173 * additional XML document). Once a parse is complete, an
174 * application may reuse the same Parser object, possibly with a
175 * different input source.</p>
176 *
177 * @param source The input source for the top-level of the
178 * XML document.
179 * @exception org.xml.sax.SAXException Any SAX exception, possibly
180 * wrapping another exception.
181 * @exception java.io.IOException An IO exception from the parser,
182 * possibly from a byte stream or character stream
183 * supplied by the application.
184 * @see org.xml.sax.InputSource
185 * @see #parse(java.lang.String)
186 * @see #setEntityResolver
187 * @see #setDTDHandler
188 * @see #setDocumentHandler
189 * @see #setErrorHandler
190 */
191 public abstract void parse (InputSource source)
192 throws SAXException, IOException;
193
194
195 /**
196 * Parse an XML document from a system identifier (URI).
197 *
198 * <p>This method is a shortcut for the common case of reading a
199 * document from a system identifier. It is the exact
200 * equivalent of the following:</p>
201 *
202 * <pre>
203 * parse(new InputSource(systemId));
204 * </pre>
205 *
206 * <p>If the system identifier is a URL, it must be fully resolved
207 * by the application before it is passed to the parser.</p>
208 *
209 * @param systemId The system identifier (URI).
210 * @exception org.xml.sax.SAXException Any SAX exception, possibly
211 * wrapping another exception.
212 * @exception java.io.IOException An IO exception from the parser,
213 * possibly from a byte stream or character stream
214 * supplied by the application.
215 * @see #parse(org.xml.sax.InputSource)
216 */
217 public abstract void parse (String systemId)
218 throws SAXException, IOException;
219
220 }
221
222 // end of Parser.java
|
1 /*
2 * Copyright (c) 2000, 2020, 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
57 * @see org.xml.sax.EntityResolver
58 * @see org.xml.sax.DTDHandler
59 * @see org.xml.sax.DocumentHandler
60 * @see org.xml.sax.ErrorHandler
61 * @see org.xml.sax.HandlerBase
62 * @see org.xml.sax.InputSource
63 */
64 @Deprecated(since="1.5")
65 public interface Parser
66 {
67
68 /**
69 * Allow an application to request a locale for errors and warnings.
70 *
71 * <p>SAX parsers are not required to provide localisation for errors
72 * and warnings; if they cannot support the requested locale,
73 * however, they must throw a SAX exception. Applications may
74 * not request a locale change in the middle of a parse.</p>
75 *
76 * @param locale A Java Locale object.
77 * @throws org.xml.sax.SAXException Throws an exception
78 * (using the previous or default locale) if the
79 * requested locale is not supported.
80 * @see org.xml.sax.SAXException
81 * @see org.xml.sax.SAXParseException
82 */
83 public abstract void setLocale (Locale locale)
84 throws SAXException;
85
86
87 /**
88 * Allow an application to register a custom entity resolver.
89 *
90 * <p>If the application does not register an entity resolver, the
91 * SAX parser will resolve system identifiers and open connections
92 * to entities itself (this is the default behaviour implemented in
93 * HandlerBase).</p>
94 *
95 * <p>Applications may register a new or different entity resolver
96 * in the middle of a parse, and the SAX parser must begin using
97 * the new resolver immediately.</p>
159 * @see HandlerBase
160 */
161 public abstract void setErrorHandler (ErrorHandler handler);
162
163
164 /**
165 * Parse an XML document.
166 *
167 * <p>The application can use this method to instruct the SAX parser
168 * to begin parsing an XML document from any valid input
169 * source (a character stream, a byte stream, or a URI).</p>
170 *
171 * <p>Applications may not invoke this method while a parse is in
172 * progress (they should create a new Parser instead for each
173 * additional XML document). Once a parse is complete, an
174 * application may reuse the same Parser object, possibly with a
175 * different input source.</p>
176 *
177 * @param source The input source for the top-level of the
178 * XML document.
179 * @throws org.xml.sax.SAXException Any SAX exception, possibly
180 * wrapping another exception.
181 * @throws java.io.IOException An IO exception from the parser,
182 * possibly from a byte stream or character stream
183 * supplied by the application.
184 * @see org.xml.sax.InputSource
185 * @see #parse(java.lang.String)
186 * @see #setEntityResolver
187 * @see #setDTDHandler
188 * @see #setDocumentHandler
189 * @see #setErrorHandler
190 */
191 public abstract void parse (InputSource source)
192 throws SAXException, IOException;
193
194
195 /**
196 * Parse an XML document from a system identifier (URI).
197 *
198 * <p>This method is a shortcut for the common case of reading a
199 * document from a system identifier. It is the exact
200 * equivalent of the following:</p>
201 *
202 * <pre>
203 * parse(new InputSource(systemId));
204 * </pre>
205 *
206 * <p>If the system identifier is a URL, it must be fully resolved
207 * by the application before it is passed to the parser.</p>
208 *
209 * @param systemId The system identifier (URI).
210 * @throws org.xml.sax.SAXException Any SAX exception, possibly
211 * wrapping another exception.
212 * @throws java.io.IOException An IO exception from the parser,
213 * possibly from a byte stream or character stream
214 * supplied by the application.
215 * @see #parse(org.xml.sax.InputSource)
216 */
217 public abstract void parse (String systemId)
218 throws SAXException, IOException;
219
220 }
221
222 // end of Parser.java
|