public class Models extends Object
Model
,
ModelBuilder
Modifier | Constructor and Description |
---|---|
protected |
Models() |
Modifier and Type | Method and Description |
---|---|
static Set<Value> |
getProperties(Model m,
Resource subject,
IRI property,
Resource... contexts)
Retrieve all property values for the supplied subject and property from the given model.
|
static Optional<Value> |
getProperty(Model m,
Resource subject,
IRI property,
Resource... contexts)
Retrieve a property value for the supplied subject from the given model.
|
static Optional<IRI> |
getPropertyIRI(Model m,
Resource subject,
IRI property,
Resource... contexts)
Retrieve a property value as an IRI for the supplied subject from the given model.
|
static Set<IRI> |
getPropertyIRIs(Model m,
Resource subject,
IRI property,
Resource... contexts)
Retrieve all property IRI values for the supplied subject and property from the given model.
|
static Optional<Literal> |
getPropertyLiteral(Model m,
Resource subject,
IRI property,
Resource... contexts)
Retrieve a property value as a
Literal for the supplied subject from the given model. |
static Set<Literal> |
getPropertyLiterals(Model m,
Resource subject,
IRI property,
Resource... contexts)
Retrieve all property Literal values for the supplied subject and property from the given model.
|
static Optional<Resource> |
getPropertyResource(Model m,
Resource subject,
IRI property,
Resource... contexts)
Retrieve a property value as an IRI for the supplied subject from the given model.
|
static Set<Resource> |
getPropertyResources(Model m,
Resource subject,
IRI property,
Resource... contexts)
Retrieve all property Resource values for the supplied subject and property from the given model.
|
static Optional<String> |
getPropertyString(Model m,
Resource subject,
IRI property,
Resource... contexts)
Retrieve a property value as a String for the supplied subject from the given model.
|
static Set<String> |
getPropertyStrings(Model m,
Resource subject,
IRI property,
Resource... contexts)
Retrieve all property values as Strings for the supplied subject and property from the given model.
|
static boolean |
isomorphic(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.
|
static boolean |
isSubset(Iterable<? extends Statement> model1,
Iterable<? extends Statement> model2)
Compares two RDF models, and returns true if the first model is a subset of the second model, using
graph isomorphism to map statements between models.
|
static boolean |
isSubset(Set<? extends Statement> model1,
Set<? extends Statement> model2)
Compares two RDF models, and returns true if the first model is a subset of the second model, using
graph isomorphism to map statements between models.
|
static java.util.function.Supplier<ModelException> |
modelException(String message)
Creates a
Supplier of ModelException objects that be passed to
Optional.orElseThrow(Supplier) to generate exceptions as necessary. |
static Optional<Value> |
object(Model m)
Retrieves an object
Value from the statements in the given model. |
static Optional<IRI> |
objectIRI(Model m)
Retrieves an object
IRI value from the statements in the given model. |
static Set<IRI> |
objectIRIs(Model m)
Retrieves all object
IRI values from the statements in the given model. |
static Optional<Literal> |
objectLiteral(Model m)
Retrieves an object
Literal value from the statements in the given model. |
static Set<Literal> |
objectLiterals(Model m)
Retrieves all object
Literal values from the statements in the given model. |
static Optional<Resource> |
objectResource(Model m)
Retrieves an object
Resource value from the statements in the given model. |
static Set<Resource> |
objectResources(Model m)
Retrieves all object
Resource values from the statements in the given model. |
static Optional<String> |
objectString(Model m)
Retrieves an object value as a String from the statements in the given model.
|
static Set<String> |
objectStrings(Model m)
Retrieves all object String values from the statements in the given model.
|
static Optional<IRI> |
predicate(Model m)
Retrieves a predicate from the statements in the given model.
|
static Model |
setProperty(Model m,
Resource subject,
IRI property,
Value value,
Resource... contexts)
Sets the property value for the given subject to the given object value, replacing any existing value(s) for the
subject's property.
|
static Model |
stripContexts(Model model,
Resource... contexts)
Strips contexts from the input model.
|
static Optional<Resource> |
subject(Model m)
Retrieves a subject
Resource from the statements in the given model. |
static Optional<BNode> |
subjectBNode(Model m)
Retrieves a subject
BNode from the statements in the given model. |
static Set<BNode> |
subjectBNodes(Model m)
Retrieves all subject
BNode s from the statements in the given model. |
static Optional<IRI> |
subjectIRI(Model m)
Retrieves a subject
IRI from the statements in the given model. |
static Set<IRI> |
subjectIRIs(Model m)
Retrieves all subject
IRI s from the statements in the given model. |
static Model |
synchronizedModel(Model toSynchronize)
Make a model thread-safe by synchronizing all its methods.
|
public static Optional<Value> object(Model m)
Value
from the statements in the given model. If more than one possible object value
exists, any one value is picked and returned.m
- the model from which to retrieve an object value.Optional.empty()
if no such value exists.public static Optional<Literal> objectLiteral(Model m)
Literal
value from the statements in the given model. If more than one possible
Literal value exists, any one Literal value is picked and returned.m
- the model from which to retrieve an object Literal value.Optional.empty()
if no such value exists.public static Set<Literal> objectLiterals(Model m)
Literal
values from the statements in the given model.m
- the model from which to retrieve all object Literal
values.Set
containing object Literal
values from the given model, which will be empty if no
such value exists.Model.objects()
public static Optional<Resource> objectResource(Model m)
Resource
value from the statements in the given model. If more than one possible
Resource value exists, any one Resource value is picked and returned.public static Set<Resource> objectResources(Model m)
Resource
values from the statements in the given model.m
- the model from which to retrieve all object Resource
values.Set
containing object Resource
values from the given model, which will be empty if no
such value exists.Model.objects()
public static Optional<IRI> objectIRI(Model m)
IRI
value from the statements in the given model. If more than one possible IRI value
exists, any one value is picked and returned.public static Set<IRI> objectIRIs(Model m)
IRI
values from the statements in the given model.m
- the model from which to retrieve all object IRI values.Set
containing object IRI values from the given model, which will be empty if no such value
exists.Model.objects()
public static Optional<String> objectString(Model m)
public static Set<String> objectStrings(Model m)
m
- the model from which to retrieve all object String values.Set
containing object String values from the given model, which will be empty if no such value
exists.Model.objects()
public static Optional<Resource> subject(Model m)
Resource
from the statements in the given model. If more than one possible resource
value exists, any one resource value is picked and returned.public static Optional<IRI> subjectIRI(Model m)
IRI
from the statements in the given model. If more than one possible IRI value
exists, any one IRI value is picked and returned.public static Set<IRI> subjectIRIs(Model m)
IRI
s from the statements in the given model.m
- the model from which to retrieve a subject IRI value.Set
of subject IRI values from the given model. The returned Set may be empty.public static Optional<BNode> subjectBNode(Model m)
BNode
from the statements in the given model. If more than one possible blank node
value exists, any one blank node value is picked and returned.public static Set<BNode> subjectBNodes(Model m)
BNode
s from the statements in the given model.public static Optional<IRI> predicate(Model m)
public static Model setProperty(Model m, Resource subject, IRI property, Value value, Resource... contexts)
m
- the model in which to set the property value. May not be null.subject
- the subject for which to set/replace the property value. May not be null.property
- the property for which to set/replace the value. May not be null.value
- the value to set for the given subject and property. May not be null.contexts
- the context(s) in which to set/replace the property value. Optional vararg argument. If not
specified the operations works on the entire Model.public static Optional<Value> getProperty(Model m, Resource subject, IRI property, Resource... contexts)
m
- the model from which to retrieve an object value.subject
- the subject resource for which to retrieve a property value.property
- the property for which to retrieve a value.contexts
- the contexts from which to retrieve the property value. Optional vararg argument. If not
specified the operations works on the entire Model.Optional.empty()
if no such value exists.public static Set<Value> getProperties(Model m, Resource subject, IRI property, Resource... contexts)
m
- the model from which to retrieve the property values.subject
- the subject resource for which to retrieve all property values.property
- the property for which to retrieve all values.contexts
- the contexts from which to retrieve the property values. Optional vararg argument. If not
specified the operations works on the entire Model.public static Optional<Resource> getPropertyResource(Model m, Resource subject, IRI property, Resource... contexts)
m
- the model from which to retrieve an object value.subject
- the subject resource for which to retrieve a property value.property
- the property for which to retrieve a value.contexts
- the contexts from which to retrieve the property value. Optional vararg argument. If not
specified the operations works on the entire Model.Optional.empty()
if no such value exists.public static Set<Resource> getPropertyResources(Model m, Resource subject, IRI property, Resource... contexts)
m
- the model from which to retrieve the property Resource values.subject
- the subject resource for which to retrieve all property Resource values.property
- the property for which to retrieve all Resource values.contexts
- the contexts from which to retrieve the property values. Optional vararg argument. If not
specified the operations works on the entire Model.public static Optional<IRI> getPropertyIRI(Model m, Resource subject, IRI property, Resource... contexts)
m
- the model from which to retrieve an object value.subject
- the subject resource for which to retrieve a property value.property
- the property for which to retrieve a value.contexts
- the contexts from which to retrieve the property value. Optional vararg argument. If not
specified the operations works on the entire Model.Optional.empty()
if no such value exists.public static Set<IRI> getPropertyIRIs(Model m, Resource subject, IRI property, Resource... contexts)
m
- the model from which to retrieve the property IRI values.subject
- the subject resource for which to retrieve all property IRI values.property
- the property for which to retrieve all IRI values.contexts
- the contexts from which to retrieve the property values. Optional vararg argument. If not
specified the operations works on the entire Model.public static Optional<Literal> getPropertyLiteral(Model m, Resource subject, IRI property, Resource... contexts)
Literal
for the supplied subject from the given model. If more than one
property value exists, any one value is picked and returned.m
- the model from which to retrieve an object value.subject
- the subject resource for which to retrieve a property literal value.property
- the property for which to retrieve a value.contexts
- the contexts from which to retrieve the property value. Optional vararg argument. If not
specified the operations works on the entire Model.Optional.empty()
if no such value exists.public static Set<Literal> getPropertyLiterals(Model m, Resource subject, IRI property, Resource... contexts)
m
- the model from which to retrieve the property Literal values.subject
- the subject resource for which to retrieve all property Literal values.property
- the property for which to retrieve all Literal values.contexts
- the contexts from which to retrieve the property values. Optional vararg argument. If not
specified the operations works on the entire Model.public static Optional<String> getPropertyString(Model m, Resource subject, IRI property, Resource... contexts)
m
- the model from which to retrieve an object value.subject
- the subject resource for which to retrieve a property literal value.property
- the property for which to retrieve a value.contexts
- the contexts from which to retrieve the property value. Optional vararg argument. If not
specified the operations works on the entire Model.Optional.empty()
if no such value exists.public static Set<String> getPropertyStrings(Model m, Resource subject, IRI property, Resource... contexts)
m
- the model from which to retrieve the property values as Strings.subject
- the subject resource for which to retrieve all property values as Strings.property
- the property for which to retrieve all values as Strings.contexts
- the contexts from which to retrieve the property values. Optional vararg argument. If not
specified the operations works on the entire Model.public static boolean isomorphic(Iterable<? extends Statement> model1, Iterable<? extends Statement> model2)
public static boolean isSubset(Iterable<? extends Statement> model1, Iterable<? extends Statement> model2)
public static boolean isSubset(Set<? extends Statement> model1, Set<? extends Statement> model2)
public static Model stripContexts(Model model, Resource... contexts)
Model
containing all statements from the
input model, with the supplied contexts removed from those statements.model
- the input modelcontexts
- the contexts to remove. This is a vararg and as such is optional. If not supplied, the method
strips all contexts.Model
object containg the same statements as the input model, with the supplied contexts
stripped.public static java.util.function.Supplier<ModelException> modelException(String message)
Supplier
of ModelException
objects that be passed to
Optional.orElseThrow(Supplier)
to generate exceptions as necessary.message
- The message to be used for the exceptionSupplier
that will create ModelException
objects with the given message.Copyright © 2015-2020 Eclipse Foundation. All Rights Reserved.