Package javanet.staxutils.io
Class StAXStreamWriter
java.lang.Object
javanet.staxutils.io.StAXStreamWriter
- All Implemented Interfaces:
XMLStreamWriter
An
XMLStreamWriter implementation that writes to a character stream.- Version:
- $Revision: 1.1 $
- Author:
- Christian Niles
-
Constructor Summary
ConstructorsConstructorDescriptionStAXStreamWriter(OutputStream stream) Constructs aStAXStreamWriterthat writes to the providedOutputStreamusing the platform default encoding.StAXStreamWriter(OutputStream stream, String encoding) Constructs aStAXStreamWriterthat writes to the providedOutputStreamusing the specified encoding.StAXStreamWriter(Writer writer) Constructs aStAXStreamWriterthat writes to the providedWriter.StAXStreamWriter(Writer writer, NamespaceContext rootContext) Constructs aStAXStreamWriterthat writes to the providedWriter. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()protected voidCloses the currentElementContext, writing any cached content and making it read-only.voidflush()Returns the current position of the writer as a path ofQNamestrings.getProperty(String name) voidvoidsetNamespaceContext(NamespaceContext context) voidvoidwriteAttribute(String localName, String value) voidwriteAttribute(String namespaceURI, String localName, String value) voidwriteAttribute(String prefix, String namespaceURI, String localName, String value) voidwriteAttribute(QName name, String value) voidwriteCData(String data) voidwriteCharacters(char[] text, int start, int len) voidwriteCharacters(String text) voidwriteComment(String data) voidwriteDefaultNamespace(String namespaceURI) voidvoidwriteEmptyElement(String localName) voidwriteEmptyElement(String namespaceURI, String localName) voidwriteEmptyElement(String prefix, String localName, String namespaceURI) voidvoidvoidwriteEntityRef(String name) voidwriteNamespace(String prefix, String namespaceURI) voidwriteProcessingInstruction(String target) voidwriteProcessingInstruction(String target, String data) voidvoidwriteStartDocument(String version) voidwriteStartDocument(String encoding, String version) voidwriteStartElement(String localName) voidwriteStartElement(String namespaceURI, String localName) voidwriteStartElement(String prefix, String localName, String namespaceURI) voidwriteStartElement(String prefix, String localName, String namespaceURI, boolean isEmpty) Core start tag output method called by all otherwriteXXXElementmethods.
-
Constructor Details
-
StAXStreamWriter
Constructs aStAXStreamWriterthat writes to the providedOutputStreamusing the platform default encoding.- Parameters:
stream- The destination stream.
-
StAXStreamWriter
Constructs aStAXStreamWriterthat writes to the providedOutputStreamusing the specified encoding.- Parameters:
stream- The destination stream.encoding- The output encoding.- Throws:
UnsupportedEncodingException- If the encoding isn't supported.
-
StAXStreamWriter
Constructs aStAXStreamWriterthat writes to the providedWriter.- Parameters:
writer- The destinationWriterinstance.
-
StAXStreamWriter
Constructs aStAXStreamWriterthat writes to the providedWriter.- Parameters:
writer- The destinationWriterinstance.rootContext- The root namespace context.
-
-
Method Details
-
close
- Specified by:
closein interfaceXMLStreamWriter- Throws:
XMLStreamException
-
flush
- Specified by:
flushin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
getPrefix
- Specified by:
getPrefixin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
getProperty
- Specified by:
getPropertyin interfaceXMLStreamWriter- Throws:
IllegalArgumentException
-
writeStartDocument
- Specified by:
writeStartDocumentin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeStartDocument
- Specified by:
writeStartDocumentin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeStartDocument
- Specified by:
writeStartDocumentin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeEndDocument
- Specified by:
writeEndDocumentin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeCData
- Specified by:
writeCDatain interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeCharacters
- Specified by:
writeCharactersin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeCharacters
- Specified by:
writeCharactersin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeComment
- Specified by:
writeCommentin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeDTD
- Specified by:
writeDTDin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeEntityRef
- Specified by:
writeEntityRefin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeProcessingInstruction
- Specified by:
writeProcessingInstructionin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeProcessingInstruction
- Specified by:
writeProcessingInstructionin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
getNamespaceContext
- Specified by:
getNamespaceContextin interfaceXMLStreamWriter
-
setNamespaceContext
- Specified by:
setNamespaceContextin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
setDefaultNamespace
- Specified by:
setDefaultNamespacein interfaceXMLStreamWriter- Throws:
XMLStreamException
-
setPrefix
- Specified by:
setPrefixin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeStartElement
public void writeStartElement(String prefix, String localName, String namespaceURI, boolean isEmpty) throws XMLStreamException Core start tag output method called by all otherwriteXXXElementmethods.- Parameters:
prefix- The tag prefix.localName- The tag local name.namespaceURI- The namespace URI of the prefix.isEmpty- Whether the tag is empty.- Throws:
XMLStreamException- If an error occurs writing the tag to the stream.
-
writeStartElement
public void writeStartElement(String prefix, String localName, String namespaceURI) throws XMLStreamException - Specified by:
writeStartElementin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeStartElement
- Specified by:
writeStartElementin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeStartElement
- Specified by:
writeStartElementin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeEmptyElement
public void writeEmptyElement(String prefix, String localName, String namespaceURI) throws XMLStreamException - Specified by:
writeEmptyElementin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeEmptyElement
- Specified by:
writeEmptyElementin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeEmptyElement
- Specified by:
writeEmptyElementin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeAttribute
- Throws:
XMLStreamException
-
writeAttribute
public void writeAttribute(String prefix, String namespaceURI, String localName, String value) throws XMLStreamException - Specified by:
writeAttributein interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeAttribute
public void writeAttribute(String namespaceURI, String localName, String value) throws XMLStreamException - Specified by:
writeAttributein interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeAttribute
- Specified by:
writeAttributein interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeDefaultNamespace
- Specified by:
writeDefaultNamespacein interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeNamespace
- Specified by:
writeNamespacein interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeEndElement
- Specified by:
writeEndElementin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
getCurrentPath
Returns the current position of the writer as a path ofQNamestrings.- Returns:
- The current position of the writer.
-
closeElementContext
Closes the currentElementContext, writing any cached content and making it read-only. If the current context is empty, it will be popped and replaced with its parent context. If no context is open, this method has no effects.- Throws:
XMLStreamException- If an error occurs flushing any element content.
-