Class MetaschemaJsonWriter
- java.lang.Object
-
- gov.nist.secauto.metaschema.databind.io.json.MetaschemaJsonWriter
-
- All Implemented Interfaces:
IWritingContext<com.fasterxml.jackson.core.JsonGenerator>
,IJsonWritingContext
public class MetaschemaJsonWriter extends Object implements IJsonWritingContext
-
-
Constructor Summary
Constructors Constructor Description MetaschemaJsonWriter(com.fasterxml.jackson.core.JsonGenerator generator)
Construct a new Module-aware JSON writer.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description com.fasterxml.jackson.core.JsonGenerator
getWriter()
Get the writer associated with the writing context.void
write(IAssemblyClassBinding targetDefinition, Object targetObject)
Writes data in a bound object to JSON.void
writeDefinitionValue(IClassBinding targetDefinition, Object targetObject, Map<String,? extends IBoundNamedInstance> instances)
Write the data described by the providedtargetDefinition
as a JSON value.protected void
writeFieldValueInstanceValue(IBoundFieldValueInstance targetInstance, Object parentObject)
Write the instance data contained in theparentObject
based on the structure described by thetargetInstance
.protected void
writeFlagInstanceValue(IBoundFlagInstance targetInstance, Object parentObject)
Write the instance data contained in theparentObject
based on the structure described by thetargetInstance
.protected void
writeInstance(IBoundNamedInstance targetInstance, Object parentObject)
Write the instance data contained in theparentObject
based on the structure described by thetargetInstance
.protected void
writeModelInstanceValues(IBoundNamedModelInstance targetInstance, Object parentObject)
Write the instance data contained in theparentObject
based on the structure described by thetargetInstance
.
-
-
-
Constructor Detail
-
MetaschemaJsonWriter
public MetaschemaJsonWriter(@NonNull com.fasterxml.jackson.core.JsonGenerator generator)
Construct a new Module-aware JSON writer.- Parameters:
generator
- the JSON generator to write with- See Also:
DefaultJsonProblemHandler
-
-
Method Detail
-
getWriter
public com.fasterxml.jackson.core.JsonGenerator getWriter()
Description copied from interface:IWritingContext
Get the writer associated with the writing context.- Specified by:
getWriter
in interfaceIWritingContext<com.fasterxml.jackson.core.JsonGenerator>
- Returns:
- the writer
-
write
public void write(@NonNull IAssemblyClassBinding targetDefinition, @NonNull Object targetObject) throws IOException
Writes data in a bound object to JSON. 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:
IOException
- if an error occurred while reading the JSON
-
writeDefinitionValue
public void writeDefinitionValue(IClassBinding targetDefinition, Object targetObject, Map<String,? extends IBoundNamedInstance> instances) throws IOException
Description copied from interface:IJsonWritingContext
Write the data described by the providedtargetDefinition
as a JSON value.- Specified by:
writeDefinitionValue
in interfaceIJsonWritingContext
- Parameters:
targetDefinition
- the bound Module definition describing the structure of the JSON data to writetargetObject
- the Java object data to writeinstances
- the set of named instances to write- Throws:
IOException
- if an error occurred while writing the JSON
-
writeInstance
protected void writeInstance(@NonNull IBoundNamedInstance targetInstance, @NonNull Object parentObject) throws IOException
Write the instance data contained in theparentObject
based on the structure described by thetargetInstance
.- Parameters:
targetInstance
- the instance to write data forparentObject
- the Java object containing the instance data to write- Throws:
IOException
- if an error occurred while writing the data
-
writeFlagInstanceValue
protected void writeFlagInstanceValue(@NonNull IBoundFlagInstance targetInstance, @NonNull Object parentObject) throws IOException
Write the instance data contained in theparentObject
based on the structure described by thetargetInstance
.- Parameters:
targetInstance
- the instance to write data forparentObject
- the Java object containing the instance data to write- Throws:
IOException
- if an error occurred while writing the data
-
writeModelInstanceValues
protected void writeModelInstanceValues(@NonNull IBoundNamedModelInstance targetInstance, @NonNull Object parentObject) throws IOException
Write the instance data contained in theparentObject
based on the structure described by thetargetInstance
.- Parameters:
targetInstance
- the instance to write data forparentObject
- the Java object containing the instance data to write- Throws:
IOException
- if an error occurred while writing the data
-
writeFieldValueInstanceValue
protected void writeFieldValueInstanceValue(@NonNull IBoundFieldValueInstance targetInstance, @NonNull Object parentObject) throws IOException
Write the instance data contained in theparentObject
based on the structure described by thetargetInstance
.- Parameters:
targetInstance
- the instance to write data forparentObject
- the Java object containing the instance data to write- Throws:
IOException
- if an error occurred while writing the data
-
-