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 Details

  • Method Details

    • 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. This method uses the class URL to resolve the provided url. This method honors HttpURLConnection.getFollowRedirects() to determine if redirects are followed and if set to true will also follow redirects from HTTP to HTTPS. The maximum number of redirects can be controlled using system property http.maxRedirects.
      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