public class Models extends Object
Model,
ModelBuilder| Modifier | Constructor and Description |
|---|---|
protected |
Models() |
| Modifier and Type | Method and Description |
|---|---|
static Model |
convertRDFStarToReification(Model model)
Converts the statements in the supplied RDF* model to a new RDF model using reification.
|
static void |
convertRDFStarToReification(Model model,
java.util.function.Consumer<Statement> consumer)
Converts the supplied RDF* model to RDF reification statements.
|
static Model |
convertRDFStarToReification(ValueFactory vf,
Model model)
Converts the statements in supplied RDF* model to a new RDF model using reificiation.
|
static void |
convertRDFStarToReification(ValueFactory vf,
Model model,
java.util.function.Consumer<Statement> consumer)
Converts the supplied RDF* model to RDF reification statements.
|
static Model |
convertRDFStarToReification(ValueFactory vf,
Model model,
ModelFactory modelFactory)
Converts the statements in supplied RDF* model to a new RDF model using reificiation.
|
static Model |
convertReificationToRDFStar(Model model)
Converts the supplied RDF reification model to a new RDF* model.
|
static void |
convertReificationToRDFStar(Model model,
java.util.function.Consumer<Statement> consumer)
Converts the supplied RDF reification model to RDF* statements.
|
static Model |
convertReificationToRDFStar(ValueFactory vf,
Model model)
Converts the statements in supplied RDF reification model to a new RDF* model.
|
static void |
convertReificationToRDFStar(ValueFactory vf,
Model model,
java.util.function.Consumer<Statement> consumer)
Converts the supplied RDF reification model to RDF* statements.
|
static Model |
convertReificationToRDFStar(ValueFactory vf,
Model model,
ModelFactory modelFactory)
Converts the statements in supplied RDF reification model to a new RDF* model.
|
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 boolean |
legacyIsomorphic(Iterable<? extends Statement> model1,
Iterable<? extends Statement> model2)
Deprecated.
since 3.6.0 - use
isomorphic(Iterable, Iterable) instead. |
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(Iterable<Statement> statements)
Retrieves an object
Value from the supplied statements. |
static Optional<Value> |
object(Model m)
Retrieves an object
Value from the statements in the given model. |
static Optional<IRI> |
objectIRI(Iterable<Statement> statements)
Retrieves an object
IRI value from the supplied statements. |
static Optional<IRI> |
objectIRI(Model m)
Retrieves an object
IRI value from the supplied statements in the given model. |
static Set<IRI> |
objectIRIs(Iterable<Statement> statements)
Retrieves all object
IRI values from the supplied statements. |
static Set<IRI> |
objectIRIs(Model m)
Retrieves all object
IRI values from the statements in the given model. |
static Optional<Literal> |
objectLiteral(Iterable<Statement> statements)
Retrieves an object
Literal value from the supplied statements. |
static Optional<Literal> |
objectLiteral(Model m)
Retrieves an object
Literal value from the statements in the given model. |
static Set<Literal> |
objectLiterals(Iterable<Statement> statements)
Retrieves all object
Literal values from the supplied statements. |
static Set<Literal> |
objectLiterals(Model m)
Retrieves all object
Literal values from the statements in the given model. |
static Optional<Resource> |
objectResource(Iterable<Statement> statements)
Retrieves an object
Resource value from the supplied statements. |
static Optional<Resource> |
objectResource(Model m)
Retrieves an object
Resource value from the statements in the given model. |
static Set<Resource> |
objectResources(Iterable<Statement> statements)
Retrieves all object
Resource values from the supplied statements. |
static Set<Resource> |
objectResources(Model m)
Retrieves all object
Resource values from the supplied model. |
static Optional<String> |
objectString(Iterable<Statement> statements)
Retrieves an object value as a String from the supplied statements.
|
static Optional<String> |
objectString(Model m)
Retrieves an object value as a String from the statements in the given model.
|
static Set<String> |
objectStrings(Iterable<Statement> statements)
Retrieves all object String values from the supplied statements.
|
static Set<String> |
objectStrings(Model m)
Retrieves all object String values from the statements in the given model.
|
static Optional<IRI> |
predicate(Iterable<Statement> statements)
Retrieves a predicate from the supplied statements.
|
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(Iterable<Statement> statements)
Retrieves a subject
Resource from the supplied statements. |
static Optional<Resource> |
subject(Model m)
Retrieves a subject
Resource from the statements in the given model. |
static Optional<BNode> |
subjectBNode(Iterable<Statement> statements)
Retrieves a subject
BNode from the supplied statements. |
static Optional<BNode> |
subjectBNode(Model m)
Retrieves a subject
BNode from the statements in the given model. |
static Set<BNode> |
subjectBNodes(Iterable<Statement> statements)
Retrieves all subject
BNodes from the supplied statements. |
static Set<BNode> |
subjectBNodes(Model m)
Retrieves all subject
BNodes from the statements in the given model. |
static Optional<IRI> |
subjectIRI(Iterable<Statement> statements)
Retrieves a subject
IRI from the supplied statements. |
static Optional<IRI> |
subjectIRI(Model m)
Retrieves a subject
IRI from the statements in the given model. |
static Set<IRI> |
subjectIRIs(Iterable<Statement> statements)
Retrieves all subject
IRIs from the supplied statements. |
static Set<IRI> |
subjectIRIs(Model m)
Retrieves all subject
IRIs 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(Iterable<Statement> statements)
Value from the supplied statements. If more than one possible object value exists,
any one value is picked and returned.statements - the Statement Iterable from which to retrieve an object value.Optional.empty() if no such value exists.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(Iterable<Statement> statements)
Literal value from the supplied statements. If more than one possible Literal value
exists, any one Literal value is picked and returned.statements - the Statement Iterable from which to retrieve an object Literal 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(Iterable<Statement> statements)
Literal values from the supplied statements.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(Iterable<Statement> statements)
Resource value from the supplied statements. If more than one possible Resource value
exists, any one Resource value is picked and returned.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(Iterable<Statement> statements)
Resource values from the supplied statements.public static Set<Resource> objectResources(Model m)
Resource values from the supplied 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(Iterable<Statement> statements)
IRI value from the supplied statements. If more than one possible IRI value exists,
any one value is picked and returned.public static Optional<IRI> objectIRI(Model m)
IRI value from the supplied 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(Iterable<Statement> statements)
IRI values from the supplied statements.statements - the Statement Iterable 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 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(Iterable<Statement> statements)
public static Optional<String> objectString(Model m)
public static Set<String> objectStrings(Iterable<Statement> statements)
statements - the Statement Iterable 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 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(Iterable<Statement> statements)
Resource from the supplied statements. If more than one possible resource value
exists, any one resource value is picked and returned.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(Iterable<Statement> statements)
IRI from the supplied statements. If more than one possible IRI value exists, any one
IRI 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(Iterable<Statement> statements)
IRIs from the supplied statements.public static Set<IRI> subjectIRIs(Model m)
IRIs 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(Iterable<Statement> statements)
BNode from the supplied statements. If more than one possible blank node value
exists, any one blank node value is picked and returned.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(Iterable<Statement> statements)
BNodes from the supplied statements.public static Set<BNode> subjectBNodes(Model m)
BNodes from the statements in the given model.public static Optional<IRI> predicate(Iterable<Statement> statements)
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)
@Experimental @Deprecated public static boolean legacyIsomorphic(Iterable<? extends Statement> model1, Iterable<? extends Statement> model2)
isomorphic(Iterable, Iterable) instead.isomorphic comparison. This method is offered as
a temporary fallback for corner cases where the newly introduced isomorphism algorithm (in release 3.6.0) has
worse performance or an unexpected result.isomorphic(Iterable, Iterable)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.public static Model synchronizedModel(Model toSynchronize)
toSynchronize - the model that should be synchronized@Experimental public static void convertRDFStarToReification(ValueFactory vf, Model model, java.util.function.Consumer<Statement> consumer)
The supplied value factory is used to create all new statements.
vf - the ValueFactory to use for creating statements.model - the Model to convert.consumer - the Consumer function for the produced statements.@Experimental public static void convertRDFStarToReification(Model model, java.util.function.Consumer<Statement> consumer)
@Experimental public static Model convertRDFStarToReification(ValueFactory vf, Model model)
The supplied value factory is used to create all new statements.
vf - the ValueFactory to use for creating statements.model - the Model to convert.Model with RDF* statements converted to reified triples.@Experimental public static Model convertRDFStarToReification(ValueFactory vf, Model model, ModelFactory modelFactory)
The supplied value factory is used to create all new statements.
vf - the ValueFactory to use for creating statements.model - the Model to convert.modelFactory - the ModelFactory used to create the new output Model.Model with RDF* statements converted to reified triples.@Experimental public static Model convertRDFStarToReification(Model model)
@Experimental public static void convertReificationToRDFStar(ValueFactory vf, Model model, java.util.function.Consumer<Statement> consumer)
The supplied value factory is used to create all new statements.
vf - the ValueFactory to use for creating statements.model - the Model to convert.consumer - the Consumer function for the produced statements.@Experimental public static void convertReificationToRDFStar(Model model, java.util.function.Consumer<Statement> consumer)
@Experimental public static Model convertReificationToRDFStar(ValueFactory vf, Model model, ModelFactory modelFactory)
The supplied value factory is used to create all new statements.
vf - the ValueFactory to use for creating statements.model - the Model to convert.modelFactory - the ModelFactory to use for creating a new Model object for the output.Model with reification statements converted to RDF* Triples.@Experimental public static Model convertReificationToRDFStar(ValueFactory vf, Model model)
The supplied value factory is used to create all new statements.
vf - the ValueFactory to use for creating statements.model - the Model to convert.Model with reification statements converted to RDF* Triples.Copyright © 2015-2021 Eclipse Foundation. All Rights Reserved.