Class MetaschemaJsonReader
java.lang.Object
gov.nist.secauto.metaschema.databind.io.json.MetaschemaJsonReader
- All Implemented Interfaces:
IParsingContext<com.fasterxml.jackson.core.JsonParser,
,IJsonProblemHandler> IJsonParsingContext
,IItemReadHandler
Supports reading JSON-based Metaschema module instances.
-
Nested Class Summary
Nested classes/interfaces inherited from interface gov.nist.secauto.metaschema.databind.io.json.IJsonParsingContext
IJsonParsingContext.IInstanceReader
-
Constructor Summary
ConstructorDescriptionMetaschemaJsonReader
(com.fasterxml.jackson.core.JsonParser parser, URI source) Construct a new Module-aware JSON parser using the default problem handler.MetaschemaJsonReader
(com.fasterxml.jackson.core.JsonParser parser, URI source, IJsonProblemHandler problemHandler) Construct a new Module-aware JSON parser. -
Method Summary
Modifier and TypeMethodDescriptionA handler that provides callbacks used to resolve parsing issues.com.fasterxml.jackson.core.JsonParser
The parser used for reading data associated with the supported format.Get the URI-based resource read by this parser.readChoiceGroupItem
(IBoundObject parentItem, IBoundInstanceModelChoiceGroup instance) Parse and return an item.readItemAssembly
(IBoundObject parentItem, IBoundDefinitionModelAssembly definition) Parse and return an item.readItemAssembly
(IBoundObject parentItem, IBoundInstanceModelAssembly instance) Parse and return an item.readItemAssembly
(IBoundObject parentItem, IBoundInstanceModelGroupedAssembly instance) Parse and return an item.readItemField
(IBoundObject parentItem, IBoundDefinitionModelFieldComplex definition) Parse and return an item.readItemField
(IBoundObject parentItem, IBoundInstanceModelFieldComplex instance) Parse and return an item.readItemField
(IBoundObject parentItem, IBoundInstanceModelFieldScalar instance) Parse and return an item.readItemField
(IBoundObject parentItem, IBoundInstanceModelGroupedField instance) Parse and return an item.readItemFieldValue
(IBoundObject parentItem, IBoundFieldValue fieldValue) Parse and return an item.readItemFlag
(IBoundObject parentItem, IBoundInstanceFlag instance) Parse and return an item.<T> T
readObject
(IBoundDefinitionModelComplex definition) Read a JSON object value based on the provided definition.<T> T
readObjectRoot
(IBoundDefinitionModelComplex definition, String expectedFieldName) Read a JSON property based on the provided definition.
-
Constructor Details
-
MetaschemaJsonReader
public MetaschemaJsonReader(@NonNull com.fasterxml.jackson.core.JsonParser parser, @NonNull URI source) throws IOException Construct a new Module-aware JSON parser using the default problem handler.- Parameters:
parser
- the JSON parser to parse withsource
- the resource being parsed- Throws:
IOException
- if an error occurred while reading the JSON- See Also:
-
MetaschemaJsonReader
public MetaschemaJsonReader(@NonNull com.fasterxml.jackson.core.JsonParser parser, @NonNull URI source, @NonNull IJsonProblemHandler problemHandler) throws IOException Construct a new Module-aware JSON parser.- Parameters:
parser
- the JSON parser to parse withsource
- the resource being parsedproblemHandler
- the problem handler implementation to use- Throws:
IOException
- if an error occurred while reading the JSON
-
-
Method Details
-
getReader
Description copied from interface:IParsingContext
The parser used for reading data associated with the supported format.- Specified by:
getReader
in interfaceIParsingContext<com.fasterxml.jackson.core.JsonParser,
IJsonProblemHandler> - Returns:
- the parser
-
getSource
Description copied from interface:IParsingContext
Get the URI-based resource read by this parser.- Specified by:
getSource
in interfaceIParsingContext<com.fasterxml.jackson.core.JsonParser,
IJsonProblemHandler> - Returns:
- the resource URI
-
getProblemHandler
Description copied from interface:IParsingContext
A handler that provides callbacks used to resolve parsing issues.- Specified by:
getProblemHandler
in interfaceIParsingContext<com.fasterxml.jackson.core.JsonParser,
IJsonProblemHandler> - Returns:
- the configured handler
-
readObject
@NonNull public <T> T readObject(@NonNull IBoundDefinitionModelComplex definition) throws IOException Read a JSON object value based on the provided definition.- Type Parameters:
T
- the Java type of the bound object produced by this parser- Parameters:
definition
- the Metaschema module definition that describes the node to parse- Returns:
- the resulting parsed bound object
- Throws:
IOException
- if an error occurred while parsing the content
-
readObjectRoot
@NonNull public <T> T readObjectRoot(@NonNull IBoundDefinitionModelComplex definition, @NonNull String expectedFieldName) throws IOException Read a JSON property based on the provided definition.- Type Parameters:
T
- the Java type of the bound object produced by this parser- Parameters:
definition
- the Metaschema module definition that describes the node to parseexpectedFieldName
- the name of the JSON field to parse- Returns:
- the resulting parsed bound object
- Throws:
IOException
- if an error occurred while parsing the content
-
readItemFlag
Description copied from interface:IItemReadHandler
Parse and return an item.- Specified by:
readItemFlag
in interfaceIItemReadHandler
- Parameters:
parentItem
- the parent Java object to use for serialization callbacksinstance
- the flag instance- Returns:
- the Java object representing the parsed item
- Throws:
IOException
- if an error occurred while parsing
-
readItemField
public Object readItemField(IBoundObject parentItem, IBoundInstanceModelFieldScalar instance) throws IOException Description copied from interface:IItemReadHandler
Parse and return an item.- Specified by:
readItemField
in interfaceIItemReadHandler
- Parameters:
parentItem
- the parent Java object to use for serialization callbacksinstance
- the field instance- Returns:
- the Java object representing the parsed item
- Throws:
IOException
- if an error occurred while parsing
-
readItemField
public IBoundObject readItemField(IBoundObject parentItem, IBoundInstanceModelFieldComplex instance) throws IOException Description copied from interface:IItemReadHandler
Parse and return an item.- Specified by:
readItemField
in interfaceIItemReadHandler
- Parameters:
parentItem
- the parent Java object to use for serialization callbacksinstance
- the field instance- Returns:
- the Java object representing the parsed item
- Throws:
IOException
- if an error occurred while parsing
-
readItemField
public IBoundObject readItemField(IBoundObject parentItem, IBoundInstanceModelGroupedField instance) throws IOException Description copied from interface:IItemReadHandler
Parse and return an item.- Specified by:
readItemField
in interfaceIItemReadHandler
- Parameters:
parentItem
- the parent Java object to use for serialization callbacksinstance
- the field instance- Returns:
- the Java object representing the parsed item
- Throws:
IOException
- if an error occurred while parsing
-
readItemField
public IBoundObject readItemField(IBoundObject parentItem, IBoundDefinitionModelFieldComplex definition) throws IOException Description copied from interface:IItemReadHandler
Parse and return an item.- Specified by:
readItemField
in interfaceIItemReadHandler
- Parameters:
parentItem
- the parent Java object to use for serialization callbacks, ornull
if there is no parentdefinition
- the field instance- Returns:
- the Java object representing the parsed item
- Throws:
IOException
- if an error occurred while parsing
-
readItemFieldValue
public Object readItemFieldValue(IBoundObject parentItem, IBoundFieldValue fieldValue) throws IOException Description copied from interface:IItemReadHandler
Parse and return an item.- Specified by:
readItemFieldValue
in interfaceIItemReadHandler
- Parameters:
parentItem
- the parent Java object to use for serialization callbacksfieldValue
- the field value instance- Returns:
- the Java object representing the parsed item
- Throws:
IOException
- if an error occurred while parsing
-
readItemAssembly
public IBoundObject readItemAssembly(IBoundObject parentItem, IBoundInstanceModelAssembly instance) throws IOException Description copied from interface:IItemReadHandler
Parse and return an item.- Specified by:
readItemAssembly
in interfaceIItemReadHandler
- Parameters:
parentItem
- the parent Java object to use for serialization callbacksinstance
- the assembly instance- Returns:
- the Java object representing the parsed item
- Throws:
IOException
- if an error occurred while parsing
-
readItemAssembly
public IBoundObject readItemAssembly(IBoundObject parentItem, IBoundInstanceModelGroupedAssembly instance) throws IOException Description copied from interface:IItemReadHandler
Parse and return an item.- Specified by:
readItemAssembly
in interfaceIItemReadHandler
- Parameters:
parentItem
- the parent Java object to use for serialization callbacksinstance
- the assembly instance- Returns:
- the Java object representing the parsed item
- Throws:
IOException
- if an error occurred while parsing
-
readItemAssembly
public IBoundObject readItemAssembly(IBoundObject parentItem, IBoundDefinitionModelAssembly definition) throws IOException Description copied from interface:IItemReadHandler
Parse and return an item.- Specified by:
readItemAssembly
in interfaceIItemReadHandler
- Parameters:
parentItem
- the parent Java object to use for serialization callbacks, ornull
if there is no parentdefinition
- the assembly instance- Returns:
- the Java object representing the parsed item
- Throws:
IOException
- if an error occurred while parsing
-
readChoiceGroupItem
public IBoundObject readChoiceGroupItem(IBoundObject parentItem, IBoundInstanceModelChoiceGroup instance) throws IOException Description copied from interface:IItemReadHandler
Parse and return an item.- Specified by:
readChoiceGroupItem
in interfaceIItemReadHandler
- Parameters:
parentItem
- the parent Java object to use for serialization callbacksinstance
- the choice group instance- Returns:
- the Java object representing the parsed item
- Throws:
IOException
- if an error occurred while parsing
-