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.XMLStreamWriter2getWriter()Get the writer associated with the writing context.voidwrite(IAssemblyClassBinding targetDefinition, Object targetObject)Writes data in a bound object to XML.voidwriteDefinitionValue(IClassBinding targetDefinition, Object targetObject, QName parentName)Write the data described by the providedtargetDefinitionas an XML element.protected voidwriteFlagInstance(IBoundFlagInstance targetInstance, Object parentObject)Write the data described by the providedtargetInstanceas an XML attribute.voidwriteInstanceValue(IBoundNamedModelInstance targetInstance, Object targetObject, QName parentName)Write the data described by the providedtargetDefinitionas an XML element.protected booleanwriteModelInstanceValues(IBoundNamedModelInstance targetInstance, Object parentObject, QName parentName)Write the data described by the providedtargetInstanceas 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:IWritingContextGet the writer associated with the writing context.- Specified by:
getWriterin 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:IXmlWritingContextWrite the data described by the providedtargetDefinitionas an XML element.- Specified by:
writeDefinitionValuein 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 providedtargetInstanceas 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 providedtargetInstanceas 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:
trueid the value was written orfalseotherwise- 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:IXmlWritingContextWrite the data described by the providedtargetDefinitionas an XML element.- Specified by:
writeInstanceValuein 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
-
-