TPTP 4.6.0 Platform Project
Internal API Specification

org.eclipse.tptp.platform.common.internal.util
Class EMFUtil

java.lang.Object
  extended by org.eclipse.hyades.models.hierarchy.util.EMFUtil
      extended by org.eclipse.tptp.platform.common.internal.util.EMFUtil
Direct Known Subclasses:
EMFUtil

public class EMFUtil
extends org.eclipse.hyades.models.hierarchy.util.EMFUtil

Contains generic utility methods to work with EMF objects.


Nested Class Summary
 
Nested classes/interfaces inherited from class org.eclipse.hyades.models.hierarchy.util.EMFUtil
org.eclipse.hyades.models.hierarchy.util.EMFUtil.EqualityHelperIgnoreContainer, org.eclipse.hyades.models.hierarchy.util.EMFUtil.ReusableValuesAdapter
 
Field Summary
static java.util.Map RESOURCE_OPTIONS
           
 
Constructor Summary
EMFUtil()
           
 
Method Summary
static void addAdapter(java.util.Iterator objectIterator, org.eclipse.emf.common.notify.Adapter adapter)
          Adds the specified adapter to the notifiers in the given iterator.
static org.eclipse.emf.ecore.EObject getEObject(org.eclipse.emf.ecore.resource.ResourceSet resourceSet, org.eclipse.emf.ecore.EObject eObject, boolean load)
          Returns an EObject from the resource set that has the same URI fragment or id of the specifie eObject.
static org.eclipse.emf.ecore.EObject[] getEObjects(org.eclipse.emf.ecore.resource.ResourceSet resourceSet, org.eclipse.core.resources.IFile file)
          Returns the EObjects in the specified file from the Resource Set without loading it.
static org.eclipse.emf.ecore.EObject[] getEObjects(org.eclipse.emf.ecore.resource.ResourceSet resourceSet, java.lang.String fullPath)
          Returns the EObjects in the specified file paht from the Resource Set without loading it.
static org.eclipse.emf.ecore.resource.Resource getResource(org.eclipse.emf.ecore.resource.ResourceSet resourceSet, org.eclipse.core.resources.IFile file)
          Returns a resource without loading it.
static org.eclipse.emf.ecore.resource.Resource.Factory getResourceFactory(java.lang.String fileExtension)
          Returns the resource factory associated with a given file extension.
static org.eclipse.emf.ecore.resource.Resource[] getResources(org.eclipse.core.runtime.IPath fullPath, org.eclipse.emf.ecore.resource.ResourceSet resourceSet)
          Returns an array of EMF resources from the resource set passed by @param resourceSet that are in the file path specified by @param fullPath
static org.eclipse.core.resources.IFile getWorkspaceFile(org.eclipse.emf.ecore.EObject eObject)
          Returns the workspace file that is storing a given eObject or null if the object is not persisted.
static org.eclipse.core.resources.IFile getWorkspaceFile(org.eclipse.emf.ecore.resource.Resource resource)
          Returns the workspace file that corresponds to a given resource or null if the resource is not available in the workspace.
static java.lang.String getWorkspaceFilePath(org.eclipse.emf.ecore.resource.Resource resource)
           
static org.eclipse.emf.ecore.EObject[] load(org.eclipse.emf.ecore.resource.ResourceSet resourceSet, org.eclipse.core.resources.IFile file)
          Loads the specified file returning all the root EObjects.
static org.eclipse.emf.ecore.EObject[] load(org.eclipse.emf.ecore.resource.ResourceSet resourceSet, java.lang.String fullPath)
          Loads the specified file returning all the root EObjects.
static org.eclipse.emf.ecore.EObject reload(org.eclipse.emf.ecore.EObject eObject)
          Reloads a given eObject returning a new instance from the same resource.
static org.eclipse.emf.ecore.resource.Resource[] remove(org.eclipse.emf.ecore.EObject eObject)
          Removes the specified eObject from its container and breaks all the references to this object within the context of its resource set.
static org.eclipse.emf.ecore.resource.Resource[] remove(org.eclipse.emf.ecore.resource.Resource resource)
          Removes the specified resource from its resource set and breaks all the references to objects inside this resource within the context of the resource set.
static void removeAdapter(java.util.Iterator objectIterator, org.eclipse.emf.common.notify.Adapter adapter)
          Removes the specified adapter from the notifiers in the given iterator.
static void removeAdapters(java.util.Iterator objectIterator)
          Removes all adapters from the notifiers in the given iterator.
static void save(org.eclipse.emf.ecore.resource.Resource resource)
          Saves a resource.
 
Methods inherited from class org.eclipse.hyades.models.hierarchy.util.EMFUtil
containsObjectUsingSpecialEqual, convertToProxy, delete, delete, delete, delete, delete, delete, getAddReusableValue, getResourceSetRoots, isContainedIn, isContainedIn, isContainedIn, processObjectReferences, unload, unload, unsetAllFeatures, unsetFeaturesInSameResource
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RESOURCE_OPTIONS

public static final java.util.Map RESOURCE_OPTIONS
Constructor Detail

EMFUtil

public EMFUtil()
Method Detail

save

public static void save(org.eclipse.emf.ecore.resource.Resource resource)
                 throws java.lang.Exception
Saves a resource.

Parameters:
resource -
progressMonitor -
Throws:
java.lang.IllegalArgumentException - if the resource is null
java.lang.Exception - if an exception happens during the saving attempt.

getEObject

public static org.eclipse.emf.ecore.EObject getEObject(org.eclipse.emf.ecore.resource.ResourceSet resourceSet,
                                                       org.eclipse.emf.ecore.EObject eObject,
                                                       boolean load)
