org.eclipse.emf.ecore.resource.impl
Class ResourceImpl

java.lang.Object
  extended by org.eclipse.emf.common.notify.impl.BasicNotifierImpl
      extended by org.eclipse.emf.common.notify.impl.NotifierImpl
          extended by org.eclipse.emf.ecore.resource.impl.ResourceImpl
All Implemented Interfaces:
Notifier, Resource, Resource.Internal
Direct Known Subclasses:
BinaryResourceImpl, XMLResourceImpl, XMLTypeResourceImpl

public class ResourceImpl
extends NotifierImpl
implements Resource, Resource.Internal

A highly extensible resource implementation.

The following configuration and control mechanisms are provided:


Nested Class Summary
protected  class ResourceImpl.ContentsEList<E extends java.lang.Object & EObject>
          A notifying list implementation for supporting Resource.getContents().
protected  class ResourceImpl.ModificationTrackingAdapter
          An adapter implementation for tracking resource modification.
 
Nested classes/interfaces inherited from class org.eclipse.emf.common.notify.impl.BasicNotifierImpl
BasicNotifierImpl.EAdapterList<E extends java.lang.Object & Adapter>
 
Field Summary
protected  ResourceImpl.ContentsEList<EObject> contents
          The contents.
protected  java.util.Map<java.lang.Object,java.lang.Object> defaultDeleteOptions
          The storage for the default delete options.
protected  java.util.Map<java.lang.Object,java.lang.Object> defaultLoadOptions
          The storage for the default load options.
protected  java.util.Map<java.lang.Object,java.lang.Object> defaultSaveOptions
          The storage for the default save options.
protected  EList<Resource.Diagnostic> errors
          The errors.
protected  java.util.Map<java.lang.String,EObject> intrinsicIDToEObjectMap
          A map to retrieve the EObject based on the value of its ID feature.
protected  boolean isLoaded
          The loaded flag.
protected  boolean isLoading
          The loading flag.
protected  boolean isModified
          The modified flag.
protected  Adapter modificationTrackingAdapter
          The modification tracking adapter.
protected  ResourceSet resourceSet
          The containing resource set.
protected  long timeStamp
          The time stamp.
protected  java.util.List<EObject> unloadingContents
          A copy of the contents list while the contents are being unloaded.
protected  URI uri
          The URI.
protected  EList<Resource.Diagnostic> warnings
          The warnings.
 
Fields inherited from class org.eclipse.emf.common.notify.impl.NotifierImpl
eAdapters, EDELIVER, eFlags, ELAST_NOTIFIER_FLAG
 
Constructor Summary
ResourceImpl()
          Creates a empty instance.
ResourceImpl(URI uri)
          Creates an instance with the given URI.
 
Method Summary
protected  void addModificationTrackingAdapters(EObject eObject)
          Deprecated. since 2.1.0. This method is not invoked anymore. See attachedHelper(EObject).
 void attached(EObject eObject)
          Called when the object is attached to this resource, i.e., when it's eResource changes to be this one.
protected  void attachedHelper(EObject eObject)
           
 NotificationChain basicSetResourceSet(ResourceSet resourceSet, NotificationChain notifications)
          Sets the new containing resource set, and removes the resource from a previous containing resource set, if necessary.
protected  Adapter createModificationTrackingAdapter()
          Creates a modification tracking adapter.
 void delete(java.util.Map<?,?> options)
          deletes the resource using the specified options, unloads it, and then removes it from the containing resource set.
 void detached(EObject eObject)
          Called when the object is detached from this resource, i.e., when it's eResource changes to no longer be this one.
protected  void detachedHelper(EObject eObject)
           
protected  void doLoad(java.io.InputStream inputStream, java.util.Map<?,?> options)
          Called to load the resource.
protected  void doSave(java.io.OutputStream outputStream, java.util.Map<?,?> options)
          Called to save the resource.
protected  void doUnload()
          Does all the work of unloading the resource.
 TreeIterator<EObject> getAllContents()
          Returns a tree iterator that iterates over all the direct contents and indirect contents of this resource.
