Runtime

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

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

    public class PackageUtil

extends java.lang.Object

Some utility functions that work at the meta-class level.

Method Summary
`static boolean` `canContain(org.eclipse.emf.ecore.EClass class1, org.eclipse.emf.ecore.EClass class2, boolean recursive)` Checks if a container `EClass` can contain another `EClass`.
`static boolean` `canContain(org.eclipse.emf.ecore.EClass class1, org.eclipse.emf.ecore.EReference reference, org.eclipse.emf.ecore.EClass class2, boolean recursive)` Checks if a container `EClass` can contain another `EClass` at a given containment reference.
`static boolean` `canReference(org.eclipse.emf.ecore.EClass class1, org.eclipse.emf.ecore.EClass class2)` Checks if a container `EClass` can reference another `EClass`.
`static boolean` `canReference(org.eclipse.emf.ecore.EClass class1, org.eclipse.emf.ecore.EReference reference, org.eclipse.emf.ecore.EClass class2)` Checks if a container `EClass` can reference another `EClass` at a given non-containment reference.
`static org.eclipse.emf.ecore.EReference` `findFeature(org.eclipse.emf.ecore.EClass container, org.eclipse.emf.ecore.EClass eClass)` Finds a feature that can contain an object of type eClass.
`static java.lang.String` `getDisplayName(org.eclipse.emf.ecore.ENamedElement element)` Gets the localized display name of a meta-model element.
`static org.eclipse.emf.ecore.ENamedElement` `getElement(java.lang.String id)` Gets meta-model element by ID.
`static java.lang.String` `getID(org.eclipse.emf.ecore.ENamedElement element)` Gets the ID of a meta-model element.
`static java.lang.String` `getLocalizedName(org.eclipse.emf.ecore.ENamedElement element)` Gets the localized name of a meta-model element.
`static org.eclipse.emf.ecore.EAttribute` `getNameAttribute(org.eclipse.emf.ecore.EClass eClass)` Gets the name attribute of an `EClass`.
`static org.eclipse.emf.ecore.EAttribute` `getQualifiedNameAttribute(org.eclipse.emf.ecore.EClass eClass)` Gets the qualified name attribute of an `EClass`.

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

Method Detail

### getID

    public static java.lang.String getID(org.eclipse.emf.ecore.ENamedElement element)

  Gets the ID of a meta-model element. The ID of a meta-model element is the fully qualified name of the element going up to the root EPackage.

  Parameters:
    `element` - The Meta-model element.
  Returns:
    The ID.

### getElement

    public static org.eclipse.emf.ecore.ENamedElement getElement(java.lang.String id)

  Gets meta-model element by ID.

  Parameters:
    `id` - The element ID.
  Returns:
    The meta-model element.

### getLocalizedName

    public static java.lang.String getLocalizedName(org.eclipse.emf.ecore.ENamedElement element)

  Gets the localized name of a meta-model element. The name will not contain spaces.

  Parameters:
    `element` - The meta-model element.
  Returns:
    The localized name of the meta-model element.

### getDisplayName

    public static java.lang.String getDisplayName(org.eclipse.emf.ecore.ENamedElement element)

  Gets the localized display name of a meta-model element. Display name may contain spaces.

  NOTE: This should be used to make model changes (e.g. name an element). When displaying strings in the UI (menus, dialogs, etc.) get the string from one of our resource managers.

  Parameters:
    `element` - The meta-model element.
  Returns:
    The localized name of the meta-model element.

### canContain

    public static boolean canContain(org.eclipse.emf.ecore.EClass class1,
                                     org.eclipse.emf.ecore.EClass class2,
                                     boolean recursive)

  Checks if a container `EClass` can contain another `EClass`. The check can be recursive.

  Parameters:
    `class1` - The container `EClass`.
    `class2` - The contained `EClass`.
    `recursive` - True if recursive.
  Returns:
    True if an object can contain other objects of a given type.

### canContain

    public static boolean canContain(org.eclipse.emf.ecore.EClass class1,
                                     org.eclipse.emf.ecore.EReference reference,
                                     org.eclipse.emf.ecore.EClass class2,
                                     boolean recursive)

  Checks if a container `EClass` can contain another `EClass` at a given containment reference. The check can be recursive.

  Parameters:
    `class1` - The container `EClass`.
    `reference` - The reference.
    `class2` - The contained `EClass`.
    `recursive` - True if recursive.
  Returns:
    True if an object can contain other objects of a given type.

### canReference

    public static boolean canReference(org.eclipse.emf.ecore.EClass class1,
                                       org.eclipse.emf.ecore.EClass class2)

  Checks if a container `EClass` can reference another `EClass`.

  Parameters:
    `class1` - The referencer `EClass`.
    `class2` - The referenced `EClass`.
  Returns:
    True if an object can contain other objects of a given type.

### canReference

    public static boolean canReference(org.eclipse.emf.ecore.EClass class1,
                                       org.eclipse.emf.ecore.EReference reference,
                                       org.eclipse.emf.ecore.EClass class2)

  Checks if a container `EClass` can reference another `EClass` at a given non-containment reference.

  Parameters:
    `class1` - The referencer `EClass`.
    `reference` - The reference.
    `class2` - The referenced `EClass`.
  Returns:
    True if an object can contain other objects of a given type.

### findFeature

    public static org.eclipse.emf.ecore.EReference findFeature(org.eclipse.emf.ecore.EClass container,
                                                               org.eclipse.emf.ecore.EClass eClass)

  Finds a feature that can contain an object of type eClass.

  Parameters:
    `container` - The container `EClass`.
    `eClass` - The contained `EClass`.
  Returns:
    The found feature.

### getNameAttribute

    public static org.eclipse.emf.ecore.EAttribute getNameAttribute(org.eclipse.emf.ecore.EClass eClass)

  Gets the name attribute of an `EClass`.

  Parameters:
    `eClass` - The `EClass`.
  Returns:
    The name attribute.

### getQualifiedNameAttribute

    public static org.eclipse.emf.ecore.EAttribute getQualifiedNameAttribute(org.eclipse.emf.ecore.EClass eClass)

  Gets the qualified name attribute of an `EClass`.

  Parameters:
    `eClass` - The `EClass`.
  Returns:
    The qualified name attribute.

Runtime

Guidelines for using Eclipse APIs.

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