java.lang.Object
dev.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 dev.metaschema.databind.io.json.IJsonParsingContext
IJsonParsingContext.IInstanceReader -
Constructor Summary
ConstructorsConstructorDescriptionMetaschemaJsonReader(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.JsonParserThe parser used for reading data associated with the supported format.Get the URI-based resource read by this parser.dev.metaschema.core.model.IBoundObjectreadChoiceGroupItem(dev.metaschema.core.model.IBoundObject parentItem, IBoundInstanceModelChoiceGroup instance) Parse and return an item.dev.metaschema.core.model.IBoundObjectreadItemAssembly(dev.metaschema.core.model.IBoundObject parentItem, IBoundDefinitionModelAssembly definition) Parse and return an item.dev.metaschema.core.model.IBoundObjectreadItemAssembly(dev.metaschema.core.model.IBoundObject parentItem, IBoundInstanceModelAssembly instance) Parse and return an item.dev.metaschema.core.model.IBoundObjectreadItemAssembly(dev.metaschema.core.model.IBoundObject parentItem, IBoundInstanceModelGroupedAssembly instance) Parse and return an item.dev.metaschema.core.model.IBoundObjectreadItemField(dev.metaschema.core.model.IBoundObject parentItem, IBoundDefinitionModelFieldComplex definition) Parse and return an item.dev.metaschema.core.model.IBoundObjectreadItemField(dev.metaschema.core.model.IBoundObject parentItem, IBoundInstanceModelFieldComplex instance) Parse and return an item.readItemField(dev.metaschema.core.model.IBoundObject parentItem, IBoundInstanceModelFieldScalar instance) Parse and return an item.dev.metaschema.core.model.IBoundObjectreadItemField(dev.metaschema.core.model.IBoundObject parentItem, IBoundInstanceModelGroupedField instance) Parse and return an item.readItemFieldValue(dev.metaschema.core.model.IBoundObject parentItem, IBoundFieldValue fieldValue) Parse and return an item.readItemFlag(dev.metaschema.core.model.IBoundObject parentItem, IBoundInstanceFlag instance) Parse and return an item.<T> TreadObject(IBoundDefinitionModelComplex definition) Read a JSON object value based on the provided definition.<T> TreadObjectRoot(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:IParsingContextThe parser used for reading data associated with the supported format.The caller does not own this reader and must not close it.
- Specified by:
getReaderin interfaceIParsingContext<com.fasterxml.jackson.core.JsonParser,IJsonProblemHandler> - Returns:
- the parser
-
getSource
Description copied from interface:IParsingContextGet the URI-based resource read by this parser.- Specified by:
getSourcein interfaceIParsingContext<com.fasterxml.jackson.core.JsonParser,IJsonProblemHandler> - Returns:
- the resource URI
-
getProblemHandler
Description copied from interface:IParsingContextA handler that provides callbacks used to resolve parsing issues.- Specified by:
getProblemHandlerin 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
public Object readItemFlag(dev.metaschema.core.model.IBoundObject parentItem, IBoundInstanceFlag instance) throws IOException Description copied from interface:IItemReadHandlerParse and return an item.- Specified by:
readItemFlagin 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(dev.metaschema.core.model.IBoundObject parentItem, IBoundInstanceModelFieldScalar instance) throws IOException Description copied from interface:IItemReadHandlerParse and return an item.- Specified by:
readItemFieldin 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 dev.metaschema.core.model.IBoundObject readItemField(dev.metaschema.core.model.IBoundObject parentItem, IBoundInstanceModelFieldComplex instance) throws IOException Description copied from interface:IItemReadHandlerParse and return an item.- Specified by:
readItemFieldin 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 dev.metaschema.core.model.IBoundObject readItemField(dev.metaschema.core.model.IBoundObject parentItem, IBoundInstanceModelGroupedField instance) throws IOException Description copied from interface:IItemReadHandlerParse and return an item.- Specified by:
readItemFieldin 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 dev.metaschema.core.model.IBoundObject readItemField(dev.metaschema.core.model.IBoundObject parentItem, IBoundDefinitionModelFieldComplex definition) throws IOException Description copied from interface:IItemReadHandlerParse and return an item.- Specified by:
readItemFieldin interfaceIItemReadHandler- Parameters:
parentItem- the parent Java object to use for serialization callbacks, ornullif 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(dev.metaschema.core.model.IBoundObject parentItem, IBoundFieldValue fieldValue) throws IOException Description copied from interface:IItemReadHandlerParse and return an item.- Specified by:
readItemFieldValuein 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 dev.metaschema.core.model.IBoundObject readItemAssembly(dev.metaschema.core.model.IBoundObject parentItem, IBoundInstanceModelAssembly instance) throws IOException Description copied from interface:IItemReadHandlerParse and return an item.- Specified by:
readItemAssemblyin 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 dev.metaschema.core.model.IBoundObject readItemAssembly(dev.metaschema.core.model.IBoundObject parentItem, IBoundInstanceModelGroupedAssembly instance) throws IOException Description copied from interface:IItemReadHandlerParse and return an item.- Specified by:
readItemAssemblyin 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 dev.metaschema.core.model.IBoundObject readItemAssembly(dev.metaschema.core.model.IBoundObject parentItem, IBoundDefinitionModelAssembly definition) throws IOException Description copied from interface:IItemReadHandlerParse and return an item.- Specified by:
readItemAssemblyin interfaceIItemReadHandler- Parameters:
parentItem- the parent Java object to use for serialization callbacks, ornullif 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 dev.metaschema.core.model.IBoundObject readChoiceGroupItem(dev.metaschema.core.model.IBoundObject parentItem, IBoundInstanceModelChoiceGroup instance) throws IOException Description copied from interface:IItemReadHandlerParse and return an item.- Specified by:
readChoiceGroupItemin 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
-