Class MetaschemaJsonReader

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.
  • 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 with
      source - 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 with
      source - the resource being parsed
      problemHandler - the problem handler implementation to use
      Throws:
      IOException - if an error occurred while reading the JSON
  • Method Details

    • getReader

      @NotOwning public com.fasterxml.jackson.core.JsonParser getReader()
      Description copied from interface: IParsingContext
      The parser used for reading data associated with the supported format.

      The caller does not own this reader and must not close it.

      Specified by:
      getReader in interface IParsingContext<com.fasterxml.jackson.core.JsonParser,IJsonProblemHandler>
      Returns:
      the parser
    • getSource

      public URI getSource()
      Description copied from interface: IParsingContext
      Get the URI-based resource read by this parser.
      Specified by:
      getSource in interface IParsingContext<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 interface IParsingContext<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 parse
      expectedFieldName - 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: IItemReadHandler
      Parse and return an item.
      Specified by:
      readItemFlag in interface IItemReadHandler
      Parameters:
      parentItem - the parent Java object to use for serialization callbacks
      instance - 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: IItemReadHandler
      Parse and return an item.
      Specified by:
      readItemField in interface IItemReadHandler
      Parameters:
      parentItem - the parent Java object to use for serialization callbacks
      instance - 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: IItemReadHandler
      Parse and return an item.
      Specified by:
      readItemField in interface IItemReadHandler
      Parameters:
      parentItem - the parent Java object to use for serialization callbacks
      instance - 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: IItemReadHandler
      Parse and return an item.
      Specified by:
      readItemField in interface IItemReadHandler
      Parameters:
      parentItem - the parent Java object to use for serialization callbacks
      instance - 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: IItemReadHandler
      Parse and return an item.
      Specified by:
      readItemField in interface IItemReadHandler
      Parameters:
      parentItem - the parent Java object to use for serialization callbacks, or null if there is no parent
      definition - 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: IItemReadHandler
      Parse and return an item.
      Specified by:
      readItemFieldValue in interface IItemReadHandler
      Parameters:
      parentItem - the parent Java object to use for serialization callbacks
      fieldValue - 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: IItemReadHandler
      Parse and return an item.
      Specified by:
      readItemAssembly in interface IItemReadHandler
      Parameters:
      parentItem - the parent Java object to use for serialization callbacks
      instance - 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: IItemReadHandler
      Parse and return an item.
      Specified by:
      readItemAssembly in interface IItemReadHandler
      Parameters:
      parentItem - the parent Java object to use for serialization callbacks
      instance - 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: IItemReadHandler
      Parse and return an item.
      Specified by:
      readItemAssembly in interface IItemReadHandler
      Parameters:
      parentItem - the parent Java object to use for serialization callbacks, or null if there is no parent
      definition - 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: IItemReadHandler
      Parse and return an item.
      Specified by:
      readChoiceGroupItem in interface IItemReadHandler
      Parameters:
      parentItem - the parent Java object to use for serialization callbacks
      instance - the choice group instance
      Returns:
      the Java object representing the parsed item
      Throws:
      IOException - if an error occurred while parsing