use of org.eclipse.rdf4j.rio.helpers.ParseErrorLogger in project rdf4j by eclipse.
the class RDFLoader method loadInputStreamOrReader.
/**
* Adds the data that can be read from the supplied InputStream or Reader to
* this repository.
*
* @param inputStreamOrReader
* An {@link InputStream} or {@link Reader} containing RDF data
* that must be added to the repository.
* @param baseURI
* The base URI for the data.
* @param dataFormat
* The file format of the data.
* @param rdfHandler
* handles all data from all documents
* @throws IOException
* @throws UnsupportedRDFormatException
* @throws RDFParseException
* @throws RDFHandlerException
*/
private void loadInputStreamOrReader(Object inputStreamOrReader, String baseURI, RDFFormat dataFormat, RDFHandler rdfHandler) throws IOException, RDFParseException, RDFHandlerException {
RDFParser rdfParser = Rio.createParser(dataFormat, vf);
rdfParser.setParserConfig(config);
rdfParser.setParseErrorListener(new ParseErrorLogger());
rdfParser.setRDFHandler(rdfHandler);
if (inputStreamOrReader instanceof InputStream) {
rdfParser.parse((InputStream) inputStreamOrReader, baseURI);
} else if (inputStreamOrReader instanceof Reader) {
rdfParser.parse((Reader) inputStreamOrReader, baseURI);
} else {
throw new IllegalArgumentException("Must be an InputStream or a Reader, is a: " + inputStreamOrReader.getClass());
}
}
Aggregations