public interface RDF4JGraph extends Graph, RDF4JGraphLike<Triple>
| Modifier and Type | Method and Description |
|---|---|
Set<RDF4JBlankNodeOrIRI> |
getContextMask()
Return a copy of the context mask as a
Set of
RDF4JBlankNodeOrIRI graph names. |
ClosableIterable<Triple> |
iterate() |
ClosableIterable<Triple> |
iterate(BlankNodeOrIRI subject,
IRI predicate,
RDFTerm object) |
Stream<RDF4JTriple> |
stream() |
Stream<RDF4JTriple> |
stream(BlankNodeOrIRI subject,
IRI predicate,
RDFTerm object) |
add, add, clear, close, contains, contains, getTriples, getTriples, remove, remove, sizeasModel, asRepositorySet<RDF4JBlankNodeOrIRI> getContextMask()
Set of
RDF4JBlankNodeOrIRI graph names.
If the set is not Set.isEmpty(), the mask determines which
contexts in the corresponding RDF4J Model or
Repository that this graph reflect. Modifications to the graph
(e.g. Graph.add(Triple) will be performed for all the specified
contexts, while retrieval (e.g. Graph.contains(Triple)) will succeed
if the triple is in at least one of the specified contexts.
The context mask array may contain null, indicating the
default context (the default graph in RDF datasets).
If the context mask is Set.isEmpty(), then this is a union
graph which triples reflect statements in any contexts. Triples
added to the graph will be added in the default context, e.g. equivalent
to new Resource[1]{null}) in RDF4J.
Note that the context mask itself cannot be null.
The returned set is an immutable copy; to specify a different mask, use
RDF4J.asGraph(Repository, Set, Option...)
BlankNodeOrIRI graph names,
which may contain the value null.Stream<RDF4JTriple> stream()
Note that for graphs backed by a repository (RDF4JGraphLike.asRepository() is
present), the stream must be closed with
BaseStream.close().
This can generally achieved using a try-with-resources block, e.g.:
int subjects;
try (Stream<RDF4JTriple> s : graph.stream()) {
subjects = s.map(RDF4JTriple::getSubject).distinct().count()
}
Stream<RDF4JTriple> stream(BlankNodeOrIRI subject, IRI predicate, RDFTerm object)
Note that for graphs backed by a repository (RDF4JGraphLike.asRepository() is
present), the stream must be closed with
BaseStream.close().
This can generally achieved using a try-with-resources block, e.g.:
int subjects;
try (Stream<RDF4JTriple> s : graph.stream(s,p,o)) {
subjects = s.map(RDF4JTriple::getSubject).distinct().count()
}
ClosableIterable<Triple> iterate() throws ConcurrentModificationException, IllegalStateException
Note that for graphs backed by a repository (RDF4JGraphLike.asRepository() is
present), the iterable must be closed with
AutoCloseable.close().
This can generally achieved using a try-with-resources block, e.g.:
try (ClosableIterable<Triple> s : graph.iterate()) {
for (Triple t : triples) {
return t; // OK to terminate for-loop early
}
}
If you don't use a try-with-resources block, the iterator will attempt to
close the ClosableIterable when reaching the end of the iteration.iterate in interface Graphiterate in interface GraphLike<Triple>ConcurrentModificationExceptionIllegalStateExceptionClosableIterable<Triple> iterate(BlankNodeOrIRI subject, IRI predicate, RDFTerm object)
Note that for graphs backed by a repository (RDF4JGraphLike.asRepository() is
present), the iterable must be closed with
AutoCloseable.close().
This can generally achieved using a try-with-resources block, e.g.:
try (ClosableIterable<Triple> s : graph.iterate(s,p,o)) {
for (Triple t : triples) {
return t; // OK to terminate for-loop early
}
}
If you don't use a try-with-resources block, the iterator will attempt to
close the ClosableIterable when reaching the end of the iteration.Copyright © 2015–2017 The Apache Software Foundation. All rights reserved.