1. /*
  2. * Copyright (c) 2004 World Wide Web Consortium,
  3. *
  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.
  9. *
  10. * [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231
  11. */
  12. package org.w3c.dom.ls;
  13. /**
  14. * This interface represents an input source for data.
  15. * <p> This interface allows an application to encapsulate information about
  16. * an input source in a single object, which may include a public
  17. * identifier, a system identifier, a byte stream (possibly with a specified
  18. * encoding), a base URI, and/or a character stream.
  19. * <p> The exact definitions of a byte stream and a character stream are
  20. * binding dependent.
  21. * <p> The application is expected to provide objects that implement this
  22. * interface whenever such objects are needed. The application can either
  23. * provide its own objects that implement this interface, or it can use the
  24. * generic factory method <code>DOMImplementationLS.createLSInput()</code>
  25. * to create objects that implement this interface.
  26. * <p> The <code>LSParser</code> will use the <code>LSInput</code> object to
  27. * determine how to read data. The <code>LSParser</code> will look at the
  28. * different inputs specified in the <code>LSInput</code> in the following
  29. * order to know which one to read from, the first one that is not null and
  30. * not an empty string will be used:
  31. * <ol>
  32. * <li> <code>LSInput.characterStream</code>
  33. * </li>
  34. * <li>
  35. * <code>LSInput.byteStream</code>
  36. * </li>
  37. * <li> <code>LSInput.stringData</code>
  38. * </li>
  39. * <li>
  40. * <code>LSInput.systemId</code>
  41. * </li>
  42. * <li> <code>LSInput.publicId</code>
  43. * </li>
  44. * </ol>
  45. * <p> If all inputs are null, the <code>LSParser</code> will report a
  46. * <code>DOMError</code> with its <code>DOMError.type</code> set to
  47. * <code>"no-input-specified"</code> and its <code>DOMError.severity</code>
  48. * set to <code>DOMError.SEVERITY_FATAL_ERROR</code>.
  49. * <p> <code>LSInput</code> objects belong to the application. The DOM
  50. * implementation will never modify them (though it may make copies and
  51. * modify the copies, if necessary).
  52. * <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
  53. and Save Specification</a>.
  54. */
  55. public interface LSInput {
  56. /**
  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]). It is not a requirement to have an XML declaration when
  60. * using character streams. If an XML declaration is present, the value
  61. * of the encoding attribute will be ignored.
  62. */
  63. public java.io.Reader getCharacterStream();
  64. /**
  65. * An attribute of a language and binding dependent type that represents
  66. * a stream of 16-bit units. The application must encode the stream
  67. * using UTF-16 (defined in [Unicode] and in [ISO/IEC 10646]). It is not a requirement to have an XML declaration when
  68. * using character streams. If an XML declaration is present, the value
  69. * of the encoding attribute will be ignored.
  70. */
  71. public void setCharacterStream(java.io.Reader characterStream);
  72. /**
  73. * An attribute of a language and binding dependent type that represents
  74. * a stream of bytes.
  75. * <br> If the application knows the character encoding of the byte
  76. * stream, it should set the encoding attribute. Setting the encoding in
  77. * this way will override any encoding specified in an XML declaration
  78. * in the data.
  79. */
  80. public java.io.InputStream getByteStream();
  81. /**
  82. * An attribute of a language and binding dependent type that represents
  83. * a stream of bytes.
  84. * <br> If the application knows the character encoding of the byte
  85. * stream, it should set the encoding attribute. Setting the encoding in
  86. * this way will override any encoding specified in an XML declaration
  87. * in the data.
  88. */
  89. public void setByteStream(java.io.InputStream byteStream);
  90. /**
  91. * String data to parse. If provided, this will always be treated as a
  92. * sequence of 16-bit units (UTF-16 encoded characters). It is not a
  93. * requirement to have an XML declaration when using
  94. * <code>stringData</code>. If an XML declaration is present, the value
  95. * of the encoding attribute will be ignored.
  96. */
  97. public String getStringData();
  98. /**
  99. * String data to parse. If provided, this will always be treated as a
  100. * sequence of 16-bit units (UTF-16 encoded characters). It is not a
  101. * requirement to have an XML declaration when using
  102. * <code>stringData</code>. If an XML declaration is present, the value
  103. * of the encoding attribute will be ignored.
  104. */
  105. public void setStringData(String stringData);
  106. /**
  107. * The system identifier, a URI reference [<a href='http://www.ietf.org/rfc/rfc2396.txt'>IETF RFC 2396</a>], for this
  108. * input source. The system identifier is optional if there is a byte
  109. * stream, a character stream, or string data. It is still useful to
  110. * provide one, since the application will use it to resolve any
  111. * relative URIs and can include it in error messages and warnings. (The
  112. * LSParser will only attempt to fetch the resource identified by the
  113. * URI reference if there is no other input available in the input
  114. * source.)
  115. * <br> If the application knows the character encoding of the object
  116. * pointed to by the system identifier, it can set the encoding using
  117. * the <code>encoding</code> attribute.
  118. * <br> If the specified system ID is a relative URI reference (see
  119. * section 5 in [<a href='http://www.ietf.org/rfc/rfc2396.txt'>IETF RFC 2396</a>]), the DOM
  120. * implementation will attempt to resolve the relative URI with the
  121. * <code>baseURI</code> as the base, if that fails, the behavior is
  122. * implementation dependent.
  123. */
  124. public String getSystemId();
  125. /**
  126. * The system identifier, a URI reference [<a href='http://www.ietf.org/rfc/rfc2396.txt'>IETF RFC 2396</a>], for this
  127. * input source. The system identifier is optional if there is a byte
  128. * stream, a character stream, or string data. It is still useful to
  129. * provide one, since the application will use it to resolve any
  130. * relative URIs and can include it in error messages and warnings. (The
  131. * LSParser will only attempt to fetch the resource identified by the
  132. * URI reference if there is no other input available in the input
  133. * source.)
  134. * <br> If the application knows the character encoding of the object
  135. * pointed to by the system identifier, it can set the encoding using
  136. * the <code>encoding</code> attribute.
  137. * <br> If the specified system ID is a relative URI reference (see
  138. * section 5 in [<a href='http://www.ietf.org/rfc/rfc2396.txt'>IETF RFC 2396</a>]), the DOM
  139. * implementation will attempt to resolve the relative URI with the
  140. * <code>baseURI</code> as the base, if that fails, the behavior is
  141. * implementation dependent.
  142. */
  143. public void setSystemId(String systemId);
  144. /**
  145. * The public identifier for this input source. This may be mapped to an
  146. * input source using an implementation dependent mechanism (such as
  147. * catalogues or other mappings). The public identifier, if specified,
  148. * may also be reported as part of the location information when errors
  149. * are reported.
  150. */
  151. public String getPublicId();
  152. /**
  153. * The public identifier for this input source. This may be mapped to an
  154. * input source using an implementation dependent mechanism (such as
  155. * catalogues or other mappings). The public identifier, if specified,
  156. * may also be reported as part of the location information when errors
  157. * are reported.
  158. */
  159. public void setPublicId(String publicId);
  160. /**
  161. * 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
  162. * resolving a relative <code>systemId</code> to an absolute URI.
  163. * <br> If, when used, the base URI is itself a relative URI, an empty
  164. * string, or null, the behavior is implementation dependent.
  165. */
  166. public String getBaseURI();
  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 void setBaseURI(String baseURI);
  174. /**
  175. * The character encoding, if known. The encoding must be a string
  176. * acceptable for an XML encoding declaration ([<a href='http://www.w3.org/TR/2004/REC-xml-20040204'>XML 1.0</a>] section
  177. * 4.3.3 "Character Encoding in Entities").
  178. * <br> This attribute has no effect when the application provides a
  179. * character stream or string data. For other sources of input, an
  180. * encoding specified by means of this attribute will override any
  181. * encoding specified in the XML declaration or the Text declaration, or
  182. * an encoding obtained from a higher level protocol, such as HTTP [<a href='http://www.ietf.org/rfc/rfc2616.txt'>IETF RFC 2616</a>].
  183. */
  184. public String getEncoding();
  185. /**
  186. * The character encoding, if known. The encoding must be a string
  187. * acceptable for an XML encoding declaration ([<a href='http://www.w3.org/TR/2004/REC-xml-20040204'>XML 1.0</a>] section
  188. * 4.3.3 "Character Encoding in Entities").
  189. * <br> This attribute has no effect when the application provides a
  190. * character stream or string data. For other sources of input, an
  191. * encoding specified by means of this attribute will override any
  192. * encoding specified in the XML declaration or the Text declaration, or
  193. * an encoding obtained from a higher level protocol, such as HTTP [<a href='http://www.ietf.org/rfc/rfc2616.txt'>IETF RFC 2616</a>].
  194. */
  195. public void setEncoding(String encoding);
  196. /**
  197. * If set to true, assume that the input is certified (see section 2.13
  198. * in [<a href='http://www.w3.org/TR/2004/REC-xml11-20040204/'>XML 1.1</a>]) when
  199. * parsing [<a href='http://www.w3.org/TR/2004/REC-xml11-20040204/'>XML 1.1</a>].
  200. */
  201. public boolean getCertifiedText();
  202. /**
  203. * If set to true, assume that the input is certified (see section 2.13
  204. * in [<a href='http://www.w3.org/TR/2004/REC-xml11-20040204/'>XML 1.1</a>]) when
  205. * parsing [<a href='http://www.w3.org/TR/2004/REC-xml11-20040204/'>XML 1.1</a>].
  206. */
  207. public void setCertifiedText(boolean certifiedText);
  208. }