Class StaxWriterImpl<N>
java.lang.Object
org.gatein.common.xml.stax.writer.StaxWriterImpl<N>
- All Implemented Interfaces:
XMLStreamConstants,StaxWriter<N>
-
Field Summary
Fields inherited from interface javax.xml.stream.XMLStreamConstants
ATTRIBUTE, CDATA, CHARACTERS, COMMENT, DTD, END_DOCUMENT, END_ELEMENT, ENTITY_DECLARATION, ENTITY_REFERENCE, NAMESPACE, NOTATION_DECLARATION, PROCESSING_INSTRUCTION, SPACE, START_DOCUMENT, START_ELEMENT -
Constructor Summary
ConstructorsConstructorDescriptionStaxWriterImpl(org.staxnav.Naming<N> naming, XMLStreamWriter writer) StaxWriterImpl(org.staxnav.Naming<N> naming, XMLStreamWriter writer, XmlStreamingFormatter formatter) StaxWriterImpl(org.staxnav.Naming<N> naming, XMLStreamWriter writer, XmlStreamingFormatter formatter, String encoding, String version) -
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.
-
Constructor Details
-
Method Details
-
writeAttribute
Description copied from interface:StaxWriterWrites an attribute for an xml element. Requires that an element has been started first.- Specified by:
writeAttributein interfaceStaxWriter<N>- Parameters:
name- the name of the attributevalue- the value of the attribute- Returns:
- StaxWriter
-
writeAttribute
Description copied from interface:StaxWriterWrites an attribute for an xml element. Requires that an element has been started first.- Specified by:
writeAttributein interfaceStaxWriter<N>- Parameters:
name- QName object representing the name of the attributevalue- the value of the attribute- Returns:
- StaxWriter
-
writeStartElement
Description copied from interface:StaxWriterWrites the start tag of an xml element. Requires that an element has been started first.- Specified by:
writeStartElementin interfaceStaxWriter<N>- Parameters:
element- element to start- Returns:
- StaxWriter
- Throws:
org.staxnav.StaxNavException- if an exception occurs
-
writeEndElement
Description copied from interface:StaxWriterWrites an end tag for the previously started element. Requires that an element has been started first.- Specified by:
writeEndElementin interfaceStaxWriter<N>- Returns:
- StaxWriter
- Throws:
org.staxnav.StaxNavException- if an exception occurs
-
writeContent
Description copied from interface:StaxWriterWrites xml content. Requires an xml element has been started first.- Specified by:
writeContentin interfaceStaxWriter<N>- Parameters:
content- content to be written- Returns:
- StaxWriter
- Throws:
org.staxnav.StaxNavException- if an exception occurs
-
writeContent
public <V> StaxWriter<N> writeContent(WritableValueType<V> valueType, V content) throws org.staxnav.StaxNavException Description copied from interface:StaxWriterWrites xml content based on the ValueType responsible for converting the content to string. Requires an xml element has been started first.- Specified by:
writeContentin interfaceStaxWriter<N>- Parameters:
valueType- object responsible for writing content to stringcontent- content to be written- Returns:
- StaxWriter
- Throws:
org.staxnav.StaxNavException- if an exception occurs
-
writeElement
public <V> StaxWriter<N> writeElement(N element, String content) throws org.staxnav.StaxNavException Description copied from interface:StaxWriterConvenience method for callingwriteStartElement,writeContent,writeEndElement- Specified by:
writeElementin interfaceStaxWriter<N>- Parameters:
element- element to writecontent- content to be written- Returns:
- StaxWriter
- Throws:
org.staxnav.StaxNavException- if an exception occurs
-
writeElement
public <V> StaxWriter<N> writeElement(N element, WritableValueType<V> valueType, V content) throws org.staxnav.StaxNavException Description copied from interface:StaxWriterConvenience method for callingwriteStartElement,writeContent,writeEndElement- Specified by:
writeElementin interfaceStaxWriter<N>- 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
Description copied from interface:StaxWriterWrites the namespace. If prefix is an empty string, "xmlns", or null this will delegate to writeDefaultNamespace- Specified by:
writeNamespacein interfaceStaxWriter<N>- 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
Description copied from interface:StaxWriterWrites the default namespace- Specified by:
writeDefaultNamespacein interfaceStaxWriter<N>- Parameters:
uri- the uri to bind the default namespace to- Returns:
- StaxWriter
- Throws:
org.staxnav.StaxNavException- if an exception occurs
-
writeComment
Description copied from interface:StaxWriterWrites an xml comment- Specified by:
writeCommentin interfaceStaxWriter<N>- Parameters:
comment- the comment to write- Returns:
- StaxWriter
- Throws:
org.staxnav.StaxNavException- if an exception occurs
-
writeCData
Description copied from interface:StaxWriterWrites a cdata section- Specified by:
writeCDatain interfaceStaxWriter<N>- Parameters:
cdata- content of the cdata- Returns:
- StaxWriter
- Throws:
org.staxnav.StaxNavException- if an exception occurs
-
finish
public void finish() throws org.staxnav.StaxNavExceptionDescription copied from interface:StaxWriterCalling finish will flush and close the underlying stream. It will also call any endElements for you if they were never explicitly called.- Specified by:
finishin interfaceStaxWriter<N>- Throws:
org.staxnav.StaxNavException- if an exception occurs
-