protected  TreeIterator<EObject> getAllProperContents(EObject eObject)
           
protected  TreeIterator<EObject> getAllProperContents(java.util.List<EObject> contents)
           
 EList<EObject> getContents()
          Returns the list of the direct content objects; each is of type EObject.
protected static URIConverter getDefaultURIConverter()
          Returns the default URI converter that's used when there is no resource set.
protected  EObject getEObject(java.util.List<java.lang.String> uriFragmentPath)
          Returns the object based on the fragment path as a list of Strings.
 EObject getEObject(java.lang.String uriFragment)
          Returns the resolved object for the given URI fragment.
protected  EObject getEObjectByID(java.lang.String id)
          Returns the object based on the fragment as an ID.
protected  EObject getEObjectForURIFragmentRootSegment(java.lang.String uriFragmentRootSegment)
          Returns the object associated with the URI fragment root segment.
 EList<Resource.Diagnostic> getErrors()
          Returns a list of the errors in the resource; each error will be of type Resource.Diagnostic.
 java.util.Map<java.lang.String,EObject> getIntrinsicIDToEObjectMap()
          Returns the map used to cache the EObject that is identified by the value of its ID feature.
 ResourceSet getResourceSet()
          Returns the containing resource set.
 long getTimeStamp()
          Returns the cached value of the time stamp when this resource was last loaded or saved, or NULL_TIME_STAMP if the resource is not loaded and the time stamp has not been set.
 URI getURI()
          Returns the URI of this resource.
protected  URIConverter getURIConverter()
          Returns the URI converter.
 java.lang.String getURIFragment(EObject eObject)
          Returns the URI fragment that, when passed to getEObject will return the given object.
protected  java.lang.String getURIFragmentRootSegment(EObject eObject)
          Returns the URI fragment root segment for reaching the given direct content object.
 EList<Resource.Diagnostic> getWarnings()
          Returns a list of the warnings and informational messages in the resource; each warning will be of type Resource.Diagnostic.
protected  boolean isAttachedDetachedHelperRequired()
           
protected  boolean isContentZipEntry(java.util.zip.ZipEntry zipEntry)
          Returns whether the given entry is the content entry for this resource.
 boolean isLoaded()
          Returns whether the resource is loaded.
 boolean isLoading()
          Indicates whether the resource is currently being loaded.
 boolean isModified()
          Returns whether this resource has been modified.
 boolean isTrackingModification()
          Returns whether modification tracking is enabled.
 void load(java.io.InputStream inputStream, java.util.Map<?,?> options)
          Loads the resource from the input stream using the specified options.
 void load(java.util.Map<?,?> options)
          Loads the resource using the specified options.
protected static java.util.Map<?,?> mergeMaps(java.util.Map<?,?> map1, java.util.Map<?,?> map2)
          Merges 2 maps, without changing any of them.
protected  java.util.zip.ZipEntry newContentZipEntry()
          Returns a new zip entry for saving the resource contents.
protected  void removeModificationTrackingAdapters(EObject eObject)
          Deprecated. since 2.1.0. This method is not invoked anymore. See attachedHelper(EObject).
 void save(java.util.Map<?,?> options)
          Saves the resource using the specified options.
 void save(java.io.OutputStream outputStream, java.util.Map<?,?> options)
          Saves the resource to the output stream using the specified options.
protected  void saveOnlyIfChangedWithFileBuffer(java.util.Map<?,?> options)
           
protected  void saveOnlyIfChangedWithMemoryBuffer(java.util.Map<?,?> options)
           
 void setIntrinsicIDToEObjectMap(java.util.Map<java.lang.String,EObject> intrinsicIDToEObjectMap)
          Sets the map used to cache the EObject identified by the value of its ID feature.
