Package org.eclipse.rdf4j.model.impl
Class DynamicModel
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractSet<Statement>
-
- org.eclipse.rdf4j.model.impl.DynamicModel
-
- All Implemented Interfaces:
Serializable
,Iterable<Statement>
,Collection<Statement>
,Set<Statement>
,Model
,NamespaceAware
public class DynamicModel extends AbstractSet<Statement> implements Model
A LinkedHashModel or a TreeModel achieves fast data access at the cost of higher indexing time. The DynamicModel postpones this cost until such access is actually needed. It stores all data in a LinkedHashMap and supports adding, retrieving and removing data. The model will upgrade to a full model (provided by the modelFactory) if more complex operations are called, for instance removing data according to a pattern (eg. all statements with rdf:type as predicate).DynamicModel is thread safe to the extent that the underlying LinkedHashMap or Model is. The upgrade path is protected by the actual upgrade method being synchronized. The LinkedHashMap storage is not removed once upgraded, so concurrent reads that have started reading from the LinkedHashMap can continue to read even during an upgrade. We do make the LinkedHashMap unmodifiable to reduce the chance of there being a bug.
- Author:
- HÃ¥vard Mikkelsen Ottestad
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description DynamicModel(ModelFactory modelFactory)
-
Method Summary
-
Methods inherited from class java.util.AbstractCollection
toString
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
-
Methods inherited from interface java.util.Set
spliterator
-
-
-
-
Constructor Detail
-
DynamicModel
public DynamicModel(ModelFactory modelFactory)
-
-
Method Detail
-
unmodifiable
public Model unmodifiable()
- Specified by:
unmodifiable
in interfaceModel
-
getNamespace
public Optional<Namespace> getNamespace(String prefix)
- Specified by:
getNamespace
in interfaceNamespaceAware
-
getNamespaces
public Set<Namespace> getNamespaces()
- Specified by:
getNamespaces
in interfaceNamespaceAware
-
setNamespace
public Namespace setNamespace(String prefix, String name)
- Specified by:
setNamespace
in interfaceModel
-
setNamespace
public void setNamespace(Namespace namespace)
- Specified by:
setNamespace
in interfaceModel
-
removeNamespace
public Optional<Namespace> removeNamespace(String prefix)
- Specified by:
removeNamespace
in interfaceModel
-
predicates
public Set<IRI> predicates()
- Specified by:
predicates
in interfaceModel
-
size
public int size()
- Specified by:
size
in interfaceCollection<Statement>
- Specified by:
size
in interfaceSet<Statement>
- Specified by:
size
in classAbstractCollection<Statement>
-
isEmpty
public boolean isEmpty()
- Specified by:
isEmpty
in interfaceCollection<Statement>
- Specified by:
isEmpty
in interfaceSet<Statement>
- Overrides:
isEmpty
in classAbstractCollection<Statement>
-
contains
public boolean contains(Object o)
- Specified by:
contains
in interfaceCollection<Statement>
- Specified by:
contains
in interfaceSet<Statement>
- Overrides:
contains
in classAbstractCollection<Statement>
-
toArray
public Object[] toArray()
- Specified by:
toArray
in interfaceCollection<Statement>
- Specified by:
toArray
in interfaceSet<Statement>
- Overrides:
toArray
in classAbstractCollection<Statement>
-
toArray
public <T> T[] toArray(T[] a)
- Specified by:
toArray
in interfaceCollection<Statement>
- Specified by:
toArray
in interfaceSet<Statement>
- Overrides:
toArray
in classAbstractCollection<Statement>
-
add
public boolean add(Statement statement)
- Specified by:
add
in interfaceCollection<Statement>
- Specified by:
add
in interfaceSet<Statement>
- Overrides:
add
in classAbstractCollection<Statement>
-
remove
public boolean remove(Object o)
- Specified by:
remove
in interfaceCollection<Statement>
- Specified by:
remove
in interfaceSet<Statement>
- Overrides:
remove
in classAbstractCollection<Statement>
-
containsAll
public boolean containsAll(Collection<?> c)
- Specified by:
containsAll
in interfaceCollection<Statement>
- Specified by:
containsAll
in interfaceSet<Statement>
- Overrides:
containsAll
in classAbstractCollection<Statement>
-
addAll
public boolean addAll(Collection<? extends Statement> c)
- Specified by:
addAll
in interfaceCollection<Statement>
- Specified by:
addAll
in interfaceSet<Statement>
- Overrides:
addAll
in classAbstractCollection<Statement>
-
retainAll
public boolean retainAll(Collection<?> c)
- Specified by:
retainAll
in interfaceCollection<Statement>
- Specified by:
retainAll
in interfaceSet<Statement>
- Overrides:
retainAll
in classAbstractCollection<Statement>
-
removeAll
public boolean removeAll(Collection<?> c)
- Specified by:
removeAll
in interfaceCollection<Statement>
- Specified by:
removeAll
in interfaceSet<Statement>
- Overrides:
removeAll
in classAbstractSet<Statement>
-
clear
public void clear()
- Specified by:
clear
in interfaceCollection<Statement>
- Specified by:
clear
in interfaceSet<Statement>
- Overrides:
clear
in classAbstractCollection<Statement>
-
getStatements
public Iterable<Statement> getStatements(Resource subject, IRI predicate, Value object, Resource... contexts)
- Specified by:
getStatements
in interfaceModel
-
equals
public boolean equals(Object o)
- Specified by:
equals
in interfaceCollection<Statement>
- Specified by:
equals
in interfaceSet<Statement>
- Overrides:
equals
in classAbstractSet<Statement>
-
hashCode
public int hashCode()
- Specified by:
hashCode
in interfaceCollection<Statement>
- Specified by:
hashCode
in interfaceSet<Statement>
- Overrides:
hashCode
in classAbstractSet<Statement>
-
-