Class MetaschemaXmlWriter
- java.lang.Object
-
- gov.nist.secauto.metaschema.databind.io.xml.MetaschemaXmlWriter
-
- All Implemented Interfaces:
IWritingContext<org.codehaus.stax2.XMLStreamWriter2>
,IXmlWritingContext
public class MetaschemaXmlWriter extends Object implements IXmlWritingContext
-
-
Constructor Summary
Constructors Constructor Description MetaschemaXmlWriter(org.codehaus.stax2.XMLStreamWriter2 writer)
Construct a new Module-aware JSON writer.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.codehaus.stax2.XMLStreamWriter2
getWriter()
Get the writer associated with the writing context.void
write(IAssemblyClassBinding targetDefinition, Object targetObject)
Writes data in a bound object to XML.void
writeDefinitionValue(IClassBinding targetDefinition, Object targetObject, QName parentName)
Write the data described by the providedtargetDefinition
as an XML element.protected void
writeFlagInstance(IBoundFlagInstance targetInstance, Object parentObject)
Write the data described by the providedtargetInstance
as an XML attribute.void
writeInstanceValue(IBoundNamedModelInstance targetInstance, Object targetObject, QName parentName)
Write the data described by the providedtargetDefinition
as an XML element.protected boolean
writeModelInstanceValues(IBoundNamedModelInstance targetInstance, Object parentObject, QName parentName)
Write the data described by the providedtargetInstance
as an XML element.
-
-
-
Constructor Detail
-
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:
DefaultJsonProblemHandler
-
-
Method Detail
-
getWriter
public org.codehaus.stax2.XMLStreamWriter2 getWriter()
Description copied from interface:IWritingContext
Get the writer associated with the writing context.- Specified by:
getWriter
in interfaceIWritingContext<org.codehaus.stax2.XMLStreamWriter2>
- Returns:
- the writer
-
write
public void write(@NonNull IAssemblyClassBinding targetDefinition, @NonNull Object targetObject) throws XMLStreamException, IOException
Writes data in a bound object to XML. This assembly must be a root assembly for which a call toIAssemblyDefinition.isRoot()
will returntrue
.- Parameters:
targetDefinition
- the definition describing the root element data to writetargetObject
- the bound object- Throws:
XMLStreamException
- if an error occurred while parsing into XMLIOException
- if an error occurred while writing the output
-
writeDefinitionValue
public void writeDefinitionValue(@NonNull IClassBinding targetDefinition, @NonNull Object targetObject, @NonNull QName parentName) throws IOException
Description copied from interface:IXmlWritingContext
Write the data described by the providedtargetDefinition
as an XML element.- Specified by:
writeDefinitionValue
in interfaceIXmlWritingContext
- Parameters:
targetDefinition
- the bound Module definition describing the structure of the XML data to writetargetObject
- the Java object data to writeparentName
- the qualified name of the XML element to write- Throws:
IOException
- if an error occurred while writing the XML
-
writeFlagInstance
protected void writeFlagInstance(@NonNull IBoundFlagInstance targetInstance, @NonNull Object parentObject) throws IOException
Write the data described by the providedtargetInstance
as an XML attribute.- Parameters:
targetInstance
- the model instance that describes the syntax of the data to writeparentObject
- the Java object that data written by this method is stored in- Throws:
IOException
- if an error occurred while writing the XML
-
writeModelInstanceValues
protected boolean writeModelInstanceValues(@NonNull IBoundNamedModelInstance targetInstance, @NonNull Object parentObject, @NonNull QName parentName) throws IOException
Write the data described by the providedtargetInstance
as an XML element.- Parameters:
targetInstance
- the model instance that describes the syntax of the data to writeparentObject
- the Java object that data written by this method is stored inparentName
- the qualified name of the XML data's parent element- Returns:
true
id the value was written orfalse
otherwise- Throws:
IOException
- if an error occurred while writing the XML
-
writeInstanceValue
public void writeInstanceValue(@NonNull IBoundNamedModelInstance targetInstance, @NonNull Object targetObject, @NonNull QName parentName) throws IOException
Description copied from interface:IXmlWritingContext
Write the data described by the providedtargetDefinition
as an XML element.- Specified by:
writeInstanceValue
in interfaceIXmlWritingContext
- Parameters:
targetInstance
- the model instance that describes the syntax of the data to writetargetObject
- the Java object data to writeparentName
- the qualified name of the XML element to write- Throws:
IOException
- if an error occurred while writing the XML
-
-