Interface IBoundLoader

All Superinterfaces:
dev.metaschema.core.configuration.IConfiguration<DeserializationFeature<?>>, dev.metaschema.core.metapath.IDocumentLoader, dev.metaschema.core.configuration.IMutableConfiguration<DeserializationFeature<?>>, dev.metaschema.core.model.IResourceResolver
All Known Implementing Classes:
DefaultBoundLoader

public interface IBoundLoader extends dev.metaschema.core.metapath.IDocumentLoader, dev.metaschema.core.configuration.IMutableConfiguration<DeserializationFeature<?>>
A common interface for loading Module based instance resources.
  • Method Summary

    Modifier and Type
    Method
    Description
    applyConfiguration(dev.metaschema.core.configuration.IConfiguration<DeserializationFeature<?>> other)
     
    default <CLASS extends dev.metaschema.core.model.IBoundObject>
    void
    convert(URI source, OutputStream os, Format toFormat, Class<CLASS> rootClass)
    Auto convert the provided source to the provided toFormat.
    default <CLASS extends dev.metaschema.core.model.IBoundObject>
    void
    convert(URI source, Writer writer, Format toFormat, Class<CLASS> rootClass)
    Auto convert the provided source to the provided toFormat.
    default <CLASS extends dev.metaschema.core.model.IBoundObject>
    void
    convert(URI source, Path destination, Format toFormat, Class<CLASS> rootClass)
    Auto convert the provided source to the provided toFormat.
    default <CLASS extends dev.metaschema.core.model.IBoundObject>
    void
    convert(Path source, OutputStream os, Format toFormat, Class<CLASS> rootClass)
    Auto convert the provided source to the provided toFormat.
    default <CLASS extends dev.metaschema.core.model.IBoundObject>
    void
    convert(Path source, Path destination, Format toFormat, Class<CLASS> rootClass)
    Auto convert the provided source to the provided toFormat.
    default Format
    Determine the format of the provided resource.
    detectFormat(InputStream is, URI resource)
    Determine the format of the provided resource.
    Determine the format of the resource identified by the provided uri.
    default Format
    Determine the format of the provided resource.
    default Format
    Determine the format of the provided resource.
    detectModel(InputStream is, URI resource, Format format)
    Determine the model of the provided resource.
    default IBoundLoader
     
    default IBoundLoader
     
    Get the configured Module binding context to use to load Java types.
    default <CLASS extends dev.metaschema.core.model.IBoundObject>
    CLASS
    load(File file)
    Load data from the provided resource into a bound object.
    <CLASS extends dev.metaschema.core.model.IBoundObject>
    CLASS
    load(InputStream is, URI resource)
    Load data from the provided resource into a bound object.
    <CLASS extends dev.metaschema.core.model.IBoundObject>
    CLASS
    load(Class<CLASS> clazz, Format format, InputStream is, URI resource)
    Load data from the specified resource into a bound object with the type of the specified Java class.
    default <CLASS extends dev.metaschema.core.model.IBoundObject>
    CLASS
    load(Class<CLASS> clazz, File file)
    Load data from the specified resource into a bound object with the type of the specified Java class.
    <CLASS extends dev.metaschema.core.model.IBoundObject>
    CLASS
    load(Class<CLASS> clazz, InputStream is, URI resource)
    Load data from the specified resource into a bound object with the type of the specified Java class.
    <CLASS extends dev.metaschema.core.model.IBoundObject>
    CLASS
    load(Class<CLASS> clazz, URI uri)
    Load data from the specified resource into a bound object with the type of the specified Java class.
    default <CLASS extends dev.metaschema.core.model.IBoundObject>
    CLASS
    load(Class<CLASS> clazz, URL url)
    Load data from the specified resource into a bound object with the type of the specified Java class.
    default <CLASS extends dev.metaschema.core.model.IBoundObject>
    CLASS
    load(Class<CLASS> clazz, Path path)
    Load data from the specified resource into a bound object with the type of the specified Java class.
    <CLASS extends dev.metaschema.core.model.IBoundObject>
    CLASS
    load(URI uri)
    Load data from the resource identified by the provided uri into a bound object.
    default <CLASS extends dev.metaschema.core.model.IBoundObject>
    CLASS
    load(URL url)
    Load data from the provided resource into a bound object.
    default <CLASS extends dev.metaschema.core.model.IBoundObject>
    CLASS
    load(Path path)
    Load data from the provided resource into a bound object.
    dev.metaschema.core.metapath.item.node.IDocumentNodeItem
    loadAsNodeItem(Format format, InputStream is, URI resource)
    Load data expressed using the provided format and return that data as a Metapath node item.
    dev.metaschema.core.metapath.item.node.IDocumentNodeItem
    loadAsNodeItem(Format format, URI uri)
    Load data expressed using the provided format and return that data as a Metapath node item.
    default dev.metaschema.core.metapath.item.node.IDocumentNodeItem
    loadAsNodeItem(Format format, Path path)
    Load data expressed using the provided format and return that data as a Metapath node item.
    set(DeserializationFeature<?> feature, Object value)
     

    Methods inherited from interface dev.metaschema.core.configuration.IConfiguration

    get, getFeatureValues, isFeatureEnabled

    Methods inherited from interface dev.metaschema.core.metapath.IDocumentLoader

    loadAsNodeItem, loadAsNodeItem, loadAsNodeItem, loadAsNodeItem, setUriResolver

    Methods inherited from interface dev.metaschema.core.model.IResourceResolver

    getUriResolver, resolve
  • Method Details

    • enableFeature

      Specified by:
      enableFeature in interface dev.metaschema.core.configuration.IMutableConfiguration<DeserializationFeature<?>>
    • disableFeature

      Specified by:
      disableFeature in interface dev.metaschema.core.configuration.IMutableConfiguration<DeserializationFeature<?>>
    • applyConfiguration

      IBoundLoader applyConfiguration(dev.metaschema.core.configuration.IConfiguration<DeserializationFeature<?>> other)
      Specified by:
      applyConfiguration in interface dev.metaschema.core.configuration.IMutableConfiguration<DeserializationFeature<?>>
    • set

      Specified by:
      set in interface dev.metaschema.core.configuration.IMutableConfiguration<DeserializationFeature<?>>
    • detectFormat

      @NonNull default Format detectFormat(@NonNull File file) throws IOException
      Determine the format of the provided resource.
      Parameters:
      file - the resource
      Returns:
      the format information for the provided resource
      Throws:
      IOException - if an error occurred while reading the resource
    • detectFormat

      @NonNull default Format detectFormat(@NonNull Path path) throws IOException
      Determine the format of the provided resource.
      Parameters:
      path - the resource
      Returns:
      the format information for the provided resource
      Throws:
      IOException - if an error occurred while reading the resource
    • detectFormat

      @NonNull default Format detectFormat(@NonNull URL url) throws IOException
      Determine the format of the provided resource.
      Parameters:
      url - the resource
      Returns:
      the format information for the provided resource
      Throws:
      IOException - if an error occurred while reading the resource
    • detectFormat

      @NonNull Format detectFormat(@NonNull URI uri) throws IOException
      Determine the format of the resource identified by the provided uri.
      Parameters:
      uri - the resource
      Returns:
      the format information for the provided resource
      Throws:
      IOException - if an error occurred while reading the resource
    • detectFormat

      @NonNull FormatDetector.Result detectFormat(@NonNull InputStream is, @NonNull URI resource) throws IOException
      Determine the format of the provided resource.

      This method will consume data from the provided InputStream. If the caller of this method intends to read data from the stream after determining the format, the caller should pass in a stream that can be reset.

      This method will not close the provided InputStream, since it does not own the stream.

      Parameters:
      is - an input stream for the resource
      resource - the URI of the resource
      Returns:
      the format information for the provided resource
      Throws:
      IOException - if an error occurred while reading the resource
    • detectModel

      @NonNull @Owning ModelDetector.Result detectModel(@NonNull InputStream is, @NonNull URI resource, @NonNull Format format) throws IOException
      Determine the model of the provided resource.

      This method will consume data from any InputStream provided by the InputSource. If the caller of this method intends to read data from the stream after determining the format, the caller should pass in a stream that can be reset.

      This method will not close any InputStream provided by the InputSource, since it does not own the stream.

      The caller owns the returned result and is responsible for closing it.

      Parameters:
      is - an input stream for the resource
      resource - the URI of the resource
      format - the format of the provided resource
      Returns:
      the model of the provided resource
      Throws:
      IOException - if an error occurred while reading the resource
    • load

      @NonNull default <CLASS extends dev.metaschema.core.model.IBoundObject> CLASS load(@NonNull File file) throws IOException
      Load data from the provided resource into a bound object.

      This method will auto-detect the format of the provided resource.

      Type Parameters:
      CLASS - the type of the bound object to return
      Parameters:
      file - the resource
      Returns:
      a bound object containing the loaded data
      Throws:
      IOException - if an error occurred while reading the resource
      See Also:
    • load

      @NonNull default <CLASS extends dev.metaschema.core.model.IBoundObject> CLASS load(@NonNull Path path) throws IOException
      Load data from the provided resource into a bound object.

      This method will auto-detect the format of the provided resource.

      Type Parameters:
      CLASS - the type of the bound object to return
      Parameters:
      path - the resource
      Returns:
      a bound object containing the loaded data
      Throws:
      IOException - if an error occurred while reading the resource
      See Also:
    • load

      @NonNull default <CLASS extends dev.metaschema.core.model.IBoundObject> CLASS load(@NonNull URL url) throws IOException, URISyntaxException
      Load data from the provided resource into a bound object.

      This method will auto-detect the format of the provided resource.

      Type Parameters:
      CLASS - the type of the bound object to return
      Parameters:
      url - the resource
      Returns:
      a bound object containing the loaded data
      Throws:
      IOException - if an error occurred while reading the resource
      URISyntaxException - if the provided url is malformed
      See Also:
    • load

      @NonNull <CLASS extends dev.metaschema.core.model.IBoundObject> CLASS load(@NonNull URI uri) throws IOException
      Load data from the resource identified by the provided uri into a bound object.

      This method will auto-detect the format of the provided resource.

      Type Parameters:
      CLASS - the type of the bound object to return
      Parameters:
      uri - the resource
      Returns:
      a bound object containing the loaded data
      Throws:
      IOException - if an error occurred while reading the resource
      See Also:
    • load

      @NonNull <CLASS extends dev.metaschema.core.model.IBoundObject> CLASS load(@NonNull InputStream is, @NonNull URI resource) throws IOException
      Load data from the provided resource into a bound object.

      This method should auto-detect the format of the provided resource.

      This method will not close the provided InputStream, since it does not own the stream.

      Type Parameters:
      CLASS - the type of the bound object to return
      Parameters:
      is - the resource stream
      resource - the URI of the resource
      Returns:
      a bound object containing the loaded data
      Throws:
      IOException - if an error occurred while reading the resource
      See Also:
    • load

      @NonNull default <CLASS extends dev.metaschema.core.model.IBoundObject> CLASS load(@NonNull Class<CLASS> clazz, @NonNull File file) throws IOException
      Load data from the specified resource into a bound object with the type of the specified Java class.
      Type Parameters:
      CLASS - the Java type to load data into
      Parameters:
      clazz - the class for the java type
      file - the resource to load
      Returns:
      the loaded instance data
      Throws:
      IOException - if an error occurred while loading the data in the specified file
    • load

      @NonNull default <CLASS extends dev.metaschema.core.model.IBoundObject> CLASS load(@NonNull Class<CLASS> clazz, @NonNull Path path) throws IOException
      Load data from the specified resource into a bound object with the type of the specified Java class.
      Type Parameters:
      CLASS - the Java type to load data into
      Parameters:
      clazz - the class for the java type
      path - the resource to load
      Returns:
      the loaded instance data
      Throws:
      IOException - if an error occurred while loading the data in the specified file
    • load

      @NonNull default <CLASS extends dev.metaschema.core.model.IBoundObject> CLASS load(@NonNull Class<CLASS> clazz, @NonNull URL url) throws IOException, URISyntaxException
      Load data from the specified resource into a bound object with the type of the specified Java class.
      Type Parameters:
      CLASS - the Java type to load data into
      Parameters:
      clazz - the class for the java type
      url - the resource to load
      Returns:
      the loaded instance data
      Throws:
      IOException - if an error occurred while loading the data in the specified file
      URISyntaxException - if the provided url is malformed
    • load

      @NonNull <CLASS extends dev.metaschema.core.model.IBoundObject> CLASS load(@NonNull Class<CLASS> clazz, @NonNull URI uri) throws IOException
      Load data from the specified resource into a bound object with the type of the specified Java class.
      Type Parameters:
      CLASS - the Java type to load data into
      Parameters:
      clazz - the class for the java type
      uri - the resource to load
      Returns:
      the loaded instance data
      Throws:
      IOException - if an error occurred while loading the data in the specified file
    • load

      @NonNull <CLASS extends dev.metaschema.core.model.IBoundObject> CLASS load(@NonNull Class<CLASS> clazz, @NonNull InputStream is, @NonNull URI resource) throws IOException
      Load data from the specified resource into a bound object with the type of the specified Java class.

      This method will not close the provided InputStream, since it does not own the stream.

      Implementations of this method will do format detection. This process might leave the provided InputStream at a position beyond the last parsed location. If you want to avoid this possibility, use and implementation of IDeserializer.deserialize(InputStream, URI) instead, such as what is provided by DefaultBindingContext.newDeserializer(Format, Class).

      Type Parameters:
      CLASS - the Java type to load data into
      Parameters:
      clazz - the class for the java type
      is - the resource stream
      resource - the URI of the resource
      Returns:
      the loaded data
      Throws:
      IOException - if an error occurred while loading the data from the specified resource
    • load

      @NonNull <CLASS extends dev.metaschema.core.model.IBoundObject> CLASS load(@NonNull Class<CLASS> clazz, @NonNull Format format, @NonNull InputStream is, @NonNull URI resource) throws IOException
      Load data from the specified resource into a bound object with the type of the specified Java class.

      This method will not close the provided InputStream, since it does not own the stream.

      Type Parameters:
      CLASS - the Java type to load data into
      Parameters:
      format - the format to parse
      clazz - the class for the java type
      is - the resource stream
      resource - the URI of the resource
      Returns:
      the loaded data
      Throws:
      IOException - if an error occurred while loading the data from the specified resource
    • loadAsNodeItem

      @NonNull default dev.metaschema.core.metapath.item.node.IDocumentNodeItem loadAsNodeItem(@NonNull Format format, @NonNull Path path) throws IOException
      Load data expressed using the provided format and return that data as a Metapath node item.

      The specific Module model is auto-detected by analyzing the source. The class reported is implementation specific.

      Parameters:
      format - the expected format of the data to parse
      path - the resource
      Returns:
      the Metapath node item for the parsed data
      Throws:
      IOException - if an error occurred while loading the data from the specified resource
    • loadAsNodeItem

      @NonNull dev.metaschema.core.metapath.item.node.IDocumentNodeItem loadAsNodeItem(@NonNull Format format, @NonNull URI uri) throws IOException
      Load data expressed using the provided format and return that data as a Metapath node item.

      The specific Module model is auto-detected by analyzing the source. The class reported is implementation specific.

      Parameters:
      format - the expected format of the data to parse
      uri - the resource
      Returns:
      the Metapath node item for the parsed data
      Throws:
      IOException - if an error occurred while loading the data from the specified resource
    • loadAsNodeItem

      @NonNull dev.metaschema.core.metapath.item.node.IDocumentNodeItem loadAsNodeItem(@NonNull Format format, @NonNull InputStream is, @NonNull URI resource) throws IOException
      Load data expressed using the provided format and return that data as a Metapath node item.

      The specific Module model is auto-detected by analyzing the source. The class reported is implementation specific.

      Parameters:
      format - the expected format of the data to parse
      is - the resource stream
      resource - the URI of the resource
      Returns:
      the Metapath node item for the parsed data
      Throws:
      IOException - if an error occurred while loading the data from the specified resource
    • getBindingContext

      Get the configured Module binding context to use to load Java types.
      Returns:
      the binding context
    • convert

      default <CLASS extends dev.metaschema.core.model.IBoundObject> void convert(@NonNull Path source, @NonNull Path destination, @NonNull Format toFormat, @NonNull Class<CLASS> rootClass) throws FileNotFoundException, IOException
      Auto convert the provided source to the provided toFormat. Write the converted content to the provided destination.

      The format of the source is expected to be auto detected using detectFormat(Path).

      Type Parameters:
      CLASS - the Java type to load data into
      Parameters:
      source - the resource to convert
      destination - the resource to write converted content to
      toFormat - the format to convert to
      rootClass - the class for the Java type to load data into
      Throws:
      FileNotFoundException - the the provided source file was not found
      IOException - if an error occurred while loading the data from the specified resource or writing the converted data to the specified destination
    • convert

      default <CLASS extends dev.metaschema.core.model.IBoundObject> void convert(@NonNull Path source, @NonNull OutputStream os, @NonNull Format toFormat, @NonNull Class<CLASS> rootClass) throws FileNotFoundException, IOException
      Auto convert the provided source to the provided toFormat. Write the converted content to the provided destination.

      The format of the source is expected to be auto detected using detectFormat(Path).

      Type Parameters:
      CLASS - the Java type to load data into
      Parameters:
      source - the resource to convert
      os - the output stream to write converted content to
      toFormat - the format to convert to
      rootClass - the class for the Java type to load data into
      Throws:
      FileNotFoundException - the the provided source file was not found
      IOException - if an error occurred while loading the data from the specified resource or writing the converted data to the specified destination
    • convert

      default <CLASS extends dev.metaschema.core.model.IBoundObject> void convert(@NonNull URI source, @NonNull Path destination, @NonNull Format toFormat, @NonNull Class<CLASS> rootClass) throws FileNotFoundException, IOException
      Auto convert the provided source to the provided toFormat. Write the converted content to the provided destination.

      The format of the source is expected to be auto detected using detectFormat(Path).

      Type Parameters:
      CLASS - the Java type to load data into
      Parameters:
      source - the resource to convert
      destination - the resource to write converted content to
      toFormat - the format to convert to
      rootClass - the class for the Java type to load data into
      Throws:
      FileNotFoundException - the the provided source file was not found
      IOException - if an error occurred while loading the data from the specified resource or writing the converted data to the specified destination
    • convert

      default <CLASS extends dev.metaschema.core.model.IBoundObject> void convert(@NonNull URI source, @NonNull OutputStream os, @NonNull Format toFormat, @NonNull Class<CLASS> rootClass) throws FileNotFoundException, IOException
      Auto convert the provided source to the provided toFormat. Write the converted content to the provided destination.

      The format of the source is expected to be auto detected using detectFormat(Path).

      Type Parameters:
      CLASS - the Java type to load data into
      Parameters:
      source - the resource to convert
      os - the output stream to write converted content to
      toFormat - the format to convert to
      rootClass - the class for the Java type to load data into
      Throws:
      FileNotFoundException - the the provided source file was not found
      IOException - if an error occurred while loading the data from the specified resource or writing the converted data to the specified destination
    • convert

      default <CLASS extends dev.metaschema.core.model.IBoundObject> void convert(@NonNull URI source, @NonNull Writer writer, @NonNull Format toFormat, @NonNull Class<CLASS> rootClass) throws FileNotFoundException, IOException
      Auto convert the provided source to the provided toFormat. Write the converted content to the provided destination.

      The format of the source is expected to be auto detected using detectFormat(Path).

      Type Parameters:
      CLASS - the Java type to load data into
      Parameters:
      source - the resource to convert
      writer - the writer to write converted content to
      toFormat - the format to convert to
      rootClass - the class for the Java type to load data into
      Throws:
      FileNotFoundException - the the provided source file was not found
      IOException - if an error occurred while loading the data from the specified resource or writing the converted data to the specified destination