public interface Model extends Graph, Set<Statement>, Serializable, NamespaceAware
Set of Statements with predictable iteration
order.
Additional utility functionality for working with Model objects is available in the
Models utility class.
the Models utility class| Modifier and Type | Method and Description |
|---|---|
boolean |
add(Resource subj,
IRI pred,
Value obj,
Resource... contexts)
Adds one or more statements to the model.
|
default boolean |
add(Resource subj,
URI pred,
Value obj,
Resource... contexts)
Deprecated.
since 4.0. Use
add(Resource, IRI, Value, Resource...) instead. |
boolean |
clear(Resource... context)
Removes statements with the specified context exist in this model.
|
boolean |
contains(Resource subj,
IRI pred,
Value obj,
Resource... contexts)
Determines if statements with the specified subject, predicate, object and (optionally) context exist
in this model.
|
default boolean |
contains(Resource subj,
URI pred,
Value obj,
Resource... contexts)
Deprecated.
since 4.0. Use
contains(Resource, IRI, Value, Resource...) instead. |
default Set<Resource> |
contexts()
Returns a
Set view of the contexts contained in this model. |
Model |
filter(Resource subj,
IRI pred,
Value obj,
Resource... contexts)
Returns a view of the statements with the specified subject, predicate, object and (optionally)
context.
|
default Model |
filter(Resource subj,
URI pred,
Value obj,
Resource... contexts)
Deprecated.
|
default Optional<IRI> |
objectIRI()
Deprecated.
since 4.0. Instead, use
Models#objectURI(Model) to retrieve an object URI value,
and/or use the size of the set returned by objects() to verify if the object is
unique. |
default Optional<Literal> |
objectLiteral()
Deprecated.
since 4.0. Instead, use
Models.objectLiteral(Model) to retrieve an object Literal
value, and/or use the size of the set returned by objects() to verify if the
object is unique. |
default Optional<Resource> |
objectResource()
Deprecated.
since 4.0. Instead, use
Models.objectResource(Model) to retrieve an object Resource
value, and/or use the size of the set returned by objects() to verify if the
object is unique. |
Set<Value> |
objects()
Returns a
Set view of the objects contained in this model. |
default Optional<String> |
objectString()
Deprecated.
since 4.0. Instead, use
Models.objectString(Model) to retrieve an object string
value, and/or use the size of the set returned by objects() to verify if the
object is unique. |
default Optional<IRI> |
objectURI()
Deprecated.
use
objectIRI() instead. |
default Optional<Value> |
objectValue()
Deprecated.
since 4.0. Instead, use
Models.object(Model) to retrieve an object value, and/or
use the size of the set returned by objects() to verify if the object is unique. |
Set<IRI> |
predicates()
Returns a
Set view of the predicates contained in this model. |
boolean |
remove(Resource subj,
IRI pred,
Value obj,
Resource... contexts)
Removes statements with the specified subject, predicate, object and (optionally) context exist in this
model.
|
default boolean |
remove(Resource subj,
URI pred,
Value obj,
Resource... contexts)
Deprecated.
since 4.0. Use
remove(Resource, IRI, Value, Resource...) instead. |
Optional<Namespace> |
removeNamespace(String prefix)
Removes a namespace declaration by removing the association between a prefix and a namespace name.
|
void |
setNamespace(Namespace namespace)
Sets the prefix for a namespace.
|
default Namespace |
setNamespace(String prefix,
String name)
Sets the prefix for a namespace.
|
default Optional<BNode> |
subjectBNode()
Deprecated.
since 4.0. Instead, use
Models.subjectBNode(Model) to retrieve a subject BNode,
and/or use the size of the set returned by subjects() to verify if the subject is
unique. |
default Optional<IRI> |
subjectIRI()
Deprecated.
since 4.0. Instead, use
Models#subjectURI(Model) to retrieve a subject URI, and/or
use the size of the set returned by subjects() to verify if the subject is unique. |
default Optional<Resource> |
subjectResource()
Deprecated.
since 4.0. Instead, use
Models.subject(Model) to retrieve a subject Resource,
and/or use the size of the set returned by subjects() to verify if the subject is
unique. |
Set<Resource> |
subjects()
Returns a
Set view of the subjects contained in this model. |
default Optional<IRI> |
subjectURI()
Deprecated.
use
subjectIRI() instead. |
Model |
unmodifiable()
Returns an unmodifiable view of this model.
|
getValueFactory, matchadd, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, spliterator, toArray, toArrayparallelStream, removeIf, streamgetNamespace, getNamespacesModel unmodifiable()
UnsupportedOperationException.
default Namespace setNamespace(String prefix, String name)
prefix - The new prefix.name - The namespace name that the prefix maps to.Namespace object for the given namespace.void setNamespace(Namespace namespace)
namespace - A Namespace object to use in this Model.Optional<Namespace> removeNamespace(String prefix)
prefix - The namespace prefix of which the assocation with a namespace name is to be removed.Optional.empty()boolean contains(Resource subj, IRI pred, Value obj, Resource... contexts)
subject, predicate and object parameters can be null
to indicate wildcards. The contexts parameter is a wildcard and accepts zero or more values. If
no contexts are specified, statements will match disregarding their context. If one or more contexts
are specified, statements with a context matching one of these will match. Note: to match statements
without an associated context, specify the value null and explicitly cast it to type
Resource.
Examples: model.contains(s1, null, null) is true if any statements in this model have subject
s1,
model.contains(null, null, null, c1) is true if any statements in this model have context
c1,
model.contains(null, null, null, (Resource)null) is true if any statements in this model have
no associated context,
model.contains(null, null, null, c1, c2, c3) is true if any statements in this model have
context c1, c2 or c3 .
subj - The subject of the statements to match, null to match statements with any subject.pred - The predicate of the statements to match, null to match statements with any predicate.obj - The object of the statements to match, null to match statements with any object.contexts - The contexts of the statements to match. If no contexts are specified, statements will match
disregarding their context. If one or more contexts are specified, statements with a context
matching one of these will match.true if statements match the specified pattern.@Deprecated default boolean contains(Resource subj, URI pred, Value obj, Resource... contexts)
contains(Resource, IRI, Value, Resource...) instead.boolean add(Resource subj, IRI pred, Value obj, Resource... contexts)
add in interface Graphsubj - The statement's subject.pred - The statement's predicate.obj - The statement's object.contexts - The contexts to add statements to.IllegalArgumentException - If This Model cannot store the given statement, because it is filtered out of this view.UnsupportedOperationException - If this Model cannot accept any statements, because it is filtered to the empty set.@Deprecated default boolean add(Resource subj, URI pred, Value obj, Resource... contexts)
add(Resource, IRI, Value, Resource...) instead.boolean clear(Resource... context)
context - The context of the statements to remove.true if one or more statements have been removed.boolean remove(Resource subj, IRI pred, Value obj, Resource... contexts)
subject, predicate and object parameters can be null to
indicate wildcards. The contexts parameter is a wildcard and accepts zero or more values. If no
contexts are specified, statements will be removed disregarding their context. If one or more contexts
are specified, statements with a context matching one of these will be removed. Note: to remove
statements without an associated context, specify the value null and explicitly cast it to type
Resource.
Examples: model.remove(s1, null, null) removes any statements in this model have subject
s1,
model.remove(null, null, null, c1) removes any statements in this model have context c1
,
model.remove(null, null, null, (Resource)null) removes any statements in this model have no
associated context,
model.remove(null, null, null, c1, c2, c3) removes any statements in this model have context
c1, c2 or c3.
subj - The subject of the statements to remove, null to remove statements with any subject.pred - The predicate of the statements to remove, null to remove statements with any predicate.obj - The object of the statements to remove, null to remove statements with any object.contexts - The contexts of the statements to remove. If no contexts are specified, statements will be
removed disregarding their context. If one or more contexts are specified, statements with a
context matching one of these will be removed.true if one or more statements have been removed.@Deprecated default boolean remove(Resource subj, URI pred, Value obj, Resource... contexts)
remove(Resource, IRI, Value, Resource...) instead.Model filter(Resource subj, IRI pred, Value obj, Resource... contexts)
subject, predicate and object parameters can be null to
indicate wildcards. The contexts parameter is a wildcard and accepts zero or more values. If no
contexts are specified, statements will match disregarding their context. If one or more contexts are
specified, statements with a context matching one of these will match. Note: to match statements
without an associated context, specify the value null and explicitly cast it to type
Resource.
The returned model is backed by this Model, so changes to this Model are reflected in the returned
model, and vice-versa. If this Model is modified while an iteration over the returned model is in
progress (except through the iterator's own remove operation), the results of the iteration are
undefined. The model supports element removal, which removes the corresponding statement from this
Model, via the Iterator.remove, Set.remove, removeAll, retainAll, and
clear operations. The statements passed to the add and addAll operations must
match the parameter pattern.
Examples: model.filter(s1, null, null) matches all statements that have subject s1,
model.filter(null, null, null, c1) matches all statements that have context c1,
model.filter(null, null, null, (Resource)null) matches all statements that have no associated
context,
model.filter(null, null, null, c1, c2, c3) matches all statements that have context c1,
c2 or c3.
subj - The subject of the statements to match, null to match statements with any subject.pred - The predicate of the statements to match, null to match statements with any predicate.obj - The object of the statements to match, null to match statements with any object.contexts - The contexts of the statements to match. If no contexts are specified, statements will match
disregarding their context. If one or more contexts are specified, statements with a context
matching one of these will match.@Deprecated default Model filter(Resource subj, URI pred, Value obj, Resource... contexts)
Set<Resource> subjects()
Set view of the subjects contained in this model. The set is backed by the model, so
changes to the model are reflected in the set, and vice-versa. If the model is modified while an
iteration over the set is in progress (except through the iterator's own remove operation), the
results of the iteration are undefined. The set supports element removal, which removes all statements
from the model for which that element is a subject value, via the Iterator.remove,
Set.remove, removeAll, retainAll, and clear operations. It does not
support the add or addAll operations if the parameters pred or obj are
null.@Deprecated default Optional<Resource> subjectResource() throws ModelException
Models.subject(Model) to retrieve a subject Resource,
and/or use the size of the set returned by subjects() to verify if the subject is
unique.ModelException is thrown if this is not the case.Optional.empty() if no matching statements
were found.ModelException - If the statements matched by the specified parameters have more than one unique subject.@Deprecated default Optional<IRI> subjectIRI() throws ModelException
Models#subjectURI(Model) to retrieve a subject URI, and/or
use the size of the set returned by subjects() to verify if the subject is unique.subjectResource() to a IRI, or throws a
ModelException if that value is not an IRI.null if no matching statements were found.ModelException - If such an exception is thrown by subjectResource() or if its return value is not a
IRI.@Deprecated default Optional<IRI> subjectURI() throws ModelException
subjectIRI() instead.subjectIRI() instead.ModelException@Deprecated default Optional<BNode> subjectBNode() throws ModelException
Models.subjectBNode(Model) to retrieve a subject BNode,
and/or use the size of the set returned by subjects() to verify if the subject is
unique.subjectResource() to a BNode, or throws a
ModelException if that value is not a BNode.null if no matching statements were found.ModelException - If such an exception is thrown by subjectResource() or if its return value is not a
BNode.Set<IRI> predicates()
Set view of the predicates contained in this model. The set is backed by the model,
so changes to the model are reflected in the set, and vice-versa. If the model is modified while an
iteration over the set is in progress (except through the iterator's own remove operation), the
results of the iteration are undefined. The set supports element removal, which removes all statements
from the model for which that element is a predicate value, via the Iterator.remove,
Set.remove, removeAll, retainAll, and clear operations. It does not
support the add or addAll operations if the parameters subj or obj are
null.Set<Value> objects()
Set view of the objects contained in this model. The set is backed by the model, so
changes to the model are reflected in the set, and vice-versa. If the model is modified while an
iteration over the set is in progress (except through the iterator's own remove operation), the
results of the iteration are undefined. The set supports element removal, which removes all statements
from the model for which that element is an object value, via the Iterator.remove,
Set.remove, removeAll, retainAll, and clear operations. It does not
support the add or addAll operations if the parameters subj or pred are
null.default Set<Resource> contexts()
Set view of the contexts contained in this model. The set is backed by the model, so
changes to the model are reflected in the set, and vice-versa. If the model is modified while an
iteration over the set is in progress (except through the iterator's own remove operation), the
results of the iteration are undefined. The set supports element removal, which removes all statements
from the model for which that element is a context value, via the Iterator.remove,
Set.remove, removeAll, retainAll, and clear operations. It does not
support the add or addAll operations if the parameters subj , pred or
obj are null.@Deprecated default Optional<Value> objectValue() throws ModelException
Models.object(Model) to retrieve an object value, and/or
use the size of the set returned by objects() to verify if the object is unique.ModelException is thrown if this is not the case.Optional.empty() if no matching statements
were found.ModelException - If the statements matched by the specified parameters have more than one unique object.@Deprecated default Optional<Literal> objectLiteral() throws ModelException
Models.objectLiteral(Model) to retrieve an object Literal
value, and/or use the size of the set returned by objects() to verify if the
object is unique.objectValue() to a Literal, or throws a
ModelUtilException if that value is not a Literal.Optional.empty() if no matching statements
were found.ModelException - If such an exception is thrown by objectValue() or if its return value is not a
Literal.@Deprecated default Optional<Resource> objectResource() throws ModelException
Models.objectResource(Model) to retrieve an object Resource
value, and/or use the size of the set returned by objects() to verify if the
object is unique.objectValue() to a Resource, or throws a
ModelUtilException if that value is not a Resource.Optional.empty() if no matching statements
were found.ModelException - If such an exception is thrown by objectValue() or if its return value is not a
Resource.@Deprecated default Optional<IRI> objectIRI() throws ModelException
Models#objectURI(Model) to retrieve an object URI value,
and/or use the size of the set returned by objects() to verify if the object is
unique.objectValue() to an IRI, or throws a
ModelUtilException if that value is not an IRI.Optional.empty() if no matching statements
were found.ModelException - If such an exception is thrown by objectValue() or if its return value is not an IRI.@Deprecated default Optional<IRI> objectURI() throws ModelException
objectIRI() instead.objectIRI() instead.ModelException@Deprecated default Optional<String> objectString() throws ModelException
Models.objectString(Model) to retrieve an object string
value, and/or use the size of the set returned by objects() to verify if the
object is unique.objectValue().Optional.empty() if no matching
statements were found.ModelException - If the statements matched by the specified parameters have more than one unique object.Copyright © 2015-2019 Eclipse Foundation. All Rights Reserved.