Class Connections
- java.lang.Object
-
- org.eclipse.rdf4j.repository.util.Connections
-
public class Connections extends Object
Convenience functions for use withRepositoryConnection
s.- Author:
- Jeen Broekstra
-
-
Constructor Summary
Constructors Constructor Description Connections()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
consumeRDFCollection(RepositoryConnection conn, Resource head, Consumer<Statement> collectionConsumer, Resource... contexts)
static <C extends Collection<Statement>>
CgetRDFCollection(RepositoryConnection conn, Resource head, C statementCollection, Resource... contexts)
Retrieve allStatement
s that together form the RDF Collection starting with the supplied starting resource.static Optional<Statement>
getStatement(RepositoryConnection conn, Resource subject, IRI predicate, Value object, Resource... contexts)
Retrieve a singleStatement
matching with the supplied subject, predicate, object and context(s) from the givenRepositoryConnection
.
-
-
-
Method Detail
-
consumeRDFCollection
public static void consumeRDFCollection(RepositoryConnection conn, Resource head, Consumer<Statement> collectionConsumer, Resource... contexts) throws RepositoryException
Retrieve allStatement
s that together form the RDF Collection starting with the supplied start resource and send them to the suppliedConsumer
.- Parameters:
conn
- theRepositoryConnection
to use for statement retrieval.head
- the start resource of the RDF Collection. May not benull
.collectionConsumer
- aConsumer
function to which all retrieved statements will be reported. May not benull
.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 Also:
RDFCollections
, RDF Schema 1.1 section on Collection vocabulary.
-
getRDFCollection
public static <C extends Collection<Statement>> C getRDFCollection(RepositoryConnection conn, Resource head, C statementCollection, Resource... contexts) throws RepositoryException
Retrieve allStatement
s that together form the RDF Collection starting with the supplied starting resource.- Parameters:
conn
- theRepositoryConnection
to use for statement retrieval.head
- the start resource of the RDF Collection. May not benull
.statementCollection
- aCollection
ofStatement
s (for example, aModel
) to which all retrieved statements will be reported. May not benull
.contexts
- the context(s) from which to read the RDF Collection. This argument is an optional vararg and can be left out.- Returns:
- the input statement collection, with the statements forming the retrieved RDF Collection added.
- 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 Also:
RDFCollections
, RDF Schema 1.1 section on Collection vocabulary.
-
getStatement
public static Optional<Statement> getStatement(RepositoryConnection conn, Resource subject, IRI predicate, Value object, Resource... contexts) throws RepositoryException
Retrieve a singleStatement
matching with the supplied subject, predicate, object and context(s) from the givenRepositoryConnection
. If more than one Statement matches, any one Statement is selected and returned.- Parameters:
conn
- theRepositoryConnection
from which to retrieve the statement.subject
- the subject to which the statement should match. May benull
.predicate
- the predicate to which the statement should match. May benull
.object
- the object to which the statement should match. May benull
.contexts
- the context(s) from which to read the Statement. This argument is an optional vararg and can be left out.- Returns:
- an
Optional
ofStatement
. If no matching Statement was found,Optional.empty()
is returned. - Throws:
RepositoryException
-
-