XMLStreamWriter.java 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. /* XMLStreamWriter.java --
  2. Copyright (C) 2005 Free Software Foundation, Inc.
  3. This file is part of GNU Classpath.
  4. GNU Classpath is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2, or (at your option)
  7. any later version.
  8. GNU Classpath is distributed in the hope that it will be useful, but
  9. WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with GNU Classpath; see the file COPYING. If not, write to the
  14. Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  15. 02110-1301 USA.
  16. Linking this library statically or dynamically with other modules is
  17. making a combined work based on this library. Thus, the terms and
  18. conditions of the GNU General Public License cover the whole
  19. combination.
  20. As a special exception, the copyright holders of this library give you
  21. permission to link this library with independent modules to produce an
  22. executable, regardless of the license terms of these independent
  23. modules, and to copy and distribute the resulting executable under
  24. terms of your choice, provided that you also meet, for each linked
  25. independent module, the terms and conditions of the license of that
  26. module. An independent module is a module which is not derived from
  27. or based on this library. If you modify this library, you may extend
  28. this exception to your version of the library, but you are not
  29. obligated to do so. If you do not wish to do so, delete this
  30. exception statement from your version. */
  31. package javax.xml.stream;
  32. import javax.xml.namespace.NamespaceContext;
  33. /**
  34. * Interface for writing XML to a stream.
  35. */
  36. public interface XMLStreamWriter
  37. {
  38. /**
  39. * Write the start of a tag.
  40. */
  41. void writeStartElement(String localName)
  42. throws XMLStreamException;
  43. /**
  44. * Write the start of a tag.
  45. */
  46. void writeStartElement(String namespaceURI, String localName)
  47. throws XMLStreamException;
  48. /**
  49. * Write the start of a tag.
  50. */
  51. void writeStartElement(String prefix, String localName, String namespaceURI)
  52. throws XMLStreamException;
  53. /**
  54. * Write an empty tag.
  55. */
  56. void writeEmptyElement(String namespaceURI, String localName)
  57. throws XMLStreamException;
  58. /**
  59. * Write an empty tag.
  60. */
  61. void writeEmptyElement(String prefix, String localName, String namespaceURI)
  62. throws XMLStreamException;
  63. /**
  64. * Write an empty tag.
  65. */
  66. void writeEmptyElement(String localName)
  67. throws XMLStreamException;
  68. /**
  69. * Closes the currently open tag.
  70. */
  71. void writeEndElement()
  72. throws XMLStreamException;
  73. /**
  74. * Closes any currently open tags.
  75. */
  76. void writeEndDocument()
  77. throws XMLStreamException;
  78. /**
  79. * Frees any resources used by this writer.
  80. * This will not close the underlying output sink.
  81. */
  82. void close()
  83. throws XMLStreamException;
  84. /**
  85. * Flushes any cached information to the underlying output sink.
  86. */
  87. void flush()
  88. throws XMLStreamException;
  89. /**
  90. * Write an attribute.
  91. */
  92. void writeAttribute(String localName, String value)
  93. throws XMLStreamException;
  94. /**
  95. * Write an attribute.
  96. */
  97. void writeAttribute(String prefix, String namespaceURI,
  98. String localName, String value)
  99. throws XMLStreamException;
  100. /**
  101. * Write an attribute.
  102. */
  103. void writeAttribute(String namespaceURI, String localName, String value)
  104. throws XMLStreamException;
  105. /**
  106. * Write a namespace declaration.
  107. */
  108. void writeNamespace(String prefix, String namespaceURI)
  109. throws XMLStreamException;
  110. /**
  111. * Write a default namespace declaration.
  112. */
  113. void writeDefaultNamespace(String namespaceURI)
  114. throws XMLStreamException;
  115. /**
  116. * Write a comment.
  117. */
  118. void writeComment(String data)
  119. throws XMLStreamException;
  120. /**
  121. * Write a processing instruction.
  122. */
  123. void writeProcessingInstruction(String target)
  124. throws XMLStreamException;
  125. /**
  126. * Write a processing instruction.
  127. */
  128. void writeProcessingInstruction(String target, String data)
  129. throws XMLStreamException;
  130. /**
  131. * Write a CDATA section.
  132. */
  133. void writeCData(String data)
  134. throws XMLStreamException;
  135. /**
  136. * Write a DOCTYPE declaration.
  137. */
  138. void writeDTD(String dtd)
  139. throws XMLStreamException;
  140. /**
  141. * Write an entity reference.
  142. */
  143. void writeEntityRef(String name)
  144. throws XMLStreamException;
  145. /**
  146. * Write an XML declaration.
  147. */
  148. void writeStartDocument()
  149. throws XMLStreamException;
  150. /**
  151. * Write an XML declaration with the specified XML version.
  152. */
  153. void writeStartDocument(String version)
  154. throws XMLStreamException;
  155. /**
  156. * Write an XML declaration with the specifed XML version and encoding.
  157. */
  158. void writeStartDocument(String encoding, String version)
  159. throws XMLStreamException;
  160. /**
  161. * Write the specified text.
  162. */
  163. void writeCharacters(String text)
  164. throws XMLStreamException;
  165. /**
  166. * Write the specified text.
  167. */
  168. void writeCharacters(char[] text, int start, int len)
  169. throws XMLStreamException;
  170. /**
  171. * Returns the prefix associated with the given namespace URI.
  172. */
  173. String getPrefix(String uri)
  174. throws XMLStreamException;
  175. /**
  176. * Sets the prefix for the given namespace URI.
  177. */
  178. void setPrefix(String prefix, String uri)
  179. throws XMLStreamException;
  180. /**
  181. * Sets the URI for the default namespace.
  182. */
  183. void setDefaultNamespace(String uri)
  184. throws XMLStreamException;
  185. /**
  186. * Sets the namespace context for namespace resolution.
  187. */
  188. void setNamespaceContext(NamespaceContext context)
  189. throws XMLStreamException;
  190. /**
  191. * Returns the current namespace context.
  192. */
  193. NamespaceContext getNamespaceContext();
  194. /**
  195. * Returns the implementation-specific feature or property of the given
  196. * name.
  197. * @exception IllegalArgumentException if the property is not supported
  198. */
  199. Object getProperty(String name)
  200. throws IllegalArgumentException;
  201. }