Package com.helger.xml.serialize.write
Class AbstractXMLSerializer<NODETYPE>
- java.lang.Object
-
- com.helger.xml.serialize.write.AbstractXMLSerializer<NODETYPE>
-
- Type Parameters:
NODETYPE- The DOM node type to use
- Direct Known Subclasses:
MicroSerializer,XMLSerializer
public abstract class AbstractXMLSerializer<NODETYPE> extends Object
Abstract XML serializer implementation that works with IMicroNode and org.w3c.dom.Node objects.- Author:
- Philip Helger
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classAbstractXMLSerializer.NamespaceLevelContains the XML namespace definitions for a single element.protected static classAbstractXMLSerializer.NamespaceStackContains the hierarchy of XML namespaces within a document structure.
-
Field Summary
Fields Modifier and Type Field Description static StringDEFAULT_NAMESPACE_PREFIX_PREFIXThe prefix to be used for created namespace prefixes :) (e.g. for "ns0" or "ns1")protected StringBuilderm_aIndenthelper variable: current indentation.protected AbstractXMLSerializer.NamespaceStackm_aNSStackCurrent stack of namespaces.protected IXMLWriterSettingsm_aSettingsThe serialization settings
-
Constructor Summary
Constructors Constructor Description AbstractXMLSerializer(IXMLWriterSettings aSettings)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected XMLEmittercreateXMLEmitter(Writer aWriter, IXMLWriterSettings aSettings)protected abstract voidemitNode(XMLEmitter aXMLWriter, NODETYPE aParentNode, NODETYPE aPrevSibling, NODETYPE aNode, NODETYPE aNextSibling)IXMLWriterSettingsgetSettings()protected voidhandlePutNamespaceContextPrefixInRoot(Map<QName,String> aAttrMap)This method handles the case, if all namespace context entries should be emitted on the root element.StringtoString()voidwrite(NODETYPE aNode, XMLEmitter aXMLEmitter)voidwrite(NODETYPE aNode, OutputStream aOS)Write the specified node to the specifiedOutputStream.voidwrite(NODETYPE aNode, Writer aWriter)Write the specified node to the specifiedWriter.
-
-
-
Field Detail
-
DEFAULT_NAMESPACE_PREFIX_PREFIX
public static final String DEFAULT_NAMESPACE_PREFIX_PREFIX
The prefix to be used for created namespace prefixes :) (e.g. for "ns0" or "ns1")- See Also:
- Constant Field Values
-
m_aSettings
protected final IXMLWriterSettings m_aSettings
The serialization settings
-
m_aIndent
protected final StringBuilder m_aIndent
helper variable: current indentation.
-
m_aNSStack
protected final AbstractXMLSerializer.NamespaceStack m_aNSStack
Current stack of namespaces.
-
-
Constructor Detail
-
AbstractXMLSerializer
public AbstractXMLSerializer(@Nonnull IXMLWriterSettings aSettings)
-
-
Method Detail
-
getSettings
@Nonnull public final IXMLWriterSettings getSettings()
-
handlePutNamespaceContextPrefixInRoot
protected final void handlePutNamespaceContextPrefixInRoot(@Nonnull Map<QName,String> aAttrMap)
This method handles the case, if all namespace context entries should be emitted on the root element.- Parameters:
aAttrMap- the attribute map to be filled. May not benull.
-
emitNode
protected abstract void emitNode(@Nonnull XMLEmitter aXMLWriter, @Nullable NODETYPE aParentNode, @Nullable NODETYPE aPrevSibling, @Nonnull NODETYPE aNode, @Nullable NODETYPE aNextSibling)
-
createXMLEmitter
@Nonnull @OverrideOnDemand protected XMLEmitter createXMLEmitter(@Nonnull @WillNotClose Writer aWriter, @Nonnull IXMLWriterSettings aSettings)
-
write
public final void write(@Nonnull NODETYPE aNode, @Nonnull XMLEmitter aXMLEmitter)
-
write
public final void write(@Nonnull NODETYPE aNode, @Nonnull @WillNotClose OutputStream aOS)
Write the specified node to the specifiedOutputStream.- Parameters:
aNode- The node to write. May not benull.aOS- The stream to serialize onto. May not benull.
-
write
public final void write(@Nonnull NODETYPE aNode, @Nonnull @WillNotClose Writer aWriter)
Write the specified node to the specifiedWriter.- Parameters:
aNode- The node to write. May not benull.aWriter- The writer to serialize onto. May not benull.
-
-