Package org.dellroad.stuff.xml
Class AnnotatedXMLStreamWriter
java.lang.Object
org.dellroad.stuff.xml.StreamWriterDelegate
org.dellroad.stuff.xml.AnnotatedXMLStreamWriter
- All Implemented Interfaces:
XMLStreamWriter
- Direct Known Subclasses:
UpdatesXMLStreamWriter
XMLStreamWriter
that adds an extra annotation element to an XML document as it is written.
The annotation element will be added as the first element inside the top-level document element.
This class can be used in combination with AnnotatedXMLStreamReader
to transparently annotate XML documents.
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected abstract void
addAnnotationElement
(XMLStreamWriter writer) Add the annotation element.protected String
Get the whitespace found between the opening document tag and the first non-space child.void
writeCData
(String data) void
writeCharacters
(char[] text, int start, int len) void
writeCharacters
(String text) void
writeComment
(String data) void
void
writeEmptyElement
(String localName) void
writeEmptyElement
(String namespaceURI, String localName) void
writeEmptyElement
(String prefix, String namespaceURI, String localName) void
void
void
writeEntityRef
(String name) void
writeProcessingInstruction
(String target) void
writeProcessingInstruction
(String target, String data) void
writeStartElement
(String localName) void
writeStartElement
(String namespaceURI, String localName) void
writeStartElement
(String prefix, String namespaceURI, String localName) Methods inherited from class org.dellroad.stuff.xml.StreamWriterDelegate
close, flush, getNamespaceContext, getParent, getPrefix, getProperty, setDefaultNamespace, setNamespaceContext, setParent, setPrefix, writeAttribute, writeAttribute, writeAttribute, writeDefaultNamespace, writeNamespace, writeStartDocument, writeStartDocument, writeStartDocument
-
Constructor Details
-
AnnotatedXMLStreamWriter
-
-
Method Details
-
writeStartElement
- Specified by:
writeStartElement
in interfaceXMLStreamWriter
- Overrides:
writeStartElement
in classStreamWriterDelegate
- Throws:
XMLStreamException
-
writeStartElement
- Specified by:
writeStartElement
in interfaceXMLStreamWriter
- Overrides:
writeStartElement
in classStreamWriterDelegate
- Throws:
XMLStreamException
-
writeStartElement
public void writeStartElement(String prefix, String namespaceURI, String localName) throws XMLStreamException - Specified by:
writeStartElement
in interfaceXMLStreamWriter
- Overrides:
writeStartElement
in classStreamWriterDelegate
- Throws:
XMLStreamException
-
writeEmptyElement
- Specified by:
writeEmptyElement
in interfaceXMLStreamWriter
- Overrides:
writeEmptyElement
in classStreamWriterDelegate
- Throws:
XMLStreamException
-
writeEmptyElement
public void writeEmptyElement(String prefix, String namespaceURI, String localName) throws XMLStreamException - Specified by:
writeEmptyElement
in interfaceXMLStreamWriter
- Overrides:
writeEmptyElement
in classStreamWriterDelegate
- Throws:
XMLStreamException
-
writeEmptyElement
- Specified by:
writeEmptyElement
in interfaceXMLStreamWriter
- Overrides:
writeEmptyElement
in classStreamWriterDelegate
- Throws:
XMLStreamException
-
writeComment
- Specified by:
writeComment
in interfaceXMLStreamWriter
- Overrides:
writeComment
in classStreamWriterDelegate
- Throws:
XMLStreamException
-
writeProcessingInstruction
- Specified by:
writeProcessingInstruction
in interfaceXMLStreamWriter
- Overrides:
writeProcessingInstruction
in classStreamWriterDelegate
- Throws:
XMLStreamException
-
writeProcessingInstruction
- Specified by:
writeProcessingInstruction
in interfaceXMLStreamWriter
- Overrides:
writeProcessingInstruction
in classStreamWriterDelegate
- Throws:
XMLStreamException
-
writeCData
- Specified by:
writeCData
in interfaceXMLStreamWriter
- Overrides:
writeCData
in classStreamWriterDelegate
- Throws:
XMLStreamException
-
writeDTD
- Specified by:
writeDTD
in interfaceXMLStreamWriter
- Overrides:
writeDTD
in classStreamWriterDelegate
- Throws:
XMLStreamException
-
writeEntityRef
- Specified by:
writeEntityRef
in interfaceXMLStreamWriter
- Overrides:
writeEntityRef
in classStreamWriterDelegate
- Throws:
XMLStreamException
-
writeCharacters
- Specified by:
writeCharacters
in interfaceXMLStreamWriter
- Overrides:
writeCharacters
in classStreamWriterDelegate
- Throws:
XMLStreamException
-
writeCharacters
- Specified by:
writeCharacters
in interfaceXMLStreamWriter
- Overrides:
writeCharacters
in classStreamWriterDelegate
- Throws:
XMLStreamException
-
writeEndDocument
- Specified by:
writeEndDocument
in interfaceXMLStreamWriter
- Overrides:
writeEndDocument
in classStreamWriterDelegate
- Throws:
XMLStreamException
-
writeEndElement
- Specified by:
writeEndElement
in interfaceXMLStreamWriter
- Overrides:
writeEndElement
in classStreamWriterDelegate
- Throws:
XMLStreamException
-
getTrailingSpace
Get the whitespace found between the opening document tag and the first non-space child.- Returns:
- whitespace after document tag
-
addAnnotationElement
Add the annotation element.This method should write the start element, followed by by any nested content, and then lastly the end element for the annotation element.
- Parameters:
writer
- output to which the annotation element should be written- Throws:
XMLStreamException
- if an XML error occurs
-