protected  Notification setLoaded(boolean isLoaded)
          Sets the load state as indicated, and returns a notification, if required.
 void setModified(boolean isModified)
          Sets whether this resource has been modified.
 void setTimeStamp(long timeStamp)
          Sets the value of the time stamp.
 void setTrackingModification(boolean isTrackingModification)
          Sets whether modification tracking is enabled.
 void setURI(URI uri)
          Sets the URI of this resource.
 java.lang.String toKeyString()
          If an implementation uses IDs and stores the IDs as part of the resource rather than as objects, this method should return a string representation of the ID to object mapping, which might be implemented as a Java Map.
 java.lang.String toString()
           
 void unload()
          Clears the contents, errors, and warnings of the resource and marks it as unloaded.
protected  void unloaded(InternalEObject internalEObject)
          Called when the object is unloaded.
protected  boolean useZip()
          Returns whether contents will be compressed.
 
Methods inherited from class org.eclipse.emf.common.notify.impl.NotifierImpl
eAdapters, eBasicAdapters, eDeliver, eSetDeliver
 
Methods inherited from class org.eclipse.emf.common.notify.impl.BasicNotifierImpl
eNotificationRequired, eNotify
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

defaultSaveOptions

protected java.util.Map<java.lang.Object,java.lang.Object> defaultSaveOptions
The storage for the default save options.


defaultLoadOptions

protected java.util.Map<java.lang.Object,java.lang.Object> defaultLoadOptions
The storage for the default load options.


defaultDeleteOptions

protected java.util.Map<java.lang.Object,java.lang.Object> defaultDeleteOptions
The storage for the default delete options.


resourceSet

protected ResourceSet resourceSet
The containing resource set.

See Also:
getResourceSet()

uri

protected URI uri
The URI.

See Also:
getURI()

timeStamp

protected long timeStamp
The time stamp.

See Also:
getTimeStamp()

contents

protected ResourceImpl.ContentsEList<EObject> contents
The contents.

See Also:
getContents()

errors

protected EList<Resource.Diagnostic> errors
The errors.

See Also:
getErrors()

warnings

protected EList<Resource.Diagnostic> warnings
The warnings.

See Also:
getErrors()

isModified

protected boolean isModified
The modified flag.

See Also:
isModified

isLoaded

protected boolean isLoaded
The loaded flag.

See Also:
isLoaded

isLoading

protected boolean isLoading
The loading flag.

See Also:
isLoading

unloadingContents

protected java.util.List<EObject> unloadingContents
A copy of the contents list while the contents are being unloaded. I.e., if this is not null, then the resource is in the process of unloading.

See Also:
unload()

modificationTrackingAdapter

protected Adapter modificationTrackingAdapter
The modification tracking adapter.

See Also:
isTrackingModification(), attached(EObject), detached(EObject)

intrinsicIDToEObjectMap

protected java.util.Map<java.lang.String,EObject> intrinsicIDToEObjectMap
A map to retrieve the EObject based on the value of its ID feature.

See Also:
setIntrinsicIDToEObjectMap(Map)
Constructor Detail

ResourceImpl

public ResourceImpl()
Creates a empty instance.


ResourceImpl

public ResourceImpl(URI uri)
Creates an instance with the given URI.

Parameters:
uri - the URI.
Method Detail

getDefaultURIConverter

protected static URIConverter getDefaultURIConverter()
Returns the default URI converter that's used when there is no resource set.

Returns:
the default URI converter.
See Also:
getURIConverter()

mergeMaps

protected static java.util.Map<?,?> mergeMaps(java.util.Map<?,?> map1,
                                              java.util.Map<?,?> map2)
Merges 2 maps, without changing any of them. If map2 and map1 have the same key for an entry, map1's value will be the one in the merged map.


getResourceSet

public ResourceSet getResourceSet()
Description copied from interface: Resource
Returns the containing resource set. A resource is contained by a resource set if it appears in the resources, i.e., the contents, of that resource set. This reference can only be modified by altering the contents of the resource set directly.

Specified by:
getResourceSet in interface Resource
Returns:
the containing resource set, or null if there isn't one.
See Also:
EObject.eContainer(), EObject.eResource(), ResourceSet.getResources()

basicSetResourceSet