Returns an EObject from the resource set that has the same URI fragment or id of the specifie eObject. If the eObject is not in the resource set or can't be loaded, this method returns null.

Parameters:
resourceSet -
eObject -
load -
Returns:
EObject

getEObjects

public static org.eclipse.emf.ecore.EObject[] getEObjects(org.eclipse.emf.ecore.resource.ResourceSet resourceSet,
                                                          org.eclipse.core.resources.IFile file)
Returns the EObjects in the specified file from the Resource Set without loading it.

If the resource set is null or if the file is not loaded into it, this method returns an empty array.

Parameters:
resourceSet -
file -
Returns:
EObject[]

getEObjects

public static org.eclipse.emf.ecore.EObject[] getEObjects(org.eclipse.emf.ecore.resource.ResourceSet resourceSet,
                                                          java.lang.String fullPath)
Returns the EObjects in the specified file paht from the Resource Set without loading it.

If the resource set is null or if the file is not loaded into it, this method returns an empty array.

Parameters:
resourceSet -
file -
Returns:
EObject[]

load

public static org.eclipse.emf.ecore.EObject[] load(org.eclipse.emf.ecore.resource.ResourceSet resourceSet,
                                                   org.eclipse.core.resources.IFile file)
Loads the specified file returning all the root EObjects. If the resource set argument is null then this method tries to find a registered resource factory.

If the load attempt fails this method adds an entry to the log and returns an empty array.

Parameters:
resourceSet -
file -
Returns:
EObject[]

load

public static org.eclipse.emf.ecore.EObject[] load(org.eclipse.emf.ecore.resource.ResourceSet resourceSet,
                                                   java.lang.String fullPath)
Loads the specified file returning all the root EObjects. If the resource set argument is null then this method tries to find a registered resource factory.

If the load attempt fails this method adds an entry to the log and returns an empty array.

Parameters:
resourceSet -
fullPath -
Returns:
EObject[]

getResourceFactory

public static org.eclipse.emf.ecore.resource.Resource.Factory getResourceFactory(java.lang.String fileExtension)
Returns the resource factory associated with a given file extension. If the file extension is null or if there isn't a specifc factory for the file extension, the this method returns the generic factory.

Parameters:
fileExtension -
Returns:
the Resource.Factory or null if none.

getWorkspaceFile

public static org.eclipse.core.resources.IFile getWorkspaceFile(org.eclipse.emf.ecore.EObject eObject)
Returns the workspace file that is storing a given eObject or null if the object is not persisted.

Parameters:
eObject -
Returns:
IFile

getWorkspaceFile

public static org.eclipse.core.resources.IFile getWorkspaceFile(org.eclipse.emf.ecore.resource.Resource resource)
Returns the workspace file that corresponds to a given resource or null if the resource is not available in the workspace.

Parameters:
resource -
Returns:
IFile

getWorkspaceFilePath

public static java.lang.String getWorkspaceFilePath(org.eclipse.emf.ecore.resource.Resource resource)

getResource

public static org.eclipse.emf.ecore.resource.Resource getResource(org.eclipse.emf.ecore.resource.ResourceSet resourceSet,
                                                                  org.eclipse.core.resources.IFile file)
Returns a resource without loading it. If the resource is null, a new resource is created if a resource factory is available for the file extension.

Parameters:
resourceSet -
file -
Returns:
Resource

reload

public static org.eclipse.emf.ecore.EObject reload(org.eclipse.emf.ecore.EObject eObject)
Reloads a given eObject returning a new instance from the same resource.

This method unloads and reloads the entire eObject's resource and tries to find the object in the new resource content.

Important: after reloading the resource all the objects in that resource are reinstantiated. This has a big impact if an object is being cached somewhere.

Parameters:
eObject -
Returns:
the reloaded eObject

remove

public static org.eclipse.emf.ecore.resource.Resource[] remove(org.eclipse.emf.ecore.EObject eObject)
Removes the specified eObject from its container and breaks all the references to this object within the context of its resource set.

Parameters:
eObject -
Returns:
the changed resources including the eObject's resource.

remove

public static org.eclipse.emf.ecore.resource.Resource[] remove(org.eclipse.emf.ecore.resource.Resource resource)
Removes the specified resource from its resource set and breaks all the references to objects inside this resource within the context of the resource set.

Parameters:
resource -
Returns:
the changed resources excluding the specified resource.

addAdapter

public static void addAdapter(java.util.Iterator objectIterator,
                              org.eclipse.emf.common.notify.Adapter adapter)
Adds the specified adapter to the notifiers in the given iterator.

Parameters:
objectIterator -
adapter -

removeAdapter

public static void removeAdapter(java.util.Iterator objectIterator,
                                 org.eclipse.emf.common.notify.Adapter adapter)
Removes the specified adapter from the notifiers in the given iterator.

Parameters:
objectIterator -
adapter -

removeAdapters

public static void removeAdapters(java.util.Iterator objectIterator)
Removes all adapters from the notifiers in the given iterator.

Parameters:
objectIterator -

getResources

public static org.eclipse.emf.ecore.resource.Resource[] getResources(org.eclipse.core.runtime.IPath fullPath,
                                                                     org.eclipse.emf.ecore.resource.ResourceSet resourceSet)
Returns an array of EMF resources from the resource set passed by @param resourceSet that are in the file path specified by @param fullPath

Parameters:
resourceSet -
fullPath -
Returns:

TPTP 4.6.0 Platform Project
Internal API Specification