Package com.stardog.stark
Class Graphs
java.lang.Object
com.stardog.stark.Graphs
Utilities for working with collections of RDF statements.
- Since:
- 1.0
- Version:
- 1.0
- Author:
- Michael Grove
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionapplyContext(Collection<Statement> theStatements, Resource theContext) Create a copy of the statements, modifying them, to apply the given context to each.asList(Collection<Statement> theGraph, Resource theRes) Return the contents of the given list by following the `rdf:first`/`rdf:rest` structure of the listcontexts(Collection<Statement> theStatements) static booleanisList(Collection<Statement> theGraph, Resource theRes) Returns whether or not the given resource is a `rdf:List`static booleanisomorphic(Iterable<? extends Statement> model1, Iterable<? extends Statement> model2) Compares two RDF models, and returns true if they consist of isomorphic graphs and the isomorphic graph identifiers map 1:1 to each other.matching(Iterable<Statement> theStmts, StatementPattern thePattern) Return all thestatementsthatmatch the pattern.Apply the given context to all of the statements, including Statement values in the subject position.Return the object for the given SP.objects(Collection<Statement> theStatements) predicates(Collection<Statement> theStatements) subjects(Collection<Statement> theStatements) subjectsOfType(Iterable<Statement> theStatements, IRI theClass) Return the contents of the list serialized as an RDF list
-
Constructor Details
-
Graphs
public Graphs()
-
-
Method Details
-
subjects
-
predicates
-
objects
-
contexts
-
applyContext
@Nonnull public static Set<Statement> applyContext(@Nonnull Collection<Statement> theStatements, @Nonnull Resource theContext) Create a copy of the statements, modifying them, to apply the given context to each.- Parameters:
theStatements- the statementstheContext- the new context- Returns:
- the new statements
-
matching
@Nonnull public static Stream<Statement> matching(@Nonnull Iterable<Statement> theStmts, @Nonnull StatementPattern thePattern) Return all thestatementsthatmatch the pattern.- Parameters:
theStmts- the statementsthePattern- the pattern to match- Returns:
- the matching statements
-
object
@Nonnull public static Optional<Value> object(@Nonnull Iterable<Statement> theStatements, @Nonnull Resource theSubj, @Nonnull IRI thePred) Return the object for the given SP. If the SP combination has more than one object associated with it, only the first one will be returned.- Parameters:
theStatements- the statementstheSubj- the subjectthePred- the predicate- Returns:
- the object for the given SP
-
named
@Nonnull public static Set<Statement> named(@Nonnull Iterable<Statement> theStatements, @Nonnull Resource theContext) Apply the given context to all of the statements, including Statement values in the subject position.- Parameters:
theStatements- the graph of statementstheContext- the context to apply- Returns:
- A *new* set of statements all of which are in the given context
-
isList
Returns whether or not the given resource is a `rdf:List`- Parameters:
theGraph- the graphtheRes- the resource to check- Returns:
- `true` if its a list, `false` otherwise
-
asList
@Nonnull public static List<Value> asList(@Nonnull Collection<Statement> theGraph, @Nonnull Resource theRes) Return the contents of the given list by following the `rdf:first`/`rdf:rest` structure of the list- Parameters:
theGraph- the graphtheRes- the resource which is the head of the list- Returns:
- the contents of the list.
-
toList
Return the contents of the list serialized as an RDF list- Parameters:
theResources- the list- Returns:
- the list as RDF
-
isomorphic
public static boolean isomorphic(@Nonnull Iterable<? extends Statement> model1, @Nonnull Iterable<? extends Statement> model2) Compares two RDF models, and returns true if they consist of isomorphic graphs and the isomorphic graph identifiers map 1:1 to each other. RDF graphs are isomorphic graphs if statements from one graphs can be mapped 1:1 on to statements in the other graphs. In this mapping, blank nodes are not considered mapped when having an identical internal id, but are mapped from one graph to the other by looking at the statements in which the blank nodes occur.A Model can consist of more than one graph (denoted by context identifiers). Two models are considered isomorphic if for each of the graphs in one model, an isomorphic graph exists in the other model, and the context identifiers of these graphs are either identical or (in the case of blank nodes) map 1:1 on each other.
- See Also:
-
subjectsOfType
-