org.eclipse.rdf4j.repository.util

## Class RDFLoader

- java.lang.Object
- - org.eclipse.rdf4j.repository.util.RDFLoader

-     public class RDFLoader
      extends Object

  Handles common I/O to retrieve and parse RDF.
  Author:
    James Leigh

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `RDFLoader(ParserConfig config, ValueFactory vf)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `load(File file, String baseURI, RDFFormat dataFormat, RDFHandler rdfHandler)` Parses RDF data from the specified file to the given RDFHandler.
    `void` | `load(InputStream in, String baseURI, RDFFormat dataFormat, RDFHandler rdfHandler)` Parses RDF data from an InputStream to the RDFHandler.
    `void` | `load(Reader reader, String baseURI, RDFFormat dataFormat, RDFHandler rdfHandler)` Parses RDF data from a Reader to the RDFHandler.
    `void` | `load(URL url, String baseURI, RDFFormat dataFormat, RDFHandler rdfHandler)` Parses the RDF data that can be found at the specified URL to the RDFHandler.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### RDFLoader

          public RDFLoader(ParserConfig config,
                           ValueFactory vf)

      Parameters:
        `config` -
        `vf` -

  - ### Method Detail

    - #### load

          public void load(File file,
                           String baseURI,
                           RDFFormat dataFormat,
                           RDFHandler rdfHandler)
                    throws IOException,
                           RDFParseException,
                           RDFHandlerException

      Parses RDF data from the specified file to the given RDFHandler.
      Parameters:
        `file` - A file containing RDF data.
        `baseURI` - The base URI to resolve any relative URIs that are in the data against. This defaults to the value of `file.toURI()` if the value is set to `null`.
        `dataFormat` - The serialization format of the data.
        `rdfHandler` - Receives RDF parser events.
      Throws:
        `IOException` - If an I/O error occurred while reading from the file.
        `UnsupportedRDFormatException` - If no parser is available for the specified RDF format.
        `RDFParseException` - If an error was found while parsing the RDF data.
        `RDFHandlerException` - If thrown by the RDFHandler

    - #### load

          public void load(URL url,
                           String baseURI,
                           RDFFormat dataFormat,
                           RDFHandler rdfHandler)
                    throws IOException,
                           RDFParseException,
                           RDFHandlerException

      Parses the RDF data that can be found at the specified URL to the RDFHandler.
      Parameters:
        `url` - The URL of the RDF data.
        `baseURI` - The base URI to resolve any relative URIs that are in the data against. This defaults to the value of `url.toExternalForm()` if the value is set to `null`.
        `dataFormat` - The serialization format of the data. If set to `null`, the format will be automatically determined by examining the content type in the HTTP response header, and failing that, the file name extension of the supplied URL.
        `rdfHandler` - Receives RDF parser events.
      Throws:
        `IOException` - If an I/O error occurred while reading from the URL.
        `UnsupportedRDFormatException` - If no parser is available for the specified RDF format, or the RDF format could not be automatically determined.
        `RDFParseException` - If an error was found while parsing the RDF data.
        `RDFHandlerException` - If thrown by the RDFHandler

    - #### load

          public void load(InputStream in,
                           String baseURI,
                           RDFFormat dataFormat,
                           RDFHandler rdfHandler)
                    throws IOException,
                           RDFParseException,
                           RDFHandlerException

      Parses RDF data from an InputStream to the RDFHandler.
      Parameters:
        `in` - An InputStream from which RDF data can be read.
        `baseURI` - The base URI to resolve any relative URIs that are in the data against.
        `dataFormat` - The serialization format of the data.
        `rdfHandler` - Receives RDF parser events.
      Throws:
        `IOException` - If an I/O error occurred while reading from the input stream.
        `UnsupportedRDFormatException` - If no parser is available for the specified RDF format.
        `RDFParseException` - If an error was found while parsing the RDF data.
        `RDFHandlerException` - If thrown by the RDFHandler

    - #### load

          public void load(Reader reader,
                           String baseURI,
                           RDFFormat dataFormat,
                           RDFHandler rdfHandler)
                    throws IOException,
                           RDFParseException,
                           RDFHandlerException

      Parses RDF data from a Reader to the RDFHandler. Note: using a Reader to upload byte-based data means that you have to be careful not to destroy the data's character encoding by enforcing a default character encoding upon the bytes. If possible, adding such data using an InputStream is to be preferred.
      Parameters:
        `reader` - A Reader from which RDF data can be read.
        `baseURI` - The base URI to resolve any relative URIs that are in the data against.
        `dataFormat` - The serialization format of the data.
        `rdfHandler` - Receives RDF parser events.
      Throws:
        `IOException` - If an I/O error occurred while reading from the reader.
        `UnsupportedRDFormatException` - If no parser is available for the specified RDF format.
        `RDFParseException` - If an error was found while parsing the RDF data.
        `RDFHandlerException` - If thrown by the RDFHandler

Copyright © 2015-2020 Eclipse Foundation. All Rights Reserved.