2
* Copyright (c) 2004 World Wide Web Consortium,
4
* (Massachusetts Institute of Technology, European Research Consortium for
5
* Informatics and Mathematics, Keio University). All Rights Reserved. This
6
* work is distributed under the W3C(r) Software License [1] in the hope that
7
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
8
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10
* [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231
13
package org.w3c.dom.ls;
16
* This interface represents an input source for data.
17
* <p> This interface allows an application to encapsulate information about
18
* an input source in a single object, which may include a public
19
* identifier, a system identifier, a byte stream (possibly with a specified
20
* encoding), a base URI, and/or a character stream.
21
* <p> The exact definitions of a byte stream and a character stream are
23
* <p> The application is expected to provide objects that implement this
24
* interface whenever such objects are needed. The application can either
25
* provide its own objects that implement this interface, or it can use the
26
* generic factory method <code>DOMImplementationLS.createLSInput()</code>
27
* to create objects that implement this interface.
28
* <p> The <code>LSParser</code> will use the <code>LSInput</code> object to
29
* determine how to read data. The <code>LSParser</code> will look at the
30
* different inputs specified in the <code>LSInput</code> in the following
31
* order to know which one to read from, the first one that is not null and
32
* not an empty string will be used:
34
* <li> <code>LSInput.characterStream</code>
37
* <code>LSInput.byteStream</code>
39
* <li> <code>LSInput.stringData</code>
42
* <code>LSInput.systemId</code>
44
* <li> <code>LSInput.publicId</code>
47
* <p> If all inputs are null, the <code>LSParser</code> will report a
48
* <code>DOMError</code> with its <code>DOMError.type</code> set to
49
* <code>"no-input-specified"</code> and its <code>DOMError.severity</code>
50
* set to <code>DOMError.SEVERITY_FATAL_ERROR</code>.
51
* <p> <code>LSInput</code> objects belong to the application. The DOM
52
* implementation will never modify them (though it may make copies and
53
* modify the copies, if necessary).
55
public interface LSInput {
57
* An attribute of a language and binding dependent type that represents
58
* a stream of 16-bit units. The application must encode the stream
59
* using UTF-16 (defined in [Unicode] and in [ISO/IEC 10646]).
61
public java.io.Reader getCharacterStream();
63
* An attribute of a language and binding dependent type that represents
64
* a stream of 16-bit units. The application must encode the stream
65
* using UTF-16 (defined in [Unicode] and in [ISO/IEC 10646]).
67
public void setCharacterStream(java.io.Reader characterStream);
70
* An attribute of a language and binding dependent type that represents
72
* <br> If the application knows the character encoding of the byte
73
* stream, it should set the encoding attribute. Setting the encoding in
74
* this way will override any encoding specified in an XML declaration
77
public java.io.InputStream getByteStream();
79
* An attribute of a language and binding dependent type that represents
81
* <br> If the application knows the character encoding of the byte
82
* stream, it should set the encoding attribute. Setting the encoding in
83
* this way will override any encoding specified in an XML declaration
86
public void setByteStream(java.io.InputStream byteStream);
89
* String data to parse. If provided, this will always be treated as a
90
* sequence of 16-bit units (UTF-16 encoded characters).
92
public String getStringData();
94
* String data to parse. If provided, this will always be treated as a
95
* sequence of 16-bit units (UTF-16 encoded characters).
97
public void setStringData(String stringData);
100
* The system identifier, a URI reference [<a href='http://www.ietf.org/rfc/rfc2396.txt'>IETF RFC 2396</a>], for this
101
* input source. The system identifier is optional if there is a byte
102
* stream, a character stream, or string data, but it is still useful to
103
* provide one, since the application will use it to resolve any
104
* relative URIs and can include it in error messages and warnings (the
105
* <code>LSParser</code> will only attempt to fetch the resource
106
* identified by the URI reference if there is no other input available
107
* in the input source).
108
* <br> If the application knows the character encoding of the object
109
* pointed to by the system identifier, it can set the encoding using
110
* the <code>encoding</code> attribute.
111
* <br> If the specified system ID is a relative URI reference (see
112
* section 5 in [<a href='http://www.ietf.org/rfc/rfc2396.txt'>IETF RFC 2396</a>]), the DOM
113
* implementation will attempt to resolve the relative URI with the
114
* <code>baseURI</code> as the base, if that fails, the behavior is
115
* implementation dependent.
117
public String getSystemId();
119
* The system identifier, a URI reference [<a href='http://www.ietf.org/rfc/rfc2396.txt'>IETF RFC 2396</a>], for this
120
* input source. The system identifier is optional if there is a byte
121
* stream, a character stream, or string data, but it is still useful to
122
* provide one, since the application will use it to resolve any
123
* relative URIs and can include it in error messages and warnings (the
124
* <code>LSParser</code> will only attempt to fetch the resource
125
* identified by the URI reference if there is no other input available
126
* in the input source).
127
* <br> If the application knows the character encoding of the object
128
* pointed to by the system identifier, it can set the encoding using
129
* the <code>encoding</code> attribute.
130
* <br> If the specified system ID is a relative URI reference (see
131
* section 5 in [<a href='http://www.ietf.org/rfc/rfc2396.txt'>IETF RFC 2396</a>]), the DOM
132
* implementation will attempt to resolve the relative URI with the
133
* <code>baseURI</code> as the base, if that fails, the behavior is
134
* implementation dependent.
136
public void setSystemId(String systemId);
139
* The public identifier for this input source. This may be mapped to an
140
* input source using an implementation dependent mechanism (such as
141
* catalogues or other mappings). The public identifier, if specified,
142
* may also be reported as part of the location information when errors
145
public String getPublicId();
147
* The public identifier for this input source. This may be mapped to an
148
* input source using an implementation dependent mechanism (such as
149
* catalogues or other mappings). The public identifier, if specified,
150
* may also be reported as part of the location information when errors
153
public void setPublicId(String publicId);
156
* 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
157
* resolving a relative <code>systemId</code> to an absolute URI.
158
* <br> If, when used, the base URI is itself a relative URI, an empty
159
* string, or null, the behavior is implementation dependent.
161
public String getBaseURI();
163
* 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
164
* resolving a relative <code>systemId</code> to an absolute URI.
165
* <br> If, when used, the base URI is itself a relative URI, an empty
166
* string, or null, the behavior is implementation dependent.
168
public void setBaseURI(String baseURI);
171
* The character encoding, if known. The encoding must be a string
172
* acceptable for an XML encoding declaration ([<a href='http://www.w3.org/TR/2000/REC-xml-20001006'>XML 1.0</a>] section
173
* 4.3.3 "Character Encoding in Entities").
174
* <br> This attribute has no effect when the application provides a
175
* character stream or string data. For other sources of input, an
176
* encoding specified by means of this attribute will override any
177
* encoding specified in the XML declaration or the Text declaration, or
178
* an encoding obtained from a higher level protocol, such as HTTP [<a href='http://www.ietf.org/rfc/rfc2616.txt'>IETF RFC 2616</a>].
180
public String getEncoding();
182
* The character encoding, if known. The encoding must be a string
183
* acceptable for an XML encoding declaration ([<a href='http://www.w3.org/TR/2000/REC-xml-20001006'>XML 1.0</a>] section
184
* 4.3.3 "Character Encoding in Entities").
185
* <br> This attribute has no effect when the application provides a
186
* character stream or string data. For other sources of input, an
187
* encoding specified by means of this attribute will override any
188
* encoding specified in the XML declaration or the Text declaration, or
189
* an encoding obtained from a higher level protocol, such as HTTP [<a href='http://www.ietf.org/rfc/rfc2616.txt'>IETF RFC 2616</a>].
191
public void setEncoding(String encoding);
194
* If set to true, assume that the input is certified (see section 2.13
195
* in [<a href='http://www.w3.org/TR/2003/PR-xml11-20031105/'>XML 1.1</a>]) when
196
* parsing [<a href='http://www.w3.org/TR/2003/PR-xml11-20031105/'>XML 1.1</a>].
198
public boolean getCertifiedText();
200
* If set to true, assume that the input is certified (see section 2.13
201
* in [<a href='http://www.w3.org/TR/2003/PR-xml11-20031105/'>XML 1.1</a>]) when
202
* parsing [<a href='http://www.w3.org/TR/2003/PR-xml11-20031105/'>XML 1.1</a>].
204
public void setCertifiedText(boolean certifiedText);