public NotificationChain basicSetResourceSet(ResourceSet resourceSet,
                                             NotificationChain notifications)
Sets the new containing resource set, and removes the resource from a previous containing resource set, if necessary.

Specified by:
basicSetResourceSet in interface Resource.Internal
Parameters:
resourceSet - the new containing resource set.
notifications - the accumulating notifications.
Returns:
notification of the change.

getURI

public URI getURI()
Description copied from interface: Resource
Returns the URI of this resource. The URI is normally expected to be absolute and hierarchical; document-relative references will not be serialized and will not be resolved, if this is not the case.

Specified by:
getURI in interface Resource
Returns:
the URI of this resource, or null if there isn't one.
See Also:
Resource.setURI(URI), URI.isRelative(), URI.isHierarchical()

setURI

public void setURI(URI uri)
Description copied from interface: Resource
Sets the URI of this resource.

Specified by:
setURI in interface Resource
Parameters:
uri - the new URI.
See Also:
Resource.getURI()

getTimeStamp

public long getTimeStamp()
Description copied from interface: Resource
Returns the cached value of the time stamp when this resource was last loaded or saved, or NULL_TIME_STAMP if the resource is not loaded and the time stamp has not been set. The return value is represented as the number of milliseconds since the epoch (00:00:00 GMT, January 1, 1970). The returned value may not be the same as the actual time stamp if the resource has been modified via external means since the last load or save.

Specified by:
getTimeStamp in interface Resource
See Also:
Resource.setTimeStamp(long)

setTimeStamp

public void setTimeStamp(long timeStamp)
Description copied from interface: Resource
Sets the value of the time stamp. The time stamp is typically set indirectly via other operations on the resource such as loading and saving.

Specified by:
setTimeStamp in interface Resource
Parameters:
timeStamp - the new value of the time stamp.
See Also:
Resource.getTimeStamp(), Resource.RESOURCE__TIME_STAMP

getContents

public EList<EObject> getContents()
Description copied from interface: Resource
Returns the list of the direct content objects; each is of type 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.

Specified by:
getContents in interface Resource
Returns:
the direct content objects.

getAllContents

public TreeIterator<EObject> getAllContents()
Description copied from interface: Resource
Returns a tree iterator that iterates over all the direct contents and indirect contents of this resource.

Specified by:
getAllContents in interface Resource
Returns:
a tree iterator that iterates over all contents.
See Also:
EObject.eAllContents(), ResourceSet.getAllContents(), EcoreUtil.getAllContents(Resource, boolean)

getAllProperContents

protected TreeIterator<EObject> getAllProperContents(EObject eObject)

getAllProperContents

protected TreeIterator<EObject> getAllProperContents(java.util.List<EObject> contents)

getErrors

public EList<Resource.Diagnostic> getErrors()
Description copied from interface: Resource
Returns a list of the errors in the resource; each error will be of type Resource.Diagnostic.

These will typically be produced as the resource is loaded.

Specified by:
getErrors in interface Resource
Returns:
a list of the errors in the resource.
See Also:
Resource.load(Map)

getWarnings

public EList<Resource.Diagnostic> getWarnings()
Description copied from interface: Resource
Returns a list of the warnings and informational messages in the resource; each warning will be of type Resource.Diagnostic.

These will typically be produced as the resource is loaded.

Specified by:
getWarnings in interface Resource
Returns:
a list of the warnings in the resource.
See Also:
Resource.load(Map)

useZip

protected boolean useZip()
Returns whether contents will be compressed. This implementation returns false. When this returns true, save(OutputStream, Map) and load(InputStream, Map) will zip compress and decompress contents.

Returns:
whether contents will be compressed.
See Also:
newContentZipEntry(), isContentZipEntry(ZipEntry)

getURIFragmentRootSegment

protected java.lang.String getURIFragmentRootSegment(EObject eObject)
Returns the URI fragment root segment for reaching the given direct content object. This default implementation returns the position of the object, if there is more than one object, otherwise, the empty string. As a result, the URI fragment for a single root object will be "/".

