12005
|
1 |
/*
|
|
2 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
3 |
*
|
|
4 |
* This code is free software; you can redistribute it and/or modify it
|
|
5 |
* under the terms of the GNU General Public License version 2 only, as
|
|
6 |
* published by the Free Software Foundation. Oracle designates this
|
|
7 |
* particular file as subject to the "Classpath" exception as provided
|
|
8 |
* by Oracle in the LICENSE file that accompanied this code.
|
|
9 |
*
|
|
10 |
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
11 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
12 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
13 |
* version 2 for more details (a copy is included in the LICENSE file that
|
|
14 |
* accompanied this code).
|
|
15 |
*
|
|
16 |
* You should have received a copy of the GNU General Public License version
|
|
17 |
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
18 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
19 |
*
|
|
20 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
21 |
* or visit www.oracle.com if you need additional information or have any
|
|
22 |
* questions.
|
|
23 |
*/
|
|
24 |
|
|
25 |
/*
|
|
26 |
* This file is available under and governed by the GNU General Public
|
|
27 |
* License version 2 only, as published by the Free Software Foundation.
|
|
28 |
* However, the following notice accompanied the original version of this
|
|
29 |
* file and, per its terms, should not be removed:
|
|
30 |
*
|
|
31 |
* Copyright (c) 2004 World Wide Web Consortium,
|
|
32 |
*
|
|
33 |
* (Massachusetts Institute of Technology, European Research Consortium for
|
|
34 |
* Informatics and Mathematics, Keio University). All Rights Reserved. This
|
|
35 |
* work is distributed under the W3C(r) Software License [1] in the hope that
|
|
36 |
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
|
|
37 |
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
38 |
*
|
|
39 |
* [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231
|
|
40 |
*/
|
|
41 |
|
|
42 |
package org.w3c.dom.ls;
|
|
43 |
|
|
44 |
/**
|
|
45 |
* This interface represents an input source for data.
|
|
46 |
* <p> This interface allows an application to encapsulate information about
|
|
47 |
* an input source in a single object, which may include a public
|
|
48 |
* identifier, a system identifier, a byte stream (possibly with a specified
|
|
49 |
* encoding), a base URI, and/or a character stream.
|
|
50 |
* <p> The exact definitions of a byte stream and a character stream are
|
|
51 |
* binding dependent.
|
|
52 |
* <p> The application is expected to provide objects that implement this
|
|
53 |
* interface whenever such objects are needed. The application can either
|
|
54 |
* provide its own objects that implement this interface, or it can use the
|
|
55 |
* generic factory method <code>DOMImplementationLS.createLSInput()</code>
|
|
56 |
* to create objects that implement this interface.
|
|
57 |
* <p> The <code>LSParser</code> will use the <code>LSInput</code> object to
|
|
58 |
* determine how to read data. The <code>LSParser</code> will look at the
|
|
59 |
* different inputs specified in the <code>LSInput</code> in the following
|
|
60 |
* order to know which one to read from, the first one that is not null and
|
|
61 |
* not an empty string will be used:
|
|
62 |
* <ol>
|
|
63 |
* <li> <code>LSInput.characterStream</code>
|
|
64 |
* </li>
|
|
65 |
* <li>
|
|
66 |
* <code>LSInput.byteStream</code>
|
|
67 |
* </li>
|
|
68 |
* <li> <code>LSInput.stringData</code>
|
|
69 |
* </li>
|
|
70 |
* <li>
|
|
71 |
* <code>LSInput.systemId</code>
|
|
72 |
* </li>
|
|
73 |
* <li> <code>LSInput.publicId</code>
|
|
74 |
* </li>
|
|
75 |
* </ol>
|
|
76 |
* <p> If all inputs are null, the <code>LSParser</code> will report a
|
|
77 |
* <code>DOMError</code> with its <code>DOMError.type</code> set to
|
|
78 |
* <code>"no-input-specified"</code> and its <code>DOMError.severity</code>
|
|
79 |
* set to <code>DOMError.SEVERITY_FATAL_ERROR</code>.
|
|
80 |
* <p> <code>LSInput</code> objects belong to the application. The DOM
|
|
81 |
* implementation will never modify them (though it may make copies and
|
|
82 |
* modify the copies, if necessary).
|
|
83 |
* <p>See also the <a href='http://www.w3.org/TR/2004/REC-DOM-Level-3-LS-20040407'>Document Object Model (DOM) Level 3 Load
|
|
84 |
and Save Specification</a>.
|
25262
|
85 |
*
|
|
86 |
* @since 1.5
|
12005
|
87 |
*/
|
|
88 |
public interface LSInput {
|
|
89 |
/**
|
|
90 |
* An attribute of a language and binding dependent type that represents
|
|
91 |
* a stream of 16-bit units. The application must encode the stream
|
|
92 |
* using UTF-16 (defined in [Unicode] and in [ISO/IEC 10646]). It is not a requirement to have an XML declaration when
|
|
93 |
* using character streams. If an XML declaration is present, the value
|
|
94 |
* of the encoding attribute will be ignored.
|
|
95 |
*/
|
|
96 |
public java.io.Reader getCharacterStream();
|
|
97 |
/**
|
|
98 |
* An attribute of a language and binding dependent type that represents
|
|
99 |
* a stream of 16-bit units. The application must encode the stream
|
|
100 |
* using UTF-16 (defined in [Unicode] and in [ISO/IEC 10646]). It is not a requirement to have an XML declaration when
|
|
101 |
* using character streams. If an XML declaration is present, the value
|
|
102 |
* of the encoding attribute will be ignored.
|
|
103 |
*/
|
|
104 |
public void setCharacterStream(java.io.Reader characterStream);
|
|
105 |
|
|
106 |
/**
|
|
107 |
* An attribute of a language and binding dependent type that represents
|
|
108 |
* a stream of bytes.
|
|
109 |
* <br> If the application knows the character encoding of the byte
|
|
110 |
* stream, it should set the encoding attribute. Setting the encoding in
|
|
111 |
* this way will override any encoding specified in an XML declaration
|
|
112 |
* in the data.
|
|
113 |
*/
|
|
114 |
public java.io.InputStream getByteStream();
|
|
115 |
/**
|
|
116 |
* An attribute of a language and binding dependent type that represents
|
|
117 |
* a stream of bytes.
|
|
118 |
* <br> If the application knows the character encoding of the byte
|
|
119 |
* stream, it should set the encoding attribute. Setting the encoding in
|
|
120 |
* this way will override any encoding specified in an XML declaration
|
|
121 |
* in the data.
|
|
122 |
*/
|
|
123 |
public void setByteStream(java.io.InputStream byteStream);
|
|
124 |
|
|
125 |
/**
|
|
126 |
* String data to parse. If provided, this will always be treated as a
|
|
127 |
* sequence of 16-bit units (UTF-16 encoded characters). It is not a
|
|
128 |
* requirement to have an XML declaration when using
|
|
129 |
* <code>stringData</code>. If an XML declaration is present, the value
|
|
130 |
* of the encoding attribute will be ignored.
|
|
131 |
*/
|
|
132 |
public String getStringData();
|
|
133 |
/**
|
|
134 |
* String data to parse. If provided, this will always be treated as a
|
|
135 |
* sequence of 16-bit units (UTF-16 encoded characters). It is not a
|
|
136 |
* requirement to have an XML declaration when using
|
|
137 |
* <code>stringData</code>. If an XML declaration is present, the value
|
|
138 |
* of the encoding attribute will be ignored.
|
|
139 |
*/
|
|
140 |
public void setStringData(String stringData);
|
|
141 |
|
|
142 |
/**
|
|
143 |
* The system identifier, a URI reference [<a href='http://www.ietf.org/rfc/rfc2396.txt'>IETF RFC 2396</a>], for this
|
|
144 |
* input source. The system identifier is optional if there is a byte
|
|
145 |
* stream, a character stream, or string data. It is still useful to
|
|
146 |
* provide one, since the application will use it to resolve any
|
|
147 |
* relative URIs and can include it in error messages and warnings. (The
|
|
148 |
* LSParser will only attempt to fetch the resource identified by the
|
|
149 |
* URI reference if there is no other input available in the input
|
|
150 |
* source.)
|
|
151 |
* <br> If the application knows the character encoding of the object
|
|
152 |
* pointed to by the system identifier, it can set the encoding using
|
|
153 |
* the <code>encoding</code> attribute.
|
|
154 |
* <br> If the specified system ID is a relative URI reference (see
|
|
155 |
* section 5 in [<a href='http://www.ietf.org/rfc/rfc2396.txt'>IETF RFC 2396</a>]), the DOM
|
|
156 |
* implementation will attempt to resolve the relative URI with the
|
|
157 |
* <code>baseURI</code> as the base, if that fails, the behavior is
|
|
158 |
* implementation dependent.
|
|
159 |
*/
|
|
160 |
public String getSystemId();
|
|
161 |
/**
|
|
162 |
* The system identifier, a URI reference [<a href='http://www.ietf.org/rfc/rfc2396.txt'>IETF RFC 2396</a>], for this
|
|
163 |
* input source. The system identifier is optional if there is a byte
|
|
164 |
* stream, a character stream, or string data. It is still useful to
|
|
165 |
* provide one, since the application will use it to resolve any
|
|
166 |
* relative URIs and can include it in error messages and warnings. (The
|
|
167 |
* LSParser will only attempt to fetch the resource identified by the
|
|
168 |
* URI reference if there is no other input available in the input
|
|
169 |
* source.)
|
|
170 |
* <br> If the application knows the character encoding of the object
|
|
171 |
* pointed to by the system identifier, it can set the encoding using
|
|
172 |
* the <code>encoding</code> attribute.
|
|
173 |
* <br> If the specified system ID is a relative URI reference (see
|
|
174 |
* section 5 in [<a href='http://www.ietf.org/rfc/rfc2396.txt'>IETF RFC 2396</a>]), the DOM
|
|
175 |
* implementation will attempt to resolve the relative URI with the
|
|
176 |
* <code>baseURI</code> as the base, if that fails, the behavior is
|
|
177 |
* implementation dependent.
|
|
178 |
*/
|
|
179 |
public void setSystemId(String systemId);
|
|
180 |
|
|
181 |
/**
|
|
182 |
* The public identifier for this input source. This may be mapped to an
|
|
183 |
* input source using an implementation dependent mechanism (such as
|
|
184 |
* catalogues or other mappings). The public identifier, if specified,
|
|
185 |
* may also be reported as part of the location information when errors
|
|
186 |
* are reported.
|
|
187 |
*/
|
|
188 |
public String getPublicId();
|
|
189 |
/**
|
|
190 |
* The public identifier for this input source. This may be mapped to an
|
|
191 |
* input source using an implementation dependent mechanism (such as
|
|
192 |
* catalogues or other mappings). The public identifier, if specified,
|
|
193 |
* may also be reported as part of the location information when errors
|
|
194 |
* are reported.
|
|
195 |
*/
|
|
196 |
public void setPublicId(String publicId);
|
|
197 |
|
|
198 |
/**
|
|
199 |
* The base URI to be used (see section 5.1.4 in [<a href='http://www.ietf.org/rfc/rfc2396.txt'>IETF RFC 2396</a>]) for
|
|
200 |
* resolving a relative <code>systemId</code> to an absolute URI.
|
|
201 |
* <br> If, when used, the base URI is itself a relative URI, an empty
|
|
202 |
* string, or null, the behavior is implementation dependent.
|
|
203 |
*/
|
|
204 |
public String getBaseURI();
|
|
205 |
/**
|
|
206 |
* The base URI to be used (see section 5.1.4 in [<a href='http://www.ietf.org/rfc/rfc2396.txt'>IETF RFC 2396</a>]) for
|
|
207 |
* resolving a relative <code>systemId</code> to an absolute URI.
|
|
208 |
* <br> If, when used, the base URI is itself a relative URI, an empty
|
|
209 |
* string, or null, the behavior is implementation dependent.
|
|
210 |
*/
|
|
211 |
public void setBaseURI(String baseURI);
|
|
212 |
|
|
213 |
/**
|
|
214 |
* The character encoding, if known. The encoding must be a string
|
|
215 |
* acceptable for an XML encoding declaration ([<a href='http://www.w3.org/TR/2004/REC-xml-20040204'>XML 1.0</a>] section
|
|
216 |
* 4.3.3 "Character Encoding in Entities").
|
|
217 |
* <br> This attribute has no effect when the application provides a
|
|
218 |
* character stream or string data. For other sources of input, an
|
|
219 |
* encoding specified by means of this attribute will override any
|
|
220 |
* encoding specified in the XML declaration or the Text declaration, or
|
|
221 |
* an encoding obtained from a higher level protocol, such as HTTP [<a href='http://www.ietf.org/rfc/rfc2616.txt'>IETF RFC 2616</a>].
|
|
222 |
*/
|
|
223 |
public String getEncoding();
|
|
224 |
/**
|
|
225 |
* The character encoding, if known. The encoding must be a string
|
|
226 |
* acceptable for an XML encoding declaration ([<a href='http://www.w3.org/TR/2004/REC-xml-20040204'>XML 1.0</a>] section
|
|
227 |
* 4.3.3 "Character Encoding in Entities").
|
|
228 |
* <br> This attribute has no effect when the application provides a
|
|
229 |
* character stream or string data. For other sources of input, an
|
|
230 |
* encoding specified by means of this attribute will override any
|
|
231 |
* encoding specified in the XML declaration or the Text declaration, or
|
|
232 |
* an encoding obtained from a higher level protocol, such as HTTP [<a href='http://www.ietf.org/rfc/rfc2616.txt'>IETF RFC 2616</a>].
|
|
233 |
*/
|
|
234 |
public void setEncoding(String encoding);
|
|
235 |
|
|
236 |
/**
|
|
237 |
* If set to true, assume that the input is certified (see section 2.13
|
|
238 |
* in [<a href='http://www.w3.org/TR/2004/REC-xml11-20040204/'>XML 1.1</a>]) when
|
|
239 |
* parsing [<a href='http://www.w3.org/TR/2004/REC-xml11-20040204/'>XML 1.1</a>].
|
|
240 |
*/
|
|
241 |
public boolean getCertifiedText();
|
|
242 |
/**
|
|
243 |
* If set to true, assume that the input is certified (see section 2.13
|
|
244 |
* in [<a href='http://www.w3.org/TR/2004/REC-xml11-20040204/'>XML 1.1</a>]) when
|
|
245 |
* parsing [<a href='http://www.w3.org/TR/2004/REC-xml11-20040204/'>XML 1.1</a>].
|
|
246 |
*/
|
|
247 |
public void setCertifiedText(boolean certifiedText);
|
|
248 |
|
|
249 |
}
|