com.ibm.etools.emf.resource
Interface Resource

All Superinterfaces:
Notifier

public interface Resource
extends Notifier

A resource represents serialized MOF objects. You save objects by adding them to an extent, creating a resource, setting its extent and URI, and then calling a save method. A URIConverter is used to change the URI to an output stream. Alternatively, you can invoke a save method and specify the output stream to write to.

You restore objects from a resource by calling the load method in the ResourceFactory, or by calling the load method on a Resources object. You access the restored objects by getting the extent for the resource and iterating over it.

A resource may be added to a resources object to enable cross-resource references to be handled.


Field Summary
static java.lang.String copyright
           
 
Fields inherited from interface com.ibm.etools.emf.notify.Notifier
ADD, ADD_MANY, CREATE, MOVE, NO_INDEX, REMOVE, REMOVE_MANY, REMOVING_ADAPTER, SET, TOUCH, UNSET
 
Method Summary
 java.lang.Object getDefaultSaveOptions()
          This method returns a java.lang.Object containing the default save options for saving resources.
 Extent getExtent()
           
 com.ibm.etools.emf.ref.RefObject getObject(com.ibm.etools.emf.resource.URI uri)
          Return the object that matches the given uri using the IDKey.
 ResourceSet getResourceSet()
           
 com.ibm.etools.emf.resource.URI getURI()
          Return the URI object.
 boolean isExtentModified()
          This method indicates whether or not the extent associated with the resource has been modified since the last time it was loaded or saved.
 boolean isUnloaded()
          After removing a Resource Set, the resource becomes unloaded and all the objects are turned into proxies.
 java.lang.String makeHref(com.ibm.etools.emf.resource.RefBaseObject object)
           
 void refSetID()
          Set the ID for all objects in the resource
 void save()
          Save this resource; the default save options are used, and an OutputStream is opened from the URI of the resource.
 void save(java.lang.Object options)
          Save this resource with the given save options.
 void save(java.io.OutputStream os)
          Saves this resource using the given OutputStream; the default save options are used.
 void save(java.io.OutputStream os, java.lang.Object options)
          Saves this resource using the given OutputStream with the given save options.
 void setExtent(Extent e)
           
 void setExtentModified(boolean flag)
          This method is used to set the modified flag on the extent.
 void setResourceSet(ResourceSet r)
           
 void setURI(java.lang.String uri)
           
 void setURI(com.ibm.etools.emf.resource.URI uri)
           
 void unload()
           
 
Methods inherited from interface com.ibm.etools.emf.notify.Notifier
addAdapter, getAdapter, getAdapters, getExistingAdapter, isDelivery, isDeliveryAll, notify, notify, removeAdapter, removeAllAdapters, setDelivery, setDeliveryAll
 

Field Detail

copyright

public static final java.lang.String copyright
Method Detail

getExtent

public Extent getExtent()

setExtent

public void setExtent(Extent e)

makeHref

public java.lang.String makeHref(com.ibm.etools.emf.resource.RefBaseObject object)

getURI

public com.ibm.etools.emf.resource.URI getURI()
Return the URI object.

setURI

public void setURI(com.ibm.etools.emf.resource.URI uri)

setURI

public void setURI(java.lang.String uri)

getResourceSet

public ResourceSet getResourceSet()

setResourceSet

public void setResourceSet(ResourceSet r)

save

public void save()
          throws java.lang.Exception
Save this resource; the default save options are used, and an OutputStream is opened from the URI of the resource. The objects in the resource's extent are saved.

The default implementation of this method is to call getDefaultSaveOptions() and invoke the save(Object options) method.

If there is an error when saving the resource, an exception is thrown.


save

public void save(java.lang.Object options)
          throws java.lang.Exception
Save this resource with the given save options. An OutputStream is opened using the URI of this resource. The objects in the resource's extent are saved.

The default implementation of this method is to open an OutputStream from the URI of this resource, then invoke the save(OutputStream os, Object options) method.

If there is an error when saving the resource, an exception is thrown.


save

public void save(java.io.OutputStream os)
          throws java.lang.Exception
Saves this resource using the given OutputStream; the default save options are used. The OutputStream is not closed after saving, to allow you to manage the OutputStream.

The default implementation of this method is to call getDefaultSaveOptions(), then invoke the save(OutputStream os, Object options) method.


save

public void save(java.io.OutputStream os,
                 java.lang.Object options)
          throws java.lang.Exception
Saves this resource using the given OutputStream with the given save options. The OutputStream is not closed after saving, to allow a user to manage the OutputStream.

If the given OutputStream is a ZipOutputStream, this method makes a ZipEntry in the OutputStream whose name is the URI.getFile(), then closes the new ZipEntry. The given OutputStream is not closed, so you can use it to save other resources in it.

If the given OutputStream is not a ZipOutputStream, the objects in the resource's extent are saved to the OutputStream and the OutputStream is not closed, so you can manage it.


getDefaultSaveOptions

public java.lang.Object getDefaultSaveOptions()
This method returns a java.lang.Object containing the default save options for saving resources. The default implementation returns null, so you do not need to implement this method if you make your own kind of resources.

isExtentModified

public boolean isExtentModified()
This method indicates whether or not the extent associated with the resource has been modified since the last time it was loaded or saved. Creation date: (04/04/01 4:30:40 PM)
Returns:
boolean

setExtentModified

public void setExtentModified(boolean flag)
This method is used to set the modified flag on the extent. If you have overridden the ResourceImpl.save method or the ResourceFactoryImpl.load method, then your implementation of these methods should include code to set the modified flag to false after a load or save has completed successfully. Creation date: (04/04/01 4:31:18 PM)
Parameters:
flag - boolean

getObject

public com.ibm.etools.emf.ref.RefObject getObject(com.ibm.etools.emf.resource.URI uri)
Return the object that matches the given uri using the IDKey. An IDKey is added if not already present. If not found, return null.

isUnloaded

public boolean isUnloaded()
After removing a Resource Set, the resource becomes unloaded and all the objects are turned into proxies. Accessing the proxies will cause a demand-load of a new resource.

unload

public void unload()

refSetID

public void refSetID()
Set the ID for all objects in the resource