public class StAXStreamWriter
extends java.lang.Object
implements javax.xml.stream.XMLStreamWriter
XMLStreamWriter
implementation that writes XML data to a new JDOM
Document
. The document can be retrieved using getDocument()
.
This class is the inverse of the class StAXStreamBuilder
in the sense that
this class is written to (it's an XMLStreamWriter implementation) to create a JDOM
Document whereas the StAXStreamBuilder reads from a user-supplied
XMLStreamReader. It is the difference between a 'push' concept and a 'pull' concept.
An interesting read for people using this class: Apache Axiom notes on setPrefix().
Constructor and Description |
---|
StAXStreamWriter()
Create a StAXStreamWriter with the default JDOMFactory for creating JDOM
Content.
|
StAXStreamWriter(JDOMFactory fac,
boolean repairnamespace)
Create a StAXStreamWriter with the specified JDOMFactory for creating
JDOM Content.
|
Modifier and Type | Method and Description |
---|---|
void |
close() |
void |
flush() |
Document |
getDocument()
Gets the
Document that was created by this writer. |
javax.xml.namespace.NamespaceContext |
getNamespaceContext() |
java.lang.String |
getPrefix(java.lang.String uri) |
java.lang.Object |
getProperty(java.lang.String name) |
void |
setDefaultNamespace(java.lang.String uri) |
void |
setNamespaceContext(javax.xml.namespace.NamespaceContext context) |
void |
setPrefix(java.lang.String prefix,
java.lang.String uri) |
void |
writeAttribute(java.lang.String localName,
java.lang.String value) |
void |
writeAttribute(java.lang.String namespaceURI,
java.lang.String localName,
java.lang.String value) |
void |
writeAttribute(java.lang.String prefix,
java.lang.String namespaceURI,
java.lang.String localName,
java.lang.String value) |
void |
writeCData(java.lang.String data) |
void |
writeCharacters(char[] chars,
int start,
int len) |
void |
writeCharacters(java.lang.String chars) |
void |
writeComment(java.lang.String data) |
void |
writeDefaultNamespace(java.lang.String namespaceURI) |
void |
writeDTD(java.lang.String dtd) |
void |
writeEmptyElement(java.lang.String localName) |
void |
writeEmptyElement(java.lang.String namespaceURI,
java.lang.String localName) |
void |
writeEmptyElement(java.lang.String prefix,
java.lang.String localName,
java.lang.String namespaceURI) |
void |
writeEndDocument() |
void |
writeEndElement() |
void |
writeEntityRef(java.lang.String name) |
void |
writeNamespace(java.lang.String prefix,
java.lang.String namespaceURI) |
void |
writeProcessingInstruction(java.lang.String target) |
void |
writeProcessingInstruction(java.lang.String target,
java.lang.String data) |
void |
writeStartDocument() |
void |
writeStartDocument(java.lang.String version) |
void |
writeStartDocument(java.lang.String encoding,
java.lang.String version) |
void |
writeStartElement(java.lang.String localName) |
void |
writeStartElement(java.lang.String namespaceURI,
java.lang.String localName) |
void |
writeStartElement(java.lang.String prefix,
java.lang.String localName,
java.lang.String namespaceURI) |
public StAXStreamWriter()
public StAXStreamWriter(JDOMFactory fac, boolean repairnamespace)
fac
- The JDOMFactory to use.repairnamespace
- If true, then repair namespace errors.public Document getDocument()
Document
that was created by this writer. Only available
after writeEndDocument()
has been called, and before the Writer
is closed.Document
public void writeStartDocument() throws javax.xml.stream.XMLStreamException
writeStartDocument
in interface javax.xml.stream.XMLStreamWriter
javax.xml.stream.XMLStreamException
public void writeStartDocument(java.lang.String version) throws javax.xml.stream.XMLStreamException
writeStartDocument
in interface javax.xml.stream.XMLStreamWriter
javax.xml.stream.XMLStreamException
public void writeStartDocument(java.lang.String encoding, java.lang.String version) throws javax.xml.stream.XMLStreamException
writeStartDocument
in interface javax.xml.stream.XMLStreamWriter
javax.xml.stream.XMLStreamException
public void setNamespaceContext(javax.xml.namespace.NamespaceContext context) throws javax.xml.stream.XMLStreamException
setNamespaceContext
in interface javax.xml.stream.XMLStreamWriter
javax.xml.stream.XMLStreamException
public java.lang.String getPrefix(java.lang.String uri) throws javax.xml.stream.XMLStreamException
getPrefix
in interface javax.xml.stream.XMLStreamWriter
javax.xml.stream.XMLStreamException
public void setPrefix(java.lang.String prefix, java.lang.String uri) throws javax.xml.stream.XMLStreamException
setPrefix
in interface javax.xml.stream.XMLStreamWriter
javax.xml.stream.XMLStreamException
public void setDefaultNamespace(java.lang.String uri) throws javax.xml.stream.XMLStreamException
setDefaultNamespace
in interface javax.xml.stream.XMLStreamWriter
javax.xml.stream.XMLStreamException
public void writeDTD(java.lang.String dtd) throws javax.xml.stream.XMLStreamException
writeDTD
in interface javax.xml.stream.XMLStreamWriter
javax.xml.stream.XMLStreamException
public void writeStartElement(java.lang.String localName) throws javax.xml.stream.XMLStreamException
writeStartElement
in interface javax.xml.stream.XMLStreamWriter
javax.xml.stream.XMLStreamException
public void writeStartElement(java.lang.String namespaceURI, java.lang.String localName) throws javax.xml.stream.XMLStreamException
writeStartElement
in interface javax.xml.stream.XMLStreamWriter
javax.xml.stream.XMLStreamException
public void writeStartElement(java.lang.String prefix, java.lang.String localName, java.lang.String namespaceURI) throws javax.xml.stream.XMLStreamException
writeStartElement
in interface javax.xml.stream.XMLStreamWriter
javax.xml.stream.XMLStreamException
public void writeEmptyElement(java.lang.String localName) throws javax.xml.stream.XMLStreamException
writeEmptyElement
in interface javax.xml.stream.XMLStreamWriter
javax.xml.stream.XMLStreamException
public void writeEmptyElement(java.lang.String namespaceURI, java.lang.String localName) throws javax.xml.stream.XMLStreamException
writeEmptyElement
in interface javax.xml.stream.XMLStreamWriter
javax.xml.stream.XMLStreamException
public void writeEmptyElement(java.lang.String prefix, java.lang.String localName, java.lang.String namespaceURI) throws javax.xml.stream.XMLStreamException
writeEmptyElement
in interface javax.xml.stream.XMLStreamWriter
javax.xml.stream.XMLStreamException
public void writeDefaultNamespace(java.lang.String namespaceURI) throws javax.xml.stream.XMLStreamException
writeDefaultNamespace
in interface javax.xml.stream.XMLStreamWriter
javax.xml.stream.XMLStreamException
public void writeNamespace(java.lang.String prefix, java.lang.String namespaceURI) throws javax.xml.stream.XMLStreamException
writeNamespace
in interface javax.xml.stream.XMLStreamWriter
javax.xml.stream.XMLStreamException
public void writeAttribute(java.lang.String localName, java.lang.String value) throws javax.xml.stream.XMLStreamException
writeAttribute
in interface javax.xml.stream.XMLStreamWriter
javax.xml.stream.XMLStreamException
public void writeAttribute(java.lang.String namespaceURI, java.lang.String localName, java.lang.String value) throws javax.xml.stream.XMLStreamException
writeAttribute
in interface javax.xml.stream.XMLStreamWriter
javax.xml.stream.XMLStreamException
public void writeAttribute(java.lang.String prefix, java.lang.String namespaceURI, java.lang.String localName, java.lang.String value) throws javax.xml.stream.XMLStreamException
writeAttribute
in interface javax.xml.stream.XMLStreamWriter
javax.xml.stream.XMLStreamException
public void writeComment(java.lang.String data) throws javax.xml.stream.XMLStreamException
writeComment
in interface javax.xml.stream.XMLStreamWriter
javax.xml.stream.XMLStreamException
public void writeProcessingInstruction(java.lang.String target) throws javax.xml.stream.XMLStreamException
writeProcessingInstruction
in interface javax.xml.stream.XMLStreamWriter
javax.xml.stream.XMLStreamException
public void writeProcessingInstruction(java.lang.String target, java.lang.String data) throws javax.xml.stream.XMLStreamException
writeProcessingInstruction
in interface javax.xml.stream.XMLStreamWriter
javax.xml.stream.XMLStreamException
public void writeCData(java.lang.String data) throws javax.xml.stream.XMLStreamException
writeCData
in interface javax.xml.stream.XMLStreamWriter
javax.xml.stream.XMLStreamException
public void writeEntityRef(java.lang.String name) throws javax.xml.stream.XMLStreamException
writeEntityRef
in interface javax.xml.stream.XMLStreamWriter
javax.xml.stream.XMLStreamException
public void writeCharacters(java.lang.String chars) throws javax.xml.stream.XMLStreamException
writeCharacters
in interface javax.xml.stream.XMLStreamWriter
javax.xml.stream.XMLStreamException
public void writeCharacters(char[] chars, int start, int len) throws javax.xml.stream.XMLStreamException
writeCharacters
in interface javax.xml.stream.XMLStreamWriter
javax.xml.stream.XMLStreamException
public void writeEndElement() throws javax.xml.stream.XMLStreamException
writeEndElement
in interface javax.xml.stream.XMLStreamWriter
javax.xml.stream.XMLStreamException
public void writeEndDocument() throws javax.xml.stream.XMLStreamException
writeEndDocument
in interface javax.xml.stream.XMLStreamWriter
javax.xml.stream.XMLStreamException
public void close() throws javax.xml.stream.XMLStreamException
close
in interface javax.xml.stream.XMLStreamWriter
javax.xml.stream.XMLStreamException
public void flush() throws javax.xml.stream.XMLStreamException
flush
in interface javax.xml.stream.XMLStreamWriter
javax.xml.stream.XMLStreamException
public javax.xml.namespace.NamespaceContext getNamespaceContext()
getNamespaceContext
in interface javax.xml.stream.XMLStreamWriter
public java.lang.Object getProperty(java.lang.String name) throws java.lang.IllegalArgumentException
getProperty
in interface javax.xml.stream.XMLStreamWriter
java.lang.IllegalArgumentException
Copyright © 2021 Jason Hunter, Brett McLaughlin. All Rights Reserved.