public class TreeModel extends AbstractModel implements SortedSet<Statement>
Model
implementation. The model is sorted
according to the lexical ordering of terms.
This implementation provides guaranteed log(n) time cost for filtered access
by any number of terms. If an index is not yet available for a set of
positions, it is created at runtime using a TreeSet
.
Note that this implementation is not synchronized. If multiple threads access a model concurrently, and at least one of the threads modifies the model, it must be synchronized externally. This is typically accomplished by synchronizing on some object that naturally encapsulates the model. If no such object exists, the set should be "wrapped" using the Collections.synchronizedSet method. This is best done at creation time, to prevent accidental unsynchronized access to the LinkedHashModel instance (though the synchronization guarantee is only when accessing via the Set interface methods):
Constructor and Description |
---|
TreeModel() |
TreeModel(Collection<? extends Statement> c) |
TreeModel(Model model) |
TreeModel(Set<Namespace> namespaces) |
TreeModel(Set<Namespace> namespaces,
Collection<? extends Statement> c) |
Modifier and Type | Method and Description |
---|---|
boolean |
add(Resource subj,
URI pred,
Value obj,
Resource... contexts)
Adds one or more statements to the model.
|
Statement |
ceiling(Statement e) |
void |
clear() |
Comparator<? super Statement> |
comparator() |
boolean |
contains(Resource subj,
URI pred,
Value obj,
Resource... contexts)
Determines if statements with the specified subject, predicate, object and
(optionally) context exist in this model.
|
Model |
filter(Resource subj,
URI pred,
Value obj,
Resource... contexts)
Returns a view of the statements with the specified subject, predicate,
object and (optionally) context.
|
Statement |
first() |
Statement |
floor(Statement e) |
Namespace |
getNamespace(String prefix)
Gets the namespace that is associated with the specified prefix, if any.
|
Set<Namespace> |
getNamespaces()
Gets the map that contains the assigned namespaces.
|
SortedSet<Statement> |
headSet(Statement toElement) |
Statement |
higher(Statement e) |
Iterator<Statement> |
iterator() |
Statement |
last() |
Statement |
lower(Statement e) |
Statement |
pollFirst() |
Statement |
pollLast() |
boolean |
remove(Resource subj,
URI pred,
Value obj,
Resource... contexts)
Removes statements with the specified subject, predicate, object and
(optionally) context exist in this model.
|
Namespace |
removeNamespace(String prefix)
Removes a namespace declaration by removing the association between a
prefix and a namespace name.
|
void |
removeTermIteration(Iterator<Statement> iterator,
Resource subj,
URI pred,
Value obj,
Resource... contexts)
Called by aggregate sets when a term has been removed from a term
iterator.
|
void |
setNamespace(Namespace namespace)
Sets the prefix for a namespace.
|
Namespace |
setNamespace(String prefix,
String name)
Sets the prefix for a namespace.
|
int |
size() |
SortedSet<Statement> |
subSet(Statement fromElement,
Statement toElement) |
SortedSet<Statement> |
tailSet(Statement fromElement) |
add, addAll, clear, closeIterator, contains, containsAll, contexts, equals, getValueFactory, hashCode, isEmpty, match, objectLiteral, objectResource, objects, objectString, objectURI, objectValue, predicates, remove, removeAll, retainAll, subjectBNode, subjectResource, subjects, subjectURI, toArray, toArray, unmodifiable
toString
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
spliterator
add, addAll, contains, containsAll, equals, hashCode, isEmpty, remove, removeAll, retainAll, toArray, toArray
parallelStream, removeIf, stream
public TreeModel()
public TreeModel(Model model)
public TreeModel(Collection<? extends Statement> c)
public TreeModel(Set<Namespace> namespaces, Collection<? extends Statement> c)
public Namespace getNamespace(String prefix)
Model
getNamespace
in interface Model
prefix
- A namespace prefix.public Set<Namespace> getNamespaces()
Model
getNamespaces
in interface Model
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 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.public int size()
size
in interface Collection<Statement>
size
in interface Set<Statement>
size
in class AbstractCollection<Statement>
public void clear()
clear
in interface Collection<Statement>
clear
in interface Set<Statement>
clear
in class AbstractModel
public Comparator<? super Statement> comparator()
comparator
in interface SortedSet<Statement>
public Statement pollFirst()
public Statement pollLast()
public boolean add(Resource subj, URI pred, Value obj, Resource... contexts)
Model
public boolean contains(Resource subj, URI pred, Value obj, Resource... contexts)
Model
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 remove(Resource subj, URI pred, Value obj, Resource... contexts)
Model
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, URI pred, Value obj, Resource... contexts)
Model
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.public void removeTermIteration(Iterator<Statement> iterator, Resource subj, URI pred, Value obj, Resource... contexts)
AbstractModel
removeTermIteration
in class AbstractModel
iterator
- The iterator used to navigate the live set (never null)subj
- the subject term to be removed or nullpred
- the predicate term to be removed or nullobj
- the object term to be removed or nullcontexts
- an array of one context term to be removed or an empty arrayCopyright © 2001-2016 Aduna. All Rights Reserved.