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
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidadd(XMLEventReader reader) protected abstract voidaddAnnotationElement(XMLEventWriter writer) Add the annotation element.protected StringGet 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:
addin interfaceXMLEventConsumer- Specified by:
addin interfaceXMLEventWriter- Overrides:
addin classEventWriterDelegate- Throws:
XMLStreamException
-
add
- Specified by:
addin interfaceXMLEventWriter- Overrides:
addin 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()theStartElementfor the annotation element, followed by any nested content, and then lastly theEndElementfor the annotation element.- Parameters:
writer- output to which the annotation element should be written- Throws:
XMLStreamException- if an XML error occurs
-