Interface IBoundLoader

    • Method Detail

      • detectFormat

        @NonNull
        default FormatDetector.Result 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 FormatDetector.Result 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 FormatDetector.Result 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
        FormatDetector.Result 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)
                                    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
        Returns:
        the format information for the provided resource
        Throws:
        IOException - if an error occurred while reading the resource
      • load

        @NonNull
        default <CLASS> 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:
        detectFormat(File)
      • load

        @NonNull
        default <CLASS> 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:
        detectFormat(File)
      • load

        @NonNull
        default <CLASS> 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:
        detectFormat(URL)
      • load

        @NonNull
        <CLASS> 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:
        detectFormat(URL)
      • load

        @NonNull
        <CLASS> CLASS load​(@NonNull
                           InputStream is,
                           @NonNull
                           URI documentUri)
                    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
        documentUri - 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:
        detectFormat(InputStream)
      • load

        @NonNull
        default <CLASS> 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> 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> 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> 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> CLASS load​(@NonNull
                           Class<CLASS> clazz,
                           @NonNull
                           InputStream is,
                           @NonNull
                           URI documentUri)
                    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
        documentUri - 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 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
        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
        IDocumentNodeItem loadAsNodeItem​(@NonNull
                                         Format format,
                                         @NonNull
                                         InputStream is,
                                         @NonNull
                                         URI documentUri)
                                  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
        documentUri - 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

        @NonNull
        IBindingContext getBindingContext()
        Get the configured Module binding context to use to load Java types.
        Returns:
        the binding context
      • convert

        default <CLASS> 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> 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