Package org.dellroad.stuff.xml
Class AnnotatedXMLEventWriter
java.lang.Object
org.dellroad.stuff.xml.EventWriterDelegate
org.dellroad.stuff.xml.AnnotatedXMLEventWriter
- All Implemented Interfaces:
XMLEventConsumer
,XMLEventWriter
XMLEventWriter
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 AnnotatedXMLEventReader
to transparently annotate XML documents.
- See Also:
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
void
add
(XMLEventReader reader) protected abstract void
addAnnotationElement
(XMLEventWriter writer) Add the annotation element.protected String
Get the whitespace found between the opening document tag and the first non-space child.Methods inherited from class org.dellroad.stuff.xml.EventWriterDelegate
close, flush, getNamespaceContext, getParent, getPrefix, setDefaultNamespace, setNamespaceContext, setParent, setPrefix
-
Field Details
-
xmlEventFactory
-
-
Constructor Details
-
AnnotatedXMLEventWriter
-
-
Method Details
-
add
- Specified by:
add
in interfaceXMLEventConsumer
- Specified by:
add
in interfaceXMLEventWriter
- Overrides:
add
in classEventWriterDelegate
- Throws:
XMLStreamException
-
add
- Specified by:
add
in interfaceXMLEventWriter
- Overrides:
add
in classEventWriterDelegate
- Throws:
XMLStreamException
-
getTrailingSpace
Get the whitespace found between the opening document tag and the first non-space child.- Returns:
- initial whitespace
-
addAnnotationElement
Add the annotation element.This method should
add()
theStartElement
for the annotation element, followed by any nested content, and then lastly theEndElement
for the annotation element.- Parameters:
writer
- output to which the annotation element should be written- Throws:
XMLStreamException
- if an XML error occurs
-