public class MapDbPersistenceBackend extends AbstractPersistenceBackend
PersistenceBackend
that is responsible of low-level access to a MapDB database.
It wraps an existing DB
and provides facilities to create and retrieve elements. This class manages a set of
Map
s used to represent model elements:
EStructuralFeature
links between elements DirectWriteMapDbIndicesStore
that stores Collection
indices instead of a
serialized version of the collection itself
This class is used in DirectWriteMapDbStore
and its subclasses to access and manipulate the database.
Instances of MapDbPersistenceBackend
are created by MapDbPersistenceBackendFactory
that provides an
usable DB
that can be manipulated by this wrapper.
Modifier and Type | Field and Description |
---|---|
static String |
NAME
The literal description of this back-end.
|
Modifier | Constructor and Description |
---|---|
protected |
MapDbPersistenceBackend(DB db)
Constructs a new
MapDbPersistenceBackend wrapping the provided db . |
Modifier and Type | Method and Description |
---|---|
void |
close()
In our case, it cleanly stops the underlying database.
|
ContainerInfo |
containerFor(Id id)
Retrieves container for a given object
Id . |
void |
copyTo(MapDbPersistenceBackend target)
Copies all the contents of this this back-end to the target one.
|
<E> E |
get(String name)
???
|
Map<String,Object> |
getAll()
Return all the
Collection s contained in the database. |
boolean |
isClosed()
Returns whether the underlying database is closed.
|
boolean |
isFeatureSet(FeatureKey key)
Checks if the given
FeatureKey is set. |
ClassInfo |
metaclassFor(Id id)
|
Object |
removeFeature(FeatureKey key)
Removes the value of a given
FeatureKey from the database, and unset it (isFeatureSet(FeatureKey) ). |
void |
save()
Saves the modifications of the owned
EObject s in the underlying database. |
void |
storeContainer(Id id,
ContainerInfo container)
Stores container information for a given id in the Container Map.
|
void |
storeMetaclass(Id id,
ClassInfo metaclass)
|
Object |
storeValue(FeatureKey key,
Object value)
Stores the value of a given
FeatureKey . |
Object |
storeValueAtIndex(MultivaluedFeatureKey key,
Object value)
Stores the value of a given
MultivaluedFeatureKey . |
Object |
valueAtIndex(MultivaluedFeatureKey key)
Retrieves the value of a given
MultivaluedFeatureKey . |
Object |
valueOf(FeatureKey key)
Retrieves the value of a given
FeatureKey . |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getAllInstances
public static final String NAME
protected MapDbPersistenceBackend(DB db)
MapDbPersistenceBackend
wrapping the provided db
.
This constructor initialize the different Map
s from the MapDB engine and set their respective
Serializer
s.
This constructor is protected. To create a new MapDbPersistenceBackend
use MapDbPersistenceBackendFactory.createPersistentBackend(java.io.File, Map)
.
db
- the DB
used to creates the used Map
s and manage the databaseMapDbPersistenceBackendFactory
public boolean isClosed()
PersistenceBackend
true
if the database is closed, otherwise false
public void close()
PersistenceBackend
In our case, it cleanly stops the underlying database.
public void save()
PersistenceBackend
EObject
s in the underlying database.public Map<String,Object> getAll()
Collection
s contained in the database.Map
containing all the Collection
s contained in the database and their associated namespublic <E> E get(String name)
E
- ???name
- ???public ContainerInfo containerFor(Id id)
Id
.id
- the Id
of the contained objectContainerInfo
descriptor that contains element's container informationpublic void storeContainer(Id id, ContainerInfo container)
id
- the Id
of the contained elementcontainer
- the ContainerInfo
descriptor containing element's container information to storepublic Object storeValue(FeatureKey key, Object value)
FeatureKey
.key
- the FeatureKey
to set the value ofvalue
- an Object
representing the value associated to the given key
public Object valueOf(FeatureKey key)
FeatureKey
.key
- the FeatureKey
to look forObject
representing the value associated to the given key
, null
if it is not
in the databasepublic Object removeFeature(FeatureKey key)
FeatureKey
from the database, and unset it (isFeatureSet(FeatureKey)
).key
- the FeatureKey
to removeObject
representing the removed value, null
if it hasn't been foundpublic boolean isFeatureSet(FeatureKey key)
FeatureKey
is set.key
- the FeatureKey
to checktrue
if the feature is set, false
otherwisepublic Object storeValueAtIndex(MultivaluedFeatureKey key, Object value)
MultivaluedFeatureKey
.
This method is similar to storeValue(FeatureKey, Object)
but it uses the multi-valued Map
that
stores indices explicitly.
key
- the MultivaluedFeatureKey
to set the value ofvalue
- an Object
representing the value associated to the given key
DirectWriteMapDbIndicesStore
public Object valueAtIndex(MultivaluedFeatureKey key)
MultivaluedFeatureKey
.
This method is similar to valueOf(FeatureKey)
but it uses multi-valued Map
to retrieve the
element at the given index directly instead of returning the entire Collection
.
key
- the MultivaluedFeatureKey
to get the value fromObject
representing the value associated to the given key
DirectWriteMapDbIndicesStore
public void copyTo(MapDbPersistenceBackend target)
target
- the MapDbPersistenceBackend
to copy the database contents toUnsupportedOperationException
- if the current DB
contains Collection
s which are not Map
sCopyright © 2013–2017 Atlanmod INRIA LINA Mines Nantes. All rights reserved.