Returns:
the URI fragment root segment for reaching the given direct content object.

getURIFragment

public java.lang.String getURIFragment(EObject eObject)
Description copied from interface: Resource
Returns the URI 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.

Specified by:
getURIFragment in interface Resource
Parameters:
eObject - the object to identify.
Returns:
the URI fragment for the object.
See Also:
Resource.getEObject(String), InternalEObject.eURIFragmentSegment(org.eclipse.emf.ecore.EStructuralFeature, EObject)

getEObjectForURIFragmentRootSegment

protected EObject getEObjectForURIFragmentRootSegment(java.lang.String uriFragmentRootSegment)
Returns the object associated with the URI fragment root segment. This default implementation uses the position of the object; an empty string is the same as "0".

Returns:
the object associated with the URI fragment root segment.

getEObject

public EObject getEObject(java.lang.String uriFragment)
Description copied from interface: Resource
Returns the resolved object for the given URI fragment.

The fragment encoding will typically be that produced by getURIFragment.

Specified by:
getEObject in interface Resource
Parameters:
uriFragment - the fragment to resolve.
Returns:
the resolved object for the given fragment, or null if it can't be resolved.
See Also:
Resource.getURIFragment(EObject), ResourceSet.getEObject(URI, boolean), EcoreUtil.resolve(EObject, ResourceSet), InternalEObject.eObjectForURIFragmentSegment(String)

getEObject

protected EObject getEObject(java.util.List<java.lang.String> uriFragmentPath)
Returns the object based on the fragment path as a list of Strings.


getIntrinsicIDToEObjectMap

public java.util.Map<java.lang.String,EObject> getIntrinsicIDToEObjectMap()
Returns the map used to cache the EObject that is identified by the value of its ID feature.

Returns:
the map used to cache the EObject that is identified by the value of its ID feature.
See Also:
setIntrinsicIDToEObjectMap(java.util.Map)

setIntrinsicIDToEObjectMap

public void setIntrinsicIDToEObjectMap(java.util.Map<java.lang.String,EObject> intrinsicIDToEObjectMap)
Sets the map used to cache the EObject identified by the value of its ID feature. This cache is only activated if the map is not null. The map will be lazily loaded by the getEObjectByID method. It is up to the client to clear the cache when it becomes invalid, e.g., when the ID of a previously mapped EObject is changed.

Parameters:
intrinsicIDToEObjectMap - the new map or null.
See Also:
getIntrinsicIDToEObjectMap()

getEObjectByID

protected EObject getEObjectByID(java.lang.String id)
Returns the object based on the fragment as an ID.


attached

public void attached(EObject eObject)
Description copied from interface: Resource.Internal
Called when the object is attached to this resource, i.e., when it's eResource changes to be this one.

An implementation that resolves based on IDs will need to walk the tree of this object in order to tabulate an index. An implementation that needs to track modification will also need to walk the tree in order to add the necessary adapter. In either of these cases, editing of containment relations will be significantly more expensive.

Specified by:
attached in interface Resource.Internal
Parameters:
eObject - the attached object.
See Also:
Resource.Internal.detached(EObject)

isAttachedDetachedHelperRequired

protected boolean isAttachedDetachedHelperRequired()

attachedHelper

protected void attachedHelper(EObject eObject)

addModificationTrackingAdapters

@Deprecated
protected final void addModificationTrackingAdapters(EObject eObject)
Deprecated. since 2.1.0. This method is not invoked anymore. See attachedHelper(EObject).

Adds modification tracking adapters to the object and it's content tree.

Parameters:
eObject - the object.
See Also:
attached(EObject)

detached

public void detached(EObject eObject)
Description copied from interface: Resource.Internal
Called when the object is detached from this resource, i.e., when it's eResource changes to no longer be this one.

An implementation that resolves based on IDs will need to walk the tree of this object in order clean up it's index. An implementation that needs to track modification will also need to walk the tree in order to remove the added adapter. In either of these cases, editing of containment relations will be significantly more expensive.

