Runtime

## org.eclipse.gmf.runtime.emf.core.util
Class EMFCoreUtil

    java.lang.Object
      org.eclipse.gmf.runtime.emf.core.util.EMFCoreUtil

public class EMFCoreUtil
extends java.lang.Object

Static utilities for working with EMF objects and resources in the GMF environment.

Constructor Summary
`EMFCoreUtil()`

Method Summary
`static EObject` `create(EObject container, EReference reference, EClass eClass)` Creates an object at a given containment reference whose `EClass` is eClass.
`static EObject` `createProxy(EClass eClass, URI uri)` Creates a proxy of the specified type with the specified proxy URI.
`static EObject` `getContainer(EObject eObject, EClass eClass)` Gets the first container with the specified EClass.
`static java.util.Collection` `getExports(Resource resource)` Gets the exports of a resource.
`static java.util.Collection` `getImports(Resource resource)` Gets the imports of a resource.
`static EObject` `getLeastCommonContainer(java.util.Collection objects, EClass desiredContainerType)` Finds the first common container of a collection of objects.
`static java.lang.String` `getName(EObject eObject)` Gets the name of an object if the object has name, returns an empty string otherwise.
`static EClass` `getProxyClass(EObject proxy)` Gets the proxy class by parsing the proxy URI.
`static java.lang.String` `getProxyID(EObject proxy)` Gets the proxy ID by parsing the proxy URI.
`static java.lang.String` `getQualifiedName(EObject eObject, boolean formatted)` Gets the fully qualified name of an object.
`static java.util.Collection` `getReferencers(EObject eObject, EReference[] features)` Uses a reverse reference map that is maintained by the MSL service to find all referencers of a particular element.
`static java.util.Collection` `getTransitiveExports(Resource resource)` Gets the transitive closure of the exports of a resource.
`static java.util.Collection` `getTransitiveImports(Resource resource)` Gets the transitive closure of the imports of a resource.
`static EObject` `resolve(org.eclipse.emf.transaction.TransactionalEditingDomain domain, EObject proxy)` Attempts to resolve the specified `proxy` object, returning `null` (rather than the original proxy) if it is unresolvable.
`static void` `setName(EObject eObject, java.lang.String name)` Sets the name of an object if the object can be assigned a name.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### EMFCoreUtil

    public EMFCoreUtil()

Method Detail

### create

    public static EObject create(EObject container,
                                 EReference reference,
                                 EClass eClass)

  Creates an object at a given containment reference whose `EClass` is eClass.

  Parameters:
    `container` - The container of the new object.
    `reference` - The feature containing the object.
    `eClass` - The `EClass`.
  Returns:
    The new `EObject`.

### getContainer

    public static EObject getContainer(EObject eObject,
                                       EClass eClass)

  Gets the first container with the specified EClass.

  Parameters:
    `eObject` - The `EObject`.
    `eClass` - The eClass.
  Returns:
    The container.

### getLeastCommonContainer

    public static EObject getLeastCommonContainer(java.util.Collection objects,
                                                  EClass desiredContainerType)

  Finds the first common container of a collection of objects.

  Parameters:
    `objects` - The `EObject`s.
    `desiredContainerType` - The desired `EClass` of the container.
  Returns:
    The least common container.

### getReferencers

    public static java.util.Collection getReferencers(EObject eObject,
                                                      EReference[] features)

  Uses a reverse reference map that is maintained by the MSL service to find all referencers of a particular element. The search can be narrowed down by passing the list of Reference features to match. `features` can be null.

  Parameters:
    `eObject` - The referenced object.
    `features` - The reference features.
  Returns:
    The collection of referencers.

### getImports

    public static java.util.Collection getImports(Resource resource)

  Gets the imports of a resource. These are the resources to which this `resource` has references.

  Parameters:
    `resource` - a resource.
  Returns:
    the imports of the resource

### getExports

    public static java.util.Collection getExports(Resource resource)

  Gets the exports of a resource. These are the resources that have references to the `resource`.

  Parameters:
    `resource` - a resource.
  Returns:
    the exports of the resource

### getTransitiveImports

    public static java.util.Collection getTransitiveImports(Resource resource)

  Gets the transitive closure of the imports of a resource. This obtains those resources that import the `resource`, the resources that import those, etc.

  Parameters:
    `resource` - a resource.
  Returns:
    the transitive imports of the resource

### getTransitiveExports

    public static java.util.Collection getTransitiveExports(Resource resource)

  Gets the transitive closure of the exports of a resource. This obtains those resources that export the `resource`, the resources that export those, etc.

  Parameters:
    `resource` - a resource.
  Returns:
    the transitive exports of the resource

### getName

    public static java.lang.String getName(EObject eObject)

  Gets the name of an object if the object has name, returns an empty string otherwise.

  Parameters:
    `eObject` - The object.
  Returns:
    The object's name.

### setName

    public static void setName(EObject eObject,
                               java.lang.String name)

  Sets the name of an object if the object can be assigned a name.

  Parameters:
    `eObject` - The object.
    `name` - The object's new name.
  Throws:
    `java.lang.IllegalArgumentException` - if the `eObject` does not have a name attribute

### getQualifiedName

    public static java.lang.String getQualifiedName(EObject eObject,
                                                    boolean formatted)

  Gets the fully qualified name of an object.

  Parameters:
    `eObject` - The object.
    `formatted` - if True, unnamed parents will be listed using their meta-class name.
  Returns:
    The object's qualified name.

### getProxyID

    public static java.lang.String getProxyID(EObject proxy)

  Gets the proxy ID by parsing the proxy URI.

  Parameters:
    `proxy` - The proxy object.
  Returns:
    The ID.

### getProxyClass

    public static EClass getProxyClass(EObject proxy)

  Gets the proxy class by parsing the proxy URI.

  Parameters:
    `proxy` - The proxy object.
  Returns:
    The class.

### createProxy

    public static EObject createProxy(EClass eClass,
                                      URI uri)

  Creates a proxy of the specified type with the specified proxy URI.

  Parameters:
    `uri` - The URI for the new proxy.
  Returns:
    The new proxy.

### resolve

    public static EObject resolve(org.eclipse.emf.transaction.TransactionalEditingDomain domain,
                                  EObject proxy)

  Attempts to resolve the specified `proxy` object, returning `null` (rather than the original proxy) if it is unresolvable.

  Parameters:
    `domain` - Th editing domain.
    `proxy` - The proxy object.
  Returns:
    The resolved object, or `null` if not resolved

Runtime

Guidelines for using Eclipse APIs.

Copyright (c) IBM Corp., Borland Software Corp., and others 2005,2006. All rights reserved.