Class RDFLoader
- java.lang.Object
-
- org.eclipse.rdf4j.repository.util.RDFLoader
-
public class RDFLoader extends java.lang.ObjectHandles common I/O to retrieve and parse RDF.
-
-
Field Summary
Fields Modifier and Type Field Description private ParserConfigconfigprivate ValueFactoryvf
-
Constructor Summary
Constructors Constructor Description RDFLoader(ParserConfig config, ValueFactory vf)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private booleanisRedirection(int statusCode)Returns whether a given HTTP status code represents a redirection (i.e.voidload(java.io.File file, java.lang.String baseURI, RDFFormat dataFormat, RDFHandler rdfHandler)Parses RDF data from the specified file to the given RDFHandler.voidload(java.io.InputStream in, java.lang.String baseURI, RDFFormat dataFormat, RDFHandler rdfHandler)Parses RDF data from an InputStream to the RDFHandler.voidload(java.io.Reader reader, java.lang.String baseURI, RDFFormat dataFormat, RDFHandler rdfHandler)Parses RDF data from a Reader to the RDFHandler.voidload(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 voidloadInputStreamOrReader(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 voidloadZip(java.io.InputStream in, java.lang.String baseURI, RDFFormat dataFormat, RDFHandler rdfHandler)
-
-
-
Field Detail
-
config
private final ParserConfig config
-
vf
private final ValueFactory vf
-
-
Constructor Detail
-
RDFLoader
public RDFLoader(ParserConfig config, ValueFactory vf)
- Parameters:
config-vf-
-
-
Method Detail
-
load
public void load(java.io.File file, java.lang.String baseURI, RDFFormat dataFormat, RDFHandler rdfHandler) throws java.io.IOException, RDFParseException, RDFHandlerExceptionParses 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 offile.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, RDFHandlerExceptionParses the RDF data that can be found at the specified URL to the RDFHandler. This method uses the classURLto resolve the provided url. This method honorsHttpURLConnection.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 ofurl.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, RDFHandlerExceptionParses 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, RDFHandlerExceptionParses 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
-
loadZip
private void loadZip(java.io.InputStream in, java.lang.String baseURI, RDFFormat dataFormat, RDFHandler rdfHandler) throws java.io.IOException, RDFParseException, RDFHandlerException- Throws:
java.io.IOExceptionRDFParseExceptionRDFHandlerException
-
loadInputStreamOrReader
private void loadInputStreamOrReader(java.lang.Object inputStreamOrReader, java.lang.String baseURI, RDFFormat dataFormat, RDFHandler rdfHandler) throws java.io.IOException, RDFParseException, RDFHandlerExceptionAdds the data that can be read from the supplied InputStream or Reader to this repository.- Parameters:
inputStreamOrReader- AnInputStreamorReadercontaining 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.IOExceptionUnsupportedRDFormatExceptionRDFParseExceptionRDFHandlerException
-
-