use of org.eclipse.rdf4j.model.util.GetStatementOptional in project rdf4j by eclipse.
the class Connections method consumeRDFCollection.
/**
* Retrieve all {@link Statement}s that together form the RDF Collection starting with the supplied start
* resource and send them to the supplied {@link Consumer}.
*
* @param conn
* the {@link RepositoryConnection} to use for statement retrieval.
* @param head
* the start resource of the RDF Collection. May not be {@code null}.
* @param collectionConsumer
* a {@link Consumer} function to which all retrieved statements will be reported. May not be
* {@code null}.
* @param contexts
* the context(s) from which to read the RDF Collection. This argument is an optional vararg and
* can be left out.
* @throws RepositoryException
* if an error occurred while reading the collection statements, for example if a cycle is
* detected in the RDF collection, or some other anomaly which makes it non-wellformed.
* @see RDFCollections
* @see <a href="http://www.w3.org/TR/rdf-schema/#ch_collectionvocab">RDF Schema 1.1 section on Collection
* vocabulary</a>.
*/
public static void consumeRDFCollection(RepositoryConnection conn, Resource head, Consumer<Statement> collectionConsumer, Resource... contexts) throws RepositoryException {
GetStatementOptional statementSupplier = (s, p, o, c) -> getStatement(conn, s, p, o, c);
Function<String, Supplier<RepositoryException>> exceptionSupplier = Repositories::repositoryException;
RDFCollections.extract(statementSupplier, head, collectionConsumer, exceptionSupplier, contexts);
}
Aggregations