Specified by:
detached in interface Resource.Internal
Parameters:
eObject - the attached object.
See Also:
Resource.Internal.attached(EObject)

detachedHelper

protected void detachedHelper(EObject eObject)

removeModificationTrackingAdapters

@Deprecated
protected final void removeModificationTrackingAdapters(EObject eObject)
Deprecated. since 2.1.0. This method is not invoked anymore. See attachedHelper(EObject).

Removes modification tracking adapters to the object and it's content tree.

Parameters:
eObject - the object.
See Also:
detached(EObject)

getURIConverter

protected URIConverter getURIConverter()
Returns the URI converter. This typically gets the converter from the containing resource set, but it calls getDefaultURIConverter() when there is no containing resource set.

Returns:
the URI converter.

save

public void save(java.util.Map<?,?> options)
          throws java.io.IOException
Description copied from interface: Resource
Saves the resource using the specified options.

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).

Specified by:
save in interface Resource
Parameters:
options - the save options.
Throws:
java.io.IOException
See Also:
Resource.save(OutputStream, Map)

saveOnlyIfChangedWithFileBuffer

protected void saveOnlyIfChangedWithFileBuffer(java.util.Map<?,?> options)
                                        throws java.io.IOException
Throws:
java.io.IOException

saveOnlyIfChangedWithMemoryBuffer

protected void saveOnlyIfChangedWithMemoryBuffer(java.util.Map<?,?> options)
                                          throws java.io.IOException
Throws:
java.io.IOException

load

public void load(java.util.Map<?,?> options)
          throws java.io.IOException
Description copied from interface: Resource
Loads the resource using the specified options.

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.

Specified by:
load in interface Resource
Parameters:
options - the load options.
Throws:
java.io.IOException
See Also:
Resource.load(InputStream, Map)

newContentZipEntry

protected java.util.zip.ZipEntry newContentZipEntry()
Returns a new zip entry for saving the resource contents. It is called by save(OutputStream, Map) when writing zipped contents. This implementation creates an entry called ResourceContents.

Returns:
a new zip entry.
See Also:
isContentZipEntry(ZipEntry)

save

public final void save(java.io.OutputStream outputStream,
                       java.util.Map<?,?> options)
                throws java.io.IOException
Saves the resource to the output stream using the specified options.

This implementation is final; clients should override doSave.

Specified by:
save in interface Resource
Parameters:
options - the save options.
outputStream - the stream
Throws:
java.io.IOException
See Also:
save(Map), doSave(OutputStream, Map), load(InputStream, Map)

doSave

protected void doSave(java.io.OutputStream outputStream,
                      java.util.Map<?,?> options)
               throws java.io.IOException
Called to save the resource. This implementation throws an exception; clients must override it.

Parameters:
outputStream - the stream
options - the save options.
Throws:
java.lang.UnsupportedOperationException
java.io.IOException

isContentZipEntry

protected boolean isContentZipEntry(java.util.zip.ZipEntry zipEntry)
Returns whether the given entry is the content entry for this resource. It is called by load(InputStream, Map) when reading zipped contents. This implementation return true; i.e., the first entry will be read.

Returns:
whether the given entry is the content entry for this resource.
See Also:
newContentZipEntry()

load

public final void load(java.io.InputStream inputStream,
                       java.util.Map<?,?> options)
                throws java.io.IOException
Description copied from interface: Resource
Loads the resource from the input stream using the specified options.

Usually, load(Map) is called directly and it calls this.

Specified by:
load in interface Resource
Parameters:
inputStream - the stream
options - the load options.
Throws:
java.io.IOException
See Also:
Resource.load(Map), Resource.save(OutputStream, Map)

doLoad

protected void doLoad(java.io.InputStream inputStream,
                      java.util.Map<?,?> options)
               throws java.io.IOException
Called to load the resource. This implementation throws an exception; clients must override it.

Parameters:
inputStream - the stream
options - the load options.
Throws:
java.lang.UnsupportedOperationException
java.io.IOException

isLoaded

public boolean isLoaded()
Description copied from interface: Resource
Returns whether the resource is loaded.

