Class RDFLoader


  • public class RDFLoader
    extends java.lang.Object
    Handles common I/O to retrieve and parse RDF.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private boolean isRedirection​(int statusCode)
      Returns whether a given HTTP status code represents a redirection (i.e.
      void load​(java.io.File file, java.lang.String baseURI, RDFFormat dataFormat, RDFHandler rdfHandler)
      Parses RDF data from the specified file to the given RDFHandler.
      void load​(java.io.InputStream in, java.lang.String baseURI, RDFFormat dataFormat, RDFHandler rdfHandler)
      Parses RDF data from an InputStream to the RDFHandler.
      void load​(java.io.Reader reader, java.lang.String baseURI, RDFFormat dataFormat, RDFHandler rdfHandler)
      Parses RDF data from a Reader to the RDFHandler.
      void load​(java.net.URL url, java.lang.String baseURI, RDFFormat dataFormat, RDFHandler rdfHandler)
      Parses the RDF data that can be found at the specified URL to the RDFHandler.
      private void loadInputStreamOrReader​(java.lang.Object inputStreamOrReader, java.lang.String baseURI, RDFFormat dataFormat, RDFHandler rdfHandler)
      Adds the data that can be read from the supplied InputStream or Reader to this repository.
      private void loadZip​(java.io.InputStream in, java.lang.String baseURI, RDFFormat dataFormat, RDFHandler rdfHandler)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • load

        public void load​(java.io.File file,
                         java.lang.String baseURI,
                         RDFFormat dataFormat,
                         RDFHandler rdfHandler)
                  throws java.io.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:
        java.io.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​(java.net.URL url,
                         java.lang.String baseURI,
                         RDFFormat dataFormat,
                         RDFHandler rdfHandler)
                  throws java.io.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:
        java.io.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
      • isRedirection

        private boolean isRedirection​(int statusCode)
        Returns whether a given HTTP status code represents a redirection (i.e. 3xx)
        Parameters:
        statusCode -
        Returns:
      • load

        public void load​(java.io.InputStream in,
                         java.lang.String baseURI,
                         RDFFormat dataFormat,
                         RDFHandler rdfHandler)
                  throws java.io.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:
        java.io.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​(java.io.Reader reader,
                         java.lang.String baseURI,
                         RDFFormat dataFormat,
                         RDFHandler rdfHandler)
                  throws java.io.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:
        java.io.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
      • loadInputStreamOrReader

        private void loadInputStreamOrReader​(java.lang.Object inputStreamOrReader,
                                             java.lang.String baseURI,
                                             RDFFormat dataFormat,
                                             RDFHandler rdfHandler)
                                      throws java.io.IOException,
                                             RDFParseException,
                                             RDFHandlerException
        Adds the data that can be read from the supplied InputStream or Reader to this repository.
        Parameters:
        inputStreamOrReader - An InputStream or Reader containing RDF data that must be added to the repository.
        baseURI - The base URI for the data.
        dataFormat - The file format of the data.
        rdfHandler - handles all data from all documents
        Throws:
        java.io.IOException
        UnsupportedRDFormatException
        RDFParseException
        RDFHandlerException