public class DefaultPersistentResource extends ResourceImpl implements PersistentResource
PersistentResource
that contains PersistentEObject
.
DefaultPersistentResource
s is backend-agnostic and only delegates model element operations
to its internal PersistentStore
which is responsible of database access.
ResourceImpl.ContentsEList<E extends Object & EObject>, ResourceImpl.ModificationTrackingAdapter
BasicNotifierImpl.EAdapterList<E extends Object & Adapter>, BasicNotifierImpl.EObservableAdapterList
Resource.Diagnostic, Resource.Factory, Resource.Internal, Resource.IOWrappedException
Modifier and Type | Field and Description |
---|---|
protected PersistenceBackend |
backend
The underlying
PersistenceBackend that stores the data. |
protected PersistentStore |
store
The
PersistentStore responsible of the database serialization. |
contents, defaultDeleteOptions, defaultLoadOptions, defaultSaveOptions, errors, intrinsicIDToEObjectMap, isLoaded, isLoading, isModified, modificationTrackingAdapter, resourceSet, timeStamp, unloadingContents, uri, warnings
eAdapters, EDELIVER, eFlags, ELAST_NOTIFIER_FLAG
OPTION_CIPHER, OPTION_LINE_DELIMITER, OPTION_LINE_DELIMITER_UNSPECIFIED, OPTION_SAVE_ONLY_IF_CHANGED, OPTION_SAVE_ONLY_IF_CHANGED_FILE_BUFFER, OPTION_SAVE_ONLY_IF_CHANGED_MEMORY_BUFFER, OPTION_ZIP, RESOURCE__CONTENTS, RESOURCE__ERRORS, RESOURCE__IS_LOADED, RESOURCE__IS_MODIFIED, RESOURCE__IS_TRACKING_MODIFICATION, RESOURCE__RESOURCE_SET, RESOURCE__TIME_STAMP, RESOURCE__URI, RESOURCE__WARNINGS
Constructor and Description |
---|
DefaultPersistentResource(URI uri)
Constructs a new
DefaultPersistentResource with the given uri . |
Modifier and Type | Method and Description |
---|---|
void |
close() |
protected void |
doUnload()
Does all the work of unloading the resource.
|
InternalEObject.EStore |
eStore()
Returns the
InternalEObject.EStore used to store the model. |
protected void |
finalize() |
EList<EObject> |
getAllInstances(EClass eClass)
Computes the set of instances of the given
EClass (including its sub-types). |
EList<EObject> |
getAllInstances(EClass eClass,
boolean strict)
Computes the set of instances of the given
EClass . |
EList<EObject> |
getContents()
Returns the list of the direct content objects;
each is of type
EObject . |
EObject |
getEObject(String uriFragment)
Returns the resolved object for the given URI
fragment . |
protected File |
getFile()
Returns the database file.
|
String |
getURIFragment(EObject eObject)
Returns the URI
fragment that,
when passed to getEObject will return the given object. |
void |
load(Map<?,?> options)
Loads the resource using the specified options.
|
void |
save(Map<?,?> options)
Saves the resource using the specified options.
|
addModificationTrackingAdapters, attached, attachedHelper, basicSetResourceSet, createModificationTrackingAdapter, delete, detached, detachedHelper, doLoad, doSave, getAllContents, getAllProperContents, getAllProperContents, getDefaultURIConverter, getEObject, getEObjectByID, getEObjectForURIFragmentRootSegment, getErrors, getIntrinsicIDToEObjectMap, getResourceSet, getTimeStamp, getUnloadingContents, getURI, getURIConverter, getURIFragmentRootSegment, getWarnings, handleLoadResponse, handleSaveResponse, isAttachedDetachedHelperRequired, isContentZipEntry, isLoaded, isLoading, isModified, isTrackingModification, load, mergeMaps, newContentZipEntry, removeModificationTrackingAdapters, save, saveOnlyIfChangedWithFileBuffer, saveOnlyIfChangedWithMemoryBuffer, setIntrinsicIDToEObjectMap, setLoaded, setModified, setTimeStamp, setTrackingModification, setURI, toKeyString, toString, unload, unloaded, useZip
eAdapters, eBasicAdapters, eDeliver, eSetDeliver
eBasicAdapterArray, eBasicHasAdapters, eNotificationRequired, eNotify
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
attached, basicSetResourceSet, detached, isLoading
delete, getAllContents, getErrors, getResourceSet, getTimeStamp, getURI, getWarnings, isLoaded, isModified, isTrackingModification, load, save, setModified, setTimeStamp, setTrackingModification, setURI, unload
eAdapters, eDeliver, eNotify, eSetDeliver
protected PersistentStore store
PersistentStore
responsible of the database serialization.protected PersistenceBackend backend
PersistenceBackend
that stores the data.protected File getFile()
public EList<EObject> getContents()
org.eclipse.emf.ecore.resource.Resource
EObject
.
The contents may be directly modified.
Removing an object will have the same effect as
EcoreUtil.remove(EObject)
.
Adding an object will remove it from the previous container;
it's container
will be null
and it's resource
will the this
.
getContents
in interface Resource
getContents
in class ResourceImpl
public String getURIFragment(EObject eObject)
org.eclipse.emf.ecore.resource.Resource
fragment
that,
when passed to getEObject
will return the given object.
In other words,
the following is true
for any object contained by a resource:
Resource resource = eObject.eResource(); eObject == resource.getEObject(resource.getURIFragment(eObject))An implementation may choose to use IDs or to use structured URI fragments, as supported by
eURIFragmentSegment
.
getURIFragment
in interface Resource
getURIFragment
in class ResourceImpl
eObject
- the object to identify.fragment
for the object.Resource.getEObject(String)
,
InternalEObject.eURIFragmentSegment(org.eclipse.emf.ecore.EStructuralFeature, EObject)
public EObject getEObject(String uriFragment)
org.eclipse.emf.ecore.resource.Resource
fragment
.
The fragment encoding will typically be that produced by getURIFragment
.
getEObject
in interface Resource
getEObject
in class ResourceImpl
uriFragment
- the fragment to resolve.null
if it can't be resolved.Resource.getURIFragment(EObject)
,
ResourceSet.getEObject(URI, boolean)
,
EcoreUtil.resolve(EObject, ResourceSet)
,
InternalEObject.eObjectForURIFragmentSegment(String)
public void save(Map<?,?> options) throws IOException
org.eclipse.emf.ecore.resource.Resource
Options are handled generically as feature-to-setting entries; the resource will ignore options it doesn't recognize. The options could even include things like an Eclipse progress monitor...
An implementation typically uses the URI converter
of the containing
resource set
to create
an output stream,
and then delegates to save(OutputStream, Map)
.
save
in interface Resource
save
in class ResourceImpl
options
- the save options.IOException
Resource.save(OutputStream, Map)
public void load(Map<?,?> options) throws IOException
org.eclipse.emf.ecore.resource.Resource
Options are handled generically as feature-to-setting entries; the resource will ignore options it doesn't recognize. The options could even include things like an Eclipse progress monitor...
An implementation typically uses the URI converter
of the containing
resource set
to create
an input stream,
and then delegates to load(InputStream, Map)
.
When the load completes, the errors
and warnings
can be consulted.
An implementation will typically deserialize as much of a document as possible
while producing diagnostics for any problems that are encountered.
load
in interface Resource
load
in class ResourceImpl
options
- the load options.IOException
Resource.load(InputStream, Map)
protected void doUnload()
org.eclipse.emf.ecore.resource.impl.ResourceImpl
unloaded
for each object it the content tree
,
and clears the contents
, errors
, and warnings
.doUnload
in class ResourceImpl
public void close()
close
in interface PersistentResource
close
in interface Closeable
close
in interface AutoCloseable
public InternalEObject.EStore eStore()
PersistentResource
InternalEObject.EStore
used to store the model.eStore
in interface PersistentResource
InternalEObject.EStore
public EList<EObject> getAllInstances(EClass eClass)
PersistentResource
EClass
(including its sub-types).
This method is similar to PersistentResource.getAllInstances(EClass, boolean)
with strict=false
.
getAllInstances
in interface PersistentResource
eClass
- the EClass
for which look for instancesEClass
from the resourcepublic EList<EObject> getAllInstances(EClass eClass, boolean strict)
PersistentResource
EClass
.getAllInstances
in interface PersistentResource
eClass
- the EClass
for which look for instancesstrict
- true if the lookup searches for strict instancestrue
then the method returns only the strict instances of the given EClass
, otherwise
it also returns the instances of the sub-types of eClass
.Copyright © 2013–2017 Atlanmod INRIA LINA Mines Nantes. All rights reserved.