001 /* XMLStreamWriter.java --
002 Copyright (C) 2005 Free Software Foundation, Inc.
003
004 This file is part of GNU Classpath.
005
006 GNU Classpath is free software; you can redistribute it and/or modify
007 it under the terms of the GNU General Public License as published by
008 the Free Software Foundation; either version 2, or (at your option)
009 any later version.
010
011 GNU Classpath is distributed in the hope that it will be useful, but
012 WITHOUT ANY WARRANTY; without even the implied warranty of
013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014 General Public License for more details.
015
016 You should have received a copy of the GNU General Public License
017 along with GNU Classpath; see the file COPYING. If not, write to the
018 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
019 02110-1301 USA.
020
021 Linking this library statically or dynamically with other modules is
022 making a combined work based on this library. Thus, the terms and
023 conditions of the GNU General Public License cover the whole
024 combination.
025
026 As a special exception, the copyright holders of this library give you
027 permission to link this library with independent modules to produce an
028 executable, regardless of the license terms of these independent
029 modules, and to copy and distribute the resulting executable under
030 terms of your choice, provided that you also meet, for each linked
031 independent module, the terms and conditions of the license of that
032 module. An independent module is a module which is not derived from
033 or based on this library. If you modify this library, you may extend
034 this exception to your version of the library, but you are not
035 obligated to do so. If you do not wish to do so, delete this
036 exception statement from your version. */
037
038 package javax.xml.stream;
039
040 import javax.xml.namespace.NamespaceContext;
041
042 /**
043 * Interface for writing XML to a stream.
044 */
045 public interface XMLStreamWriter
046 {
047
048 /**
049 * Write the start of a tag.
050 */
051 void writeStartElement(String localName)
052 throws XMLStreamException;
053
054 /**
055 * Write the start of a tag.
056 */
057 void writeStartElement(String namespaceURI, String localName)
058 throws XMLStreamException;
059
060 /**
061 * Write the start of a tag.
062 */
063 void writeStartElement(String prefix, String localName, String namespaceURI)
064 throws XMLStreamException;
065
066 /**
067 * Write an empty tag.
068 */
069 void writeEmptyElement(String namespaceURI, String localName)
070 throws XMLStreamException;
071
072 /**
073 * Write an empty tag.
074 */
075 void writeEmptyElement(String prefix, String localName, String namespaceURI)
076 throws XMLStreamException;
077
078 /**
079 * Write an empty tag.
080 */
081 void writeEmptyElement(String localName)
082 throws XMLStreamException;
083
084 /**
085 * Closes the currently open tag.
086 */
087 void writeEndElement()
088 throws XMLStreamException;
089
090 /**
091 * Closes any currently open tags.
092 */
093 void writeEndDocument()
094 throws XMLStreamException;
095
096 /**
097 * Frees any resources used by this writer.
098 * This will not close the underlying output sink.
099 */
100 void close()
101 throws XMLStreamException;
102
103 /**
104 * Flushes any cached information to the underlying output sink.
105 */
106 void flush()
107 throws XMLStreamException;
108
109 /**
110 * Write an attribute.
111 */
112 void writeAttribute(String localName, String value)
113 throws XMLStreamException;
114
115 /**
116 * Write an attribute.
117 */
118 void writeAttribute(String prefix, String namespaceURI,
119 String localName, String value)
120 throws XMLStreamException;
121
122 /**
123 * Write an attribute.
124 */
125 void writeAttribute(String namespaceURI, String localName, String value)
126 throws XMLStreamException;
127
128 /**
129 * Write a namespace declaration.
130 */
131 void writeNamespace(String prefix, String namespaceURI)
132 throws XMLStreamException;
133
134 /**
135 * Write a default namespace declaration.
136 */
137 void writeDefaultNamespace(String namespaceURI)
138 throws XMLStreamException;
139
140 /**
141 * Write a comment.
142 */
143 void writeComment(String data)
144 throws XMLStreamException;
145
146 /**
147 * Write a processing instruction.
148 */
149 void writeProcessingInstruction(String target)
150 throws XMLStreamException;
151
152 /**
153 * Write a processing instruction.
154 */
155 void writeProcessingInstruction(String target, String data)
156 throws XMLStreamException;
157
158 /**
159 * Write a CDATA section.
160 */
161 void writeCData(String data)
162 throws XMLStreamException;
163
164 /**
165 * Write a DOCTYPE declaration.
166 */
167 void writeDTD(String dtd)
168 throws XMLStreamException;
169
170 /**
171 * Write an entity reference.
172 */
173 void writeEntityRef(String name)
174 throws XMLStreamException;
175
176 /**
177 * Write an XML declaration.
178 */
179 void writeStartDocument()
180 throws XMLStreamException;
181
182 /**
183 * Write an XML declaration with the specified XML version.
184 */
185 void writeStartDocument(String version)
186 throws XMLStreamException;
187
188 /**
189 * Write an XML declaration with the specifed XML version and encoding.
190 */
191 void writeStartDocument(String encoding, String version)
192 throws XMLStreamException;
193
194 /**
195 * Write the specified text.
196 */
197 void writeCharacters(String text)
198 throws XMLStreamException;
199
200 /**
201 * Write the specified text.
202 */
203 void writeCharacters(char[] text, int start, int len)
204 throws XMLStreamException;
205
206 /**
207 * Returns the prefix associated with the given namespace URI.
208 */
209 String getPrefix(String uri)
210 throws XMLStreamException;
211
212 /**
213 * Sets the prefix for the given namespace URI.
214 */
215 void setPrefix(String prefix, String uri)
216 throws XMLStreamException;
217
218 /**
219 * Sets the URI for the default namespace.
220 */
221 void setDefaultNamespace(String uri)
222 throws XMLStreamException;
223
224 /**
225 * Sets the namespace context for namespace resolution.
226 */
227 void setNamespaceContext(NamespaceContext context)
228 throws XMLStreamException;
229
230 /**
231 * Returns the current namespace context.
232 */
233 NamespaceContext getNamespaceContext();
234
235 /**
236 * Returns the implementation-specific feature or property of the given
237 * name.
238 * @exception IllegalArgumentException if the property is not supported
239 */
240 Object getProperty(String name)
241 throws IllegalArgumentException;
242
243 }