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.JsonGeneratorgetWriter()Get the writer associated with the writing context.voidwrite(IAssemblyClassBinding targetDefinition, Object targetObject)Writes data in a bound object to JSON.voidwriteDefinitionValue(IClassBinding targetDefinition, Object targetObject, Map<String,? extends IBoundNamedInstance> instances)Write the data described by the providedtargetDefinitionas a JSON value.protected voidwriteFieldValueInstanceValue(IBoundFieldValueInstance targetInstance, Object parentObject)Write the instance data contained in theparentObjectbased on the structure described by thetargetInstance.protected voidwriteFlagInstanceValue(IBoundFlagInstance targetInstance, Object parentObject)Write the instance data contained in theparentObjectbased on the structure described by thetargetInstance.protected voidwriteInstance(IBoundNamedInstance targetInstance, Object parentObject)Write the instance data contained in theparentObjectbased on the structure described by thetargetInstance.protected voidwriteModelInstanceValues(IBoundNamedModelInstance targetInstance, Object parentObject)Write the instance data contained in theparentObjectbased 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:IWritingContextGet the writer associated with the writing context.- Specified by:
getWriterin 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:IJsonWritingContextWrite the data described by the providedtargetDefinitionas a JSON value.- Specified by:
writeDefinitionValuein 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 theparentObjectbased 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 theparentObjectbased 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 theparentObjectbased 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 theparentObjectbased 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
-
-