Search in sources :

Example 96 with Literal

use of org.eclipse.rdf4j.model.Literal in project timbuctoo by HuygensING.

the class TimRdfHandler method handleStatement.

@Override
public void handleStatement(Statement st) throws RDFHandlerException {
    try {
        if (Thread.currentThread().isInterrupted()) {
            rdfProcessor.commit();
            throw new RDFHandlerException("Interrupted");
        }
        String graph = st.getContext() == null ? defaultGraph : st.getContext().stringValue();
        rdfProcessor.onQuad(isAssertion(), handleNode(st.getSubject()), st.getPredicate().stringValue(), handleNode(st.getObject()), (st.getObject() instanceof Literal) ? ((Literal) st.getObject()).getDatatype().toString() : null, (st.getObject() instanceof Literal) ? ((Literal) st.getObject()).getLanguage().orElse(null) : null, graph);
    } catch (RdfProcessingFailedException e) {
        throw new RDFHandlerException(e);
    }
}
Also used : RDFHandlerException(org.eclipse.rdf4j.rio.RDFHandlerException) Literal(org.eclipse.rdf4j.model.Literal) RdfProcessingFailedException(nl.knaw.huygens.timbuctoo.v5.dataset.exceptions.RdfProcessingFailedException)

Aggregations

Literal (org.eclipse.rdf4j.model.Literal)96 Test (org.junit.Test)52 IRI (org.eclipse.rdf4j.model.IRI)34 Value (org.eclipse.rdf4j.model.Value)17 BNode (org.eclipse.rdf4j.model.BNode)14 Model (org.eclipse.rdf4j.model.Model)13 Statement (org.eclipse.rdf4j.model.Statement)13 Resource (org.eclipse.rdf4j.model.Resource)9 LinkedHashModel (org.eclipse.rdf4j.model.impl.LinkedHashModel)8 RDFHandlerException (org.eclipse.rdf4j.rio.RDFHandlerException)7 InputStream (java.io.InputStream)6 Date (java.util.Date)6 BindingSet (org.eclipse.rdf4j.query.BindingSet)5 IOException (java.io.IOException)4 ValueFactory (org.eclipse.rdf4j.model.ValueFactory)4 SimpleValueFactory (org.eclipse.rdf4j.model.impl.SimpleValueFactory)4 AbstractQueryResultIOTupleTest (org.eclipse.rdf4j.query.resultio.AbstractQueryResultIOTupleTest)4 QueryResultCollector (org.eclipse.rdf4j.query.resultio.helpers.QueryResultCollector)4 SPARQLResultsJSONParser (org.eclipse.rdf4j.query.resultio.sparqljson.SPARQLResultsJSONParser)4 ArrayList (java.util.ArrayList)3