This will be false when the resource is first created and will be set to false, when the resource is unloaded. It will be set to true when the resource is loaded and when contents are first added to a resource that isn't loaded. Calling clear for the contents of a resource that isn't loaded, will set the resource to be loaded; this is the simplest way to create an empty resource that's considered loaded.

Specified by:
isLoaded in interface Resource
Returns:
whether the resource is loaded.

isLoading

public boolean isLoading()
Description copied from interface: Resource.Internal
Indicates whether the resource is currently being loaded.

This will be true during a call to load(InputStream, Map), before notifications are dispatched.

Specified by:
isLoading in interface Resource.Internal
Returns:
whether this resource is currently being loaded.

unloaded

protected void unloaded(InternalEObject internalEObject)
Called when the object is unloaded. This implementation sets the object to be a proxy and clears the adapters.


setLoaded

protected Notification setLoaded(boolean isLoaded)
Sets the load state as indicated, and returns a notification, if required. Clients are not expected to call this directly; it is managed by the implementation.

Parameters:
isLoaded - whether the resource is loaded.
Returns:
a notification.

doUnload

protected void doUnload()
Does all the work of unloading the resource. It calls unloaded for each object it the content tree, and clears the contents, errors, and warnings.


unload

public final void unload()
Description copied from interface: Resource
Clears the contents, errors, and warnings of the resource and marks it as unloaded.

It walks the content tree, and sets each content object to be a proxy. The resource will remain in the resource set, and can be subsequently reloaded.

Specified by:
unload in interface Resource

delete

public void delete(java.util.Map<?,?> options)
            throws java.io.IOException
Description copied from interface: Resource
deletes the resource using the specified options, unloads it, and then removes it from the containing resource set.

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 URIConverter.delete(URI, Map) the resource's URI.

Specified by:
delete in interface Resource
Throws:
java.io.IOException

isTrackingModification

public boolean isTrackingModification()
Description copied from interface: Resource
Returns whether modification tracking is enabled.

If modification tracking is enabled, each object of the resource must be adapted in order to listen for changes. This will make the processing of attached and detached significantly more expensive. as well as all model editing, in general.

Specified by:
isTrackingModification in interface Resource
Returns:
whether modification tracking is enabled.

setTrackingModification

public void setTrackingModification(boolean isTrackingModification)
Description copied from interface: Resource
Sets whether modification tracking is enabled.

Calling this method is expensive because it walks the content tree to add or remove adapters.

Specified by:
setTrackingModification in interface Resource
Parameters:
isTrackingModification - whether modification tracking is to be enabled.

createModificationTrackingAdapter

protected Adapter createModificationTrackingAdapter()
Creates a modification tracking adapter. This implementation creates a ResourceImpl.ModificationTrackingAdapter. Clients may override this to any adapter.

See Also:
modificationTrackingAdapter, isTrackingModification()

isModified

public boolean isModified()
Description copied from interface: Resource
Returns whether this resource has been modified.

A resource is set to be unmodified after it is loaded or saved. Automatic modification tracking is supported, but it is expensive. Moreover, it is a poor fit for a model that supports undoable commands, since an undo looks like a change when it's really exactly the opposite.

Specified by:
isModified in interface Resource
Returns:
whether this resource has been modified.
See Also:
Resource.setModified(boolean)

setModified

public void setModified(boolean isModified)
Description copied from interface: Resource
Sets whether this resource has been modified.

A resource is automatically set to be unmodified after it is loaded or saved. Automatic modification tracking typically calls this directly.

Specified by:
setModified in interface Resource
Parameters:
isModified - whether this resource has been modified.
See Also:
Resource.isModified()

toKeyString

public java.lang.String toKeyString()
If an implementation uses IDs and stores the IDs as part of the resource rather than as objects, this method should return a string representation of the ID to object mapping, which might be implemented as a Java Map.

Returns:
a string representation of the ID to object mapping

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

Copyright 2001-2006 IBM Corporation and others.
All Rights Reserved.