001/*
002 * Copyright (c) 2004 World Wide Web Consortium,
003 *
004 * (Massachusetts Institute of Technology, European Research Consortium for
005 * Informatics and Mathematics, Keio University). All Rights Reserved. This
006 * work is distributed under the W3C(r) Software License [1] in the hope that
007 * it will be useful, but WITHOUT ANY WARRANTY; without even the implied
008 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
009 *
010 * [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231
011 */
012
013package org.w3c.dom.ls;
014
015/**
016 *  This interface represents an input source for data. 
017 * <p> This interface allows an application to encapsulate information about 
018 * an input source in a single object, which may include a public 
019 * identifier, a system identifier, a byte stream (possibly with a specified 
020 * encoding), a base URI, and/or a character stream. 
021 * <p> The exact definitions of a byte stream and a character stream are 
022 * binding dependent. 
023 * <p> The application is expected to provide objects that implement this 
024 * interface whenever such objects are needed. The application can either 
025 * provide its own objects that implement this interface, or it can use the 
026 * generic factory method <code>DOMImplementationLS.createLSInput()</code> 
027 * to create objects that implement this interface. 
028 * <p> The <code>LSParser</code> will use the <code>LSInput</code> object to 
029 * determine how to read data. The <code>LSParser</code> will look at the 
030 * different inputs specified in the <code>LSInput</code> in the following 
031 * order to know which one to read from, the first one that is not null and 
032 * not an empty string will be used: 
033 * <ol>
034 * <li> <code>LSInput.characterStream</code> 
035 * </li>
036 * <li> 
037 * <code>LSInput.byteStream</code> 
038 * </li>
039 * <li> <code>LSInput.stringData</code> 
040 * </li>
041 * <li> 
042 * <code>LSInput.systemId</code> 
043 * </li>
044 * <li> <code>LSInput.publicId</code> 
045 * </li>
046 * </ol> 
047 * <p> If all inputs are null, the <code>LSParser</code> will report a 
048 * <code>DOMError</code> with its <code>DOMError.type</code> set to 
049 * <code>"no-input-specified"</code> and its <code>DOMError.severity</code> 
050 * set to <code>DOMError.SEVERITY_FATAL_ERROR</code>. 
051 * <p> <code>LSInput</code> objects belong to the application. The DOM 
052 * implementation will never modify them (though it may make copies and 
053 * modify the copies, if necessary). 
054 * <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
055and Save Specification</a>.
056 */
057public interface LSInput {
058    /**
059     *  An attribute of a language and binding dependent type that represents 
060     * a stream of 16-bit units. The application must encode the stream 
061     * using UTF-16 (defined in [Unicode] and in [ISO/IEC 10646]). It is not a requirement to have an XML declaration when 
062     * using character streams. If an XML declaration is present, the value 
063     * of the encoding attribute will be ignored. 
064     */
065    public java.io.Reader getCharacterStream();
066    /**
067     *  An attribute of a language and binding dependent type that represents 
068     * a stream of 16-bit units. The application must encode the stream 
069     * using UTF-16 (defined in [Unicode] and in [ISO/IEC 10646]). It is not a requirement to have an XML declaration when 
070     * using character streams. If an XML declaration is present, the value 
071     * of the encoding attribute will be ignored. 
072     */
073    public void setCharacterStream(java.io.Reader characterStream);
074
075    /**
076     *  An attribute of a language and binding dependent type that represents 
077     * a stream of bytes. 
078     * <br> If the application knows the character encoding of the byte 
079     * stream, it should set the encoding attribute. Setting the encoding in 
080     * this way will override any encoding specified in an XML declaration 
081     * in the data. 
082     */
083    public java.io.InputStream getByteStream();
084    /**
085     *  An attribute of a language and binding dependent type that represents 
086     * a stream of bytes. 
087     * <br> If the application knows the character encoding of the byte 
088     * stream, it should set the encoding attribute. Setting the encoding in 
089     * this way will override any encoding specified in an XML declaration 
090     * in the data. 
091     */
092    public void setByteStream(java.io.InputStream byteStream);
093
094    /**
095     *  String data to parse. If provided, this will always be treated as a 
096     * sequence of 16-bit units (UTF-16 encoded characters). It is not a 
097     * requirement to have an XML declaration when using 
098     * <code>stringData</code>. If an XML declaration is present, the value 
099     * of the encoding attribute will be ignored. 
100     */
101    public String getStringData();
102    /**
103     *  String data to parse. If provided, this will always be treated as a 
104     * sequence of 16-bit units (UTF-16 encoded characters). It is not a 
105     * requirement to have an XML declaration when using 
106     * <code>stringData</code>. If an XML declaration is present, the value 
107     * of the encoding attribute will be ignored. 
108     */
109    public void setStringData(String stringData);
110
111    /**
112     *  The system identifier, a URI reference [<a href='http://www.ietf.org/rfc/rfc2396.txt'>IETF RFC 2396</a>], for this 
113     * input source. The system identifier is optional if there is a byte 
114     * stream, a character stream, or string data. It is still useful to 
115     * provide one, since the application will use it to resolve any 
116     * relative URIs and can include it in error messages and warnings. (The 
117     * LSParser will only attempt to fetch the resource identified by the 
118     * URI reference if there is no other input available in the input 
119     * source.) 
120     * <br> If the application knows the character encoding of the object 
121     * pointed to by the system identifier, it can set the encoding using 
122     * the <code>encoding</code> attribute. 
123     * <br> If the specified system ID is a relative URI reference (see 
124     * section 5 in [<a href='http://www.ietf.org/rfc/rfc2396.txt'>IETF RFC 2396</a>]), the DOM 
125     * implementation will attempt to resolve the relative URI with the 
126     * <code>baseURI</code> as the base, if that fails, the behavior is 
127     * implementation dependent. 
128     */
129    public String getSystemId();
130    /**
131     *  The system identifier, a URI reference [<a href='http://www.ietf.org/rfc/rfc2396.txt'>IETF RFC 2396</a>], for this 
132     * input source. The system identifier is optional if there is a byte 
133     * stream, a character stream, or string data. It is still useful to 
134     * provide one, since the application will use it to resolve any 
135     * relative URIs and can include it in error messages and warnings. (The 
136     * LSParser will only attempt to fetch the resource identified by the 
137     * URI reference if there is no other input available in the input 
138     * source.) 
139     * <br> If the application knows the character encoding of the object 
140     * pointed to by the system identifier, it can set the encoding using 
141     * the <code>encoding</code> attribute. 
142     * <br> If the specified system ID is a relative URI reference (see 
143     * section 5 in [<a href='http://www.ietf.org/rfc/rfc2396.txt'>IETF RFC 2396</a>]), the DOM 
144     * implementation will attempt to resolve the relative URI with the 
145     * <code>baseURI</code> as the base, if that fails, the behavior is 
146     * implementation dependent. 
147     */
148    public void setSystemId(String systemId);
149
150    /**
151     *  The public identifier for this input source. This may be mapped to an 
152     * input source using an implementation dependent mechanism (such as 
153     * catalogues or other mappings). The public identifier, if specified, 
154     * may also be reported as part of the location information when errors 
155     * are reported. 
156     */
157    public String getPublicId();
158    /**
159     *  The public identifier for this input source. This may be mapped to an 
160     * input source using an implementation dependent mechanism (such as 
161     * catalogues or other mappings). The public identifier, if specified, 
162     * may also be reported as part of the location information when errors 
163     * are reported. 
164     */
165    public void setPublicId(String publicId);
166
167    /**
168     *  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 
169     * resolving a relative <code>systemId</code> to an absolute URI. 
170     * <br> If, when used, the base URI is itself a relative URI, an empty 
171     * string, or null, the behavior is implementation dependent. 
172     */
173    public String getBaseURI();
174    /**
175     *  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 
176     * resolving a relative <code>systemId</code> to an absolute URI. 
177     * <br> If, when used, the base URI is itself a relative URI, an empty 
178     * string, or null, the behavior is implementation dependent. 
179     */
180    public void setBaseURI(String baseURI);
181
182    /**
183     *  The character encoding, if known. The encoding must be a string 
184     * acceptable for an XML encoding declaration ([<a href='http://www.w3.org/TR/2004/REC-xml-20040204'>XML 1.0</a>] section 
185     * 4.3.3 "Character Encoding in Entities"). 
186     * <br> This attribute has no effect when the application provides a 
187     * character stream or string data. For other sources of input, an 
188     * encoding specified by means of this attribute will override any 
189     * encoding specified in the XML declaration or the Text declaration, or 
190     * 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     */
192    public String getEncoding();
193    /**
194     *  The character encoding, if known. The encoding must be a string 
195     * acceptable for an XML encoding declaration ([<a href='http://www.w3.org/TR/2004/REC-xml-20040204'>XML 1.0</a>] section 
196     * 4.3.3 "Character Encoding in Entities"). 
197     * <br> This attribute has no effect when the application provides a 
198     * character stream or string data. For other sources of input, an 
199     * encoding specified by means of this attribute will override any 
200     * encoding specified in the XML declaration or the Text declaration, or 
201     * an encoding obtained from a higher level protocol, such as HTTP [<a href='http://www.ietf.org/rfc/rfc2616.txt'>IETF RFC 2616</a>]. 
202     */
203    public void setEncoding(String encoding);
204
205    /**
206     *  If set to true, assume that the input is certified (see section 2.13 
207     * in [<a href='http://www.w3.org/TR/2004/REC-xml11-20040204/'>XML 1.1</a>]) when 
208     * parsing [<a href='http://www.w3.org/TR/2004/REC-xml11-20040204/'>XML 1.1</a>]. 
209     */
210    public boolean getCertifiedText();
211    /**
212     *  If set to true, assume that the input is certified (see section 2.13 
213     * in [<a href='http://www.w3.org/TR/2004/REC-xml11-20040204/'>XML 1.1</a>]) when 
214     * parsing [<a href='http://www.w3.org/TR/2004/REC-xml11-20040204/'>XML 1.1</a>]. 
215     */
216    public void setCertifiedText(boolean certifiedText);
217
218}