Interface StaxWriter<N>
- All Known Implementing Classes:
StaxWriterImpl
public interface StaxWriter<N>
- Version:
- $Revision$
- Author:
- Nick Scavelli
-
Method Summary
Modifier and TypeMethodDescriptionvoidfinish()Calling finish will flush and close the underlying stream.writeAttribute(String name, String value) Writes an attribute for an xml element.writeAttribute(QName name, String value) Writes an attribute for an xml element.writeCData(String cdata) Writes a cdata sectionwriteComment(String comment) Writes an xml commentwriteContent(String content) Writes xml content.<V> StaxWriter<N> writeContent(WritableValueType<V> valueType, V content) Writes xml content based on the ValueType responsible for converting the content to string.Writes the default namespace<V> StaxWriter<N> writeElement(N element, String content) Convenience method for callingwriteStartElement,writeContent,writeEndElement<V> StaxWriter<N> writeElement(N element, WritableValueType<V> valueType, V content) Convenience method for callingwriteStartElement,writeContent,writeEndElementWrites an end tag for the previously started element.writeNamespace(String prefix, String uri) Writes the namespace.writeStartElement(N element) Writes the start tag of an xml element.
-
Method Details
-
writeStartElement
Writes the start tag of an xml element. Requires that an element has been started first.- Parameters:
element- element to start- Returns:
- StaxWriter
- Throws:
org.staxnav.StaxNavException- if an exception occurs
-
writeAttribute
Writes an attribute for an xml element. Requires that an element has been started first.- Parameters:
name- the name of the attributevalue- the value of the attribute- Returns:
- StaxWriter
- Throws:
org.staxnav.StaxNavException- if an exception occurs
-
writeAttribute
Writes an attribute for an xml element. Requires that an element has been started first.- Parameters:
name- QName object representing the name of the attributevalue- the value of the attribute- Returns:
- StaxWriter
- Throws:
org.staxnav.StaxNavException- if an exception occurs
-
writeContent
Writes xml content. Requires an xml element has been started first.- Parameters:
content- content to be written- Returns:
- StaxWriter
- Throws:
org.staxnav.StaxNavException- if an exception occurs
-
writeContent
<V> StaxWriter<N> writeContent(WritableValueType<V> valueType, V content) throws org.staxnav.StaxNavException Writes xml content based on the ValueType responsible for converting the content to string. Requires an xml element has been started first.- Parameters:
valueType- object responsible for writing content to stringcontent- content to be written- Returns:
- StaxWriter
- Throws:
org.staxnav.StaxNavException- if an exception occurs
-
writeEndElement
Writes an end tag for the previously started element. Requires that an element has been started first.- Returns:
- StaxWriter
- Throws:
org.staxnav.StaxNavException- if an exception occurs
-
writeElement
Convenience method for callingwriteStartElement,writeContent,writeEndElement- Parameters:
element- element to writecontent- content to be written- Returns:
- StaxWriter
- Throws:
org.staxnav.StaxNavException- if an exception occurs
-
writeElement
<V> StaxWriter<N> writeElement(N element, WritableValueType<V> valueType, V content) throws org.staxnav.StaxNavException Convenience method for callingwriteStartElement,writeContent,writeEndElement- Parameters:
element- element to writevalueType- object responsible for writing content to stringcontent- content to be written- Returns:
- StaxWriter
- Throws:
org.staxnav.StaxNavException- if an exception occurs
-
writeNamespace
Writes the namespace. If prefix is an empty string, "xmlns", or null this will delegate to writeDefaultNamespace- Parameters:
prefix- the prefix to bind the namespace touri- the uri to bind the prefix to- Returns:
- StaxWriter
- Throws:
org.staxnav.StaxNavException- if an exception occurs
-
writeDefaultNamespace
Writes the default namespace- Parameters:
uri- the uri to bind the default namespace to- Returns:
- StaxWriter
- Throws:
org.staxnav.StaxNavException- if an exception occurs
-
writeComment
Writes an xml comment- Parameters:
comment- the comment to write- Returns:
- StaxWriter
- Throws:
org.staxnav.StaxNavException- if an exception occurs
-
writeCData
Writes a cdata section- Parameters:
cdata- content of the cdata- Returns:
- StaxWriter
- Throws:
org.staxnav.StaxNavException- if an exception occurs
-
finish
void finish() throws org.staxnav.StaxNavExceptionCalling finish will flush and close the underlying stream. It will also call any endElements for you if they were never explicitly called.- Throws:
org.staxnav.StaxNavException- if an exception occurs
-