use of org.eclipse.rdf4j.rio.RDFParseException in project graal by graphik-team.
the class Producer method run.
@Override
public void run() {
org.eclipse.rdf4j.rio.RDFParser rdfParser = Rio.createParser(format);
if (this.config != null) {
rdfParser.setParserConfig(config);
}
rdfParser.setRDFHandler(new RDFListener(buffer));
try {
rdfParser.parse(this.reader, "");
} catch (RDFParseException e) {
throw new ParseError("An error occured while parsing", e);
} catch (RDFHandlerException e) {
throw new ParseError("An error occured while parsing", e);
} catch (IOException e) {
throw new ParseError("An error occured while parsing", e);
}
buffer.close();
try {
this.reader.close();
} catch (IOException e) {
}
}
use of org.eclipse.rdf4j.rio.RDFParseException in project rdf4j by eclipse.
the class TestTurtleParser method testParseBooleanLiteralWhitespaceSemicolumn.
@Test
public void testParseBooleanLiteralWhitespaceSemicolumn() throws Exception {
String data = "<urn:a> <urn:b> true ; <urn:c> false .";
Reader r = new StringReader(data);
try {
parser.parse(r, baseURI);
assertTrue(statementCollector.getStatements().size() == 2);
} catch (RDFParseException e) {
fail("parse error on correct data: " + e.getMessage());
}
}
use of org.eclipse.rdf4j.rio.RDFParseException in project rdf4j by eclipse.
the class TestTurtleParser method testLineNumberReporting.
@Test
public void testLineNumberReporting() throws Exception {
InputStream in = this.getClass().getResourceAsStream("/test-newlines.ttl");
try {
parser.parse(in, baseURI);
fail("expected to fail parsing input file");
} catch (RDFParseException e) {
// expected
assertFalse(errorCollector.getFatalErrors().isEmpty());
final String error = errorCollector.getFatalErrors().get(0);
// expected to fail at line 9.
assertTrue(error.contains("(9,"));
assertEquals(9, locationListener.getLineNo());
assertEquals(-1, locationListener.getColumnNo());
}
}
use of org.eclipse.rdf4j.rio.RDFParseException in project rdf4j by eclipse.
the class TestTurtleParser method testParseBooleanLiteralComma.
@Test
public void testParseBooleanLiteralComma() throws Exception {
String data = "<urn:a> <urn:b> true, false .";
Reader r = new StringReader(data);
try {
parser.parse(r, baseURI);
assertTrue(statementCollector.getStatements().size() == 2);
} catch (RDFParseException e) {
fail("parse error on correct data: " + e.getMessage());
}
}
use of org.eclipse.rdf4j.rio.RDFParseException in project rdf4j by eclipse.
the class AbstractRepositoryConnection method add.
@Override
public void add(File file, String baseURI, RDFFormat dataFormat, Resource... contexts) throws IOException, RDFParseException, RepositoryException {
OpenRDFUtil.verifyContextNotNull(contexts);
RDFInserter rdfInserter = new RDFInserter(this);
rdfInserter.enforceContext(contexts);
boolean localTransaction = startLocalTransaction();
try {
RDFLoader loader = new RDFLoader(getParserConfig(), getValueFactory());
loader.load(file, baseURI, dataFormat, rdfInserter);
conditionalCommit(localTransaction);
} catch (RDFHandlerException e) {
conditionalRollback(localTransaction);
// RDFInserter only throws wrapped RepositoryExceptions
throw (RepositoryException) e.getCause();
} catch (RDFParseException e) {
conditionalRollback(localTransaction);
throw e;
} catch (IOException e) {
conditionalRollback(localTransaction);
throw e;
} catch (RuntimeException e) {
conditionalRollback(localTransaction);
throw e;
}
}
Aggregations