java.lang.Object
dev.metaschema.databind.io.xml.MetaschemaXmlWriter
- All Implemented Interfaces:
IWritingContext<org.codehaus.stax2.XMLStreamWriter2>,IXmlWritingContext
Provides support for writing Metaschema-bound Java objects to XML format.
This class implements the IXmlWritingContext interface to serialize
bound objects to XML using StAX's XMLStreamWriter2. It handles flags
as attributes and fields/assemblies as child elements according to the
Metaschema XML serialization rules.
- See Also:
-
IXmlWritingContextXMLStreamWriter2
-
Nested Class Summary
Nested classes/interfaces inherited from interface dev.metaschema.databind.io.IWritingContext
IWritingContext.ObjectWriter<T extends IFeatureComplexItemValueHandler> -
Constructor Summary
ConstructorsConstructorDescriptionMetaschemaXmlWriter(org.codehaus.stax2.XMLStreamWriter2 writer) Construct a new Module-aware JSON writer. -
Method Summary
Modifier and TypeMethodDescriptionorg.codehaus.stax2.XMLStreamWriter2Get the writer associated with the writing context.voidwrite(IBoundDefinitionModelComplex definition, IBoundObject item) Write the data described by the providedtargetObjectas an XML element.voidwriteRoot(IBoundDefinitionModelAssembly definition, IBoundObject item) Write the root element for the provided definition and bound object.
-
Constructor Details
-
MetaschemaXmlWriter
public MetaschemaXmlWriter(@NonNull org.codehaus.stax2.XMLStreamWriter2 writer) Construct a new Module-aware JSON writer.- Parameters:
writer- the XML stream writer to write with- See Also:
-
-
Method Details
-
getWriter
public org.codehaus.stax2.XMLStreamWriter2 getWriter()Description copied from interface:IWritingContextGet the writer associated with the writing context.- Specified by:
getWriterin interfaceIWritingContext<org.codehaus.stax2.XMLStreamWriter2>- Returns:
- the writer
-
write
public void write(@NonNull IBoundDefinitionModelComplex definition, @NonNull IBoundObject item) throws IOException Description copied from interface:IWritingContextWrite the data described by the providedtargetObjectas an XML element.- Specified by:
writein interfaceIWritingContext<org.codehaus.stax2.XMLStreamWriter2>- Parameters:
definition- the bound Module definition describing the data to writeitem- the Java object data to write- Throws:
IOException- if an error occurred while writing
-
writeRoot
public void writeRoot(@NonNull IBoundDefinitionModelAssembly definition, @NonNull IBoundObject item) throws IOException Description copied from interface:IXmlWritingContextWrite the root element for the provided definition and bound object.- Specified by:
writeRootin interfaceIXmlWritingContext- Parameters:
definition- the assembly definition describing the root elementitem- the bound object to serialize as the root element- Throws:
IOException- if an error occurs during writing
-