public class DynamicModel extends AbstractSet<Statement> implements Model
Constructor and Description |
---|
DynamicModel(ModelFactory modelFactory) |
Modifier and Type | Method and Description |
---|---|
boolean |
add(Resource subj,
IRI pred,
Value obj,
Resource... contexts)
Adds one or more statements to the model.
|
boolean |
add(Statement statement) |
boolean |
addAll(Collection<? extends Statement> c) |
void |
clear() |
boolean |
clear(Resource... context)
Removes statements with the specified context exist in this model.
|
boolean |
contains(Object o) |
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.
|
boolean |
containsAll(Collection<?> c) |
Set<Resource> |
contexts()
Returns a
Set view of the contexts contained in this model. |
boolean |
equals(Object o) |
Model |
filter(Resource subj,
IRI pred,
Value obj,
Resource... contexts)
Returns a filtered view of the statements with the specified subject, predicate, object and (optionally) context.
|
Optional<Namespace> |
getNamespace(String prefix)
Gets the namespace that is associated with the specified prefix, if any.
|
Set<Namespace> |
getNamespaces()
Gets the set that contains the assigned namespaces.
|
Iterable<Statement> |
getStatements(Resource subject,
IRI predicate,
Value object,
Resource... contexts)
|
int |
hashCode() |
boolean |
isEmpty() |
Iterator<Statement> |
iterator() |
Set<Value> |
objects()
Returns a
Set view of the objects contained in this model. |
Set<IRI> |
predicates()
Returns a
Set view of the predicates contained in this model. |
boolean |
remove(Object o) |
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.
|
boolean |
removeAll(Collection<?> c) |
Optional<Namespace> |
removeNamespace(String prefix)
Removes a namespace declaration by removing the association between a prefix and a namespace name.
|
boolean |
retainAll(Collection<?> c) |
void |
setNamespace(Namespace namespace)
Sets the prefix for a namespace.
|
Namespace |
setNamespace(String prefix,
String name)
Sets the prefix for a namespace.
|
int |
size() |
Set<Resource> |
subjects()
Returns a
Set view of the subjects contained in this model. |
Object[] |
toArray() |
<T> T[] |
toArray(T[] a) |
Model |
unmodifiable()
Returns an unmodifiable view of this model.
|
toString
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
spliterator
parallelStream, removeIf, stream
public DynamicModel(ModelFactory modelFactory)
public Model unmodifiable()
Model
UnsupportedOperationException
.
unmodifiable
in interface Model
public Optional<Namespace> getNamespace(String prefix)
NamespaceAware
getNamespace
in interface NamespaceAware
prefix
- A namespace prefix.Optional.empty()
if there is
no such namespace.public Set<Namespace> getNamespaces()
NamespaceAware
getNamespaces
in interface NamespaceAware
Set
containing the Namespace
objects that are available.public Namespace setNamespace(String prefix, String name)
Model
setNamespace
in interface Model
prefix
- The new prefix.name
- The namespace name that the prefix maps to.Namespace
object for the given namespace.public void setNamespace(Namespace namespace)
Model
setNamespace
in interface Model
namespace
- A Namespace
object to use in this Model.public Optional<Namespace> removeNamespace(String prefix)
Model
removeNamespace
in interface Model
prefix
- The namespace prefix of which the assocation with a namespace name is to be removed.Optional.empty()
public boolean contains(Resource subj, IRI pred, Value obj, Resource... contexts)
Model
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
.
contains
in interface Model
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.public boolean add(Resource subj, IRI pred, Value obj, Resource... contexts)
Model
public boolean clear(Resource... context)
Model
public boolean remove(Resource subj, IRI pred, Value obj, Resource... contexts)
Model
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
.
remove
in interface Model
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.public Model filter(Resource subj, IRI pred, Value obj, Resource... contexts)
Model
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
.
filter
in interface Model
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.Model.getStatements(Resource, IRI, Value, Resource...)
public Set<Resource> subjects()
Model
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.public Set<IRI> predicates()
Model
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.predicates
in interface Model
public Set<Value> objects()
Model
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.public Set<Resource> contexts()
Model
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.public int size()
size
in interface Collection<Statement>
size
in interface Set<Statement>
size
in class AbstractCollection<Statement>
public boolean isEmpty()
isEmpty
in interface Collection<Statement>
isEmpty
in interface Set<Statement>
isEmpty
in class AbstractCollection<Statement>
public boolean contains(Object o)
contains
in interface Collection<Statement>
contains
in interface Set<Statement>
contains
in class AbstractCollection<Statement>
public Object[] toArray()
toArray
in interface Collection<Statement>
toArray
in interface Set<Statement>
toArray
in class AbstractCollection<Statement>
public <T> T[] toArray(T[] a)
toArray
in interface Collection<Statement>
toArray
in interface Set<Statement>
toArray
in class AbstractCollection<Statement>
public boolean add(Statement statement)
add
in interface Collection<Statement>
add
in interface Set<Statement>
add
in class AbstractCollection<Statement>
public boolean remove(Object o)
remove
in interface Collection<Statement>
remove
in interface Set<Statement>
remove
in class AbstractCollection<Statement>
public boolean containsAll(Collection<?> c)
containsAll
in interface Collection<Statement>
containsAll
in interface Set<Statement>
containsAll
in class AbstractCollection<Statement>
public boolean addAll(Collection<? extends Statement> c)
addAll
in interface Collection<Statement>
addAll
in interface Set<Statement>
addAll
in class AbstractCollection<Statement>
public boolean retainAll(Collection<?> c)
retainAll
in interface Collection<Statement>
retainAll
in interface Set<Statement>
retainAll
in class AbstractCollection<Statement>
public boolean removeAll(Collection<?> c)
removeAll
in interface Collection<Statement>
removeAll
in interface Set<Statement>
removeAll
in class AbstractSet<Statement>
public void clear()
clear
in interface Collection<Statement>
clear
in interface Set<Statement>
clear
in class AbstractCollection<Statement>
public Iterable<Statement> getStatements(Resource subject, IRI predicate, Value object, Resource... contexts)
Model
Iterable
over all Statement
s in this Model that match the supplied criteria.
Examples:
model.getStatements(s1, null, null)
matches all statements that have subject s1
model.getStatements(s1, p1, null)
matches all statements that have subject s1
and predicate
p1
model.getStatements(null, null, null, c1)
matches all statements that have context c1
model.getStatements(null, null, null, (Resource)null)
matches all statements that have no associated
contextmodel.getStatements(null, null, null, c1, c2, c3)
matches all statements that have context
c1
, c2
or c3
getStatements
in interface Model
subject
- The subject of the statements to match, null
to match statements with any subject.predicate
- The predicate of the statements to match, null
to match statements with any predicate.object
- 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 any one of these will match. To match statements without an associated context, specify
the value null
and explicitly cast it to type Resource
.Iterable
over the statements in this Model that match the specified pattern.Model.filter(Resource, IRI, Value, Resource...)
public boolean equals(Object o)
equals
in interface Collection<Statement>
equals
in interface Set<Statement>
equals
in class AbstractSet<Statement>
public int hashCode()
hashCode
in interface Collection<Statement>
hashCode
in interface Set<Statement>
hashCode
in class AbstractSet<Statement>
Copyright © 2015-2020 Eclipse Foundation. All Rights Reserved.