org.eclipse.emf.ecore.util
Class EcoreUtil

java.lang.Object
  extended by org.eclipse.emf.ecore.util.EcoreUtil

public class EcoreUtil
extends java.lang.Object

This class contains convenient static methods for working with EMF objects.


Nested Class Summary
static class EcoreUtil.ContentTreeIterator<E>
          An iterator over the tree contents of a collection of EObjects, Resources, and ResourceSets.
static class EcoreUtil.Copier
          A mapping building traverser of a collection of content trees; the map is from EObject to EObject, i.e., from original to copy; use EcoreUtil.copy or EcoreUtil.copyAll to do routine copies.
static class EcoreUtil.CrossReferencer
          A mapping building traverser of a collection of content trees; the map is from target object to a collection of EStructuralFeature.Setting.
static class EcoreUtil.EGenericTypeConverter
          A utility class that traverses a generic type to convert it to a string representation.
static class EcoreUtil.EqualityHelper
           A helper for determining whether two EObjects are structurally equal.
static class EcoreUtil.ExternalCrossReferencer
          A cross referencer that finds all references that are not contained within the content trees.
static class EcoreUtil.FilteredSettingsIterator
          An iterator over settings that filters out the ones that aren't of interest.
static class EcoreUtil.ProperContentIterator<E>
          An iterator that can skip over items in a list.
static class EcoreUtil.ProxyCrossReferencer
          A cross referencer that finds proxies; the cross referencer will not cause proxies to be resolved.
static class EcoreUtil.UnresolvedProxyCrossReferencer
          A cross referencer that finds proxies that cannot be resolved.
static class EcoreUtil.UsageCrossReferencer
          A cross referencer that finds each usage of an EObject or collection of EObjects.
 
Field Summary
protected static java.lang.String GEN_MODEL_PACKAGE_NS_URI
           
static int GET
          Identifier for the get accessor.
static int IS_SET
          Identifier for the isSet accessor.
static int SET
          Identifier for the set accessor.
static int UNSET
          Identifier for the unset accessor.
 
Constructor Summary
EcoreUtil()
           
 
Method Summary
static Diagnostic computeDiagnostic(Resource resource, boolean includeWarnings)
          Computes a Diagnostic from the errors and warnings stored in the specified resource.
static java.lang.String convertToString(EDataType eDataType, java.lang.Object value)
          Converts an instance of the data type to a string literal representation.
static EObject copy(EObject eObject)
          Returns a self-contained copy of the eObject.
static
<T> java.util.Collection<T>
copyAll(java.util.Collection<? extends T> eObjects)
          Returns a collection of the self-contained copies of each EObject in eObjects.
static EObject create(EClass eClass)
          Creates an instance of the class.
static java.lang.Object createFromString(EDataType eDataType, java.lang.String literal)
          Creates an instance of the datatype.
static void delete(EObject eObject)
          Deletes the object from its containing resource and/or its containing object as well as from any other feature that references it within the enclosing resource set, resource, or root object.
static void delete(EObject eObject, boolean recursive)
          Deletes the object from its containing resource and/or its containing object as well as from any other feature that references it within the enclosing resource set, resource, or root object.
static boolean equals(EObject eObject1, EObject eObject2)
          Returns true if eObject1 and eObject2 are equal, false otherwise.
static java.util.List<EObject> filterDescendants(java.util.Collection<? extends EObject> eObjects)
          Returns a subset of the objects such that no object in the result is an ancestor of any other object in the result.
static void freeze(EPackage ePackage)
          Marks the package to indicate that it and everything it contains or that its contents depend on can no longer be changed.
static java.lang.String generateUUID()
          Generates a universally unique identifier, i.e., a UUID.
static void generateUUID(byte[] uuid)
          Generates a universally unique identifier, i.e., a UUID.
static Adapter getAdapter(java.util.List<Adapter> adapters, java.lang.Object type)
          Returns the adapter of the specified type.
static AdapterFactory getAdapterFactory(java.util.List<AdapterFactory> adapterFactories, java.lang.Object type)
          Returns the adapter factory for the specified adapter type.
static
<T> TreeIterator<T>
getAllContents(java.util.Collection<?> emfObjects)
          Returns a tree iterator over the content trees recursively defined by ResourceSet.getResources(), Resource.getContents(), and EObject.eContents().
static
<T> TreeIterator<T>
getAllContents(java.util.Collection<?> emfObjects, boolean resolve)
          Returns a tree iterator over the content trees recursively defined by ResourceSet.getResources(), Resource.getContents(), and EObject.eContents().
static
<T> TreeIterator<T>
getAllContents(EObject eObject, boolean resolve)
          Returns a tree iterator that iterates over all the direct contents and indirect contents of the object.
static
<T> TreeIterator<T>
getAllContents(Resource resource, boolean resolve)
          Returns a tree iterator that iterates over all the direct contents and indirect contents of the resource.
static
<T> TreeIterator<T>
getAllContents(ResourceSet resourceSet, boolean resolve)
          Returns a tree iterator that iterates over all the direct resources in the resource set and over the content tree of each.
static
<T> TreeIterator<T>
getAllProperContents(java.util.Collection<?> emfObjects, boolean resolve)
          Returns a tree iterator over the content trees recursively defined by ResourceSet.getResources(), Resource.getContents(), and EObject.eContents(), skipping over any child object that's in a different resource from its parent.
static
<T> TreeIterator<T>
getAllProperContents(EObject eObject, boolean resolve)
          Returns a tree iterator that iterates over all the direct contents and indirect contents of the object, skipping over any child object that's in a different resource from its parent.
static
<T> TreeIterator<T>
getAllProperContents(Resource resource, boolean resolve)
          Returns a tree iterator that iterates over all the direct contents and indirect contents of the resource, skipping over any child object that's in a different resource from its parent.
static
<T> TreeIterator<T>
getAllProperContents(ResourceSet resourceSet, boolean resolve)
          Returns a tree iterator that iterates over all the direct resources in the resource set and over the content tree of each, skipping over any child object that's in a different resource from its parent.
static java.lang.String getAnnotation(EModelElement eModelElement, java.lang.String sourceURI, java.lang.String key)
           
static java.util.List<java.lang.String> getConstraints(EModelElement eModelElement)
           
static java.lang.String getDocumentation(EModelElement eModelElement)
           
static Adapter getExistingAdapter(Notifier notifier, java.lang.Object type)
          Returns the specified notifier's existing adapter of the specified type.
static java.lang.String getID(EObject eObject)
          Returns the value of the object's ID attribute as a String.
static java.lang.String getIdentification(EObject eObject)
          Returns a unique string identification of the eObject; it is structured as follows: <java-class-name>[/<dynamic-eClass-name>]@<java-hex-hash-code>{<uri-of-eObject>}
static java.lang.Object getObjectByType(java.util.Collection<?> objects, EClassifier type)
          Returns the first collection member that is an instance of the type.
static
<T> java.util.Collection<T>
getObjectsByType(java.util.Collection<?> objects, EClassifier type)
          Returns a collection containing each collection member that is an instance of the type.
static Adapter getRegisteredAdapter(EObject eObject, java.lang.Object type)
          Returns the specified eObject's adapter of the specified type.
static Adapter getRegisteredAdapter(Resource resource, java.lang.Object type)
          Returns the specified resource's adapter of the specified type.
static EObject getRootContainer(EObject eObject)
          Returns the root container; it may be this object itself and it will have a null container.
static EObject getRootContainer(EObject eObject, boolean resolve)
          Returns the root container; it may be this object itself and it will have a null container.
static URI getURI(EObject eObject)
          Returns a URI for the eObject, i.e., either the eProxyURI, the URI of the eResource with the fragment produced by the eResource, or the URI consisting of just the fragment that would be produced by a default Resource with the eObject as its only contents.
static int indexOf(java.util.List<?> list, java.lang.Object o, int fromIndex)
          Deprecated. replaced by ECollections.indexOf(List, Object, int) in 2.1.0
static boolean isAncestor(java.util.Collection<?> ancestorEMFObjects, EObject eObject)
          Returns whether any EObject, Resource, or ResourceSet in the collection is an ancestor of the EObject.
static boolean isAncestor(EObject ancestorEObject, EObject eObject)
          Returns whether the second object is directly or indirectly contained by the first object, i.e., whether the second object is in the content tree of the first.
static boolean isAncestor(Resource ancestorResource, EObject eObject)
          Returns whether the given resource is that of the object, i.e., whether the object is in the content tree of the resource.
static boolean isAncestor(ResourceSet ancestorResourceSet, EObject eObject)
          Returns whether the given resource set is that of the object, i.e., whether the object is in the content tree of the resource set.
static boolean isSuppressedVisibility(EOperation eOperation)
          Tests whether the given operation has been annotated to prevent generation of a method declaration in its interface.
static boolean isSuppressedVisibility(EStructuralFeature eStructuralFeature, int accessor)
          Tests whether the given structural feature has been annotated to prevent generation of accessor methods in its interface.
static void remove(EObject eObject)
          Removes the object from its containing resource and/or its containing object.
static void remove(EObject eObject, EStructuralFeature eStructuralFeature, java.lang.Object value)
          Removes the value from the feature of the object.
static void remove(EStructuralFeature.Setting setting, java.lang.Object value)
          Removes the value from the setting.
static void replace(EObject eObject, EObject replacementEObject)
          Replace the object in its containing resource and/or its containing object, with the replacement object.
static void replace(EObject eObject, EStructuralFeature eStructuralFeature, java.lang.Object oldValue, java.lang.Object newValue)
          Replaces the old value in the object's feature with the new value.
static void replace(EStructuralFeature.Setting setting, java.lang.Object oldValue, java.lang.Object newValue)
          Replaces the old value in the setting with the new value.
static EObject resolve(EObject proxy, EObject objectContext)
          Returns the resolved object represented by proxy.
static EObject resolve(EObject proxy, Resource resourceContext)
          Returns the resolved object represented by proxy.
static EObject resolve(EObject proxy, ResourceSet resourceSet)
          Returns the resolved object represented by proxy.
static void resolveAll(EObject eObject)
          Visits all proxies referenced by the object or recursively any of it's contained object.
static void resolveAll(Resource resource)
          Visits all proxies in the resource and tries to resolve them.
static void resolveAll(ResourceSet resourceSet)
          Visits all proxies in the resource set and tries to resolve them.
static void setAnnotation(EModelElement eModelElement, java.lang.String sourceURI, java.lang.String key, java.lang.String value)
           
static void setConstraints(EModelElement eModelElement, java.util.List<java.lang.String> constraints)
           
static void setDocumentation(EModelElement eModelElement, java.lang.String documentation)
           
static
<T> void
setEList(EList<T> eList, java.util.Collection<? extends T> prototypeCollection)
          Deprecated. replaced by ECollections.setEList(EList, List) in 2.1.0
static
<T> void
setEList(EList<T> eList, java.util.List<? extends T> prototypeList)
          Deprecated. replaced by ECollections.setEList(EList, List) in 2.1.0
static void setID(EObject eObject, java.lang.String id)
          Sets the value of the object's ID attribute according to the value represented by the String.
static void setSuppressedVisibility(EOperation eOperation, boolean suppress)
          Sets or removes the annotation on the given operation to prevent generation of a method declaration in its interface.
static void setSuppressedVisibility(EStructuralFeature eStructuralFeature, int accessor, boolean suppress)
          Sets or removes annotations on the given structural feature to prevent generation of accessor methods in its interface.
static java.lang.String toJavaInstanceTypeName(EGenericType eGenericType)
          Converts a generic type to its Java representation.
static java.lang.Class<?> wrapperClassFor(java.lang.Class<?> javaClass)
          Returns the wrapper class for the primitive class, or the original class, if it's not a primitive class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

GEN_MODEL_PACKAGE_NS_URI

protected static final java.lang.String GEN_MODEL_PACKAGE_NS_URI
See Also:
Constant Field Values

GET

public static final int GET
Identifier for the get accessor.

Since:
2.1
See Also:
isSuppressedVisibility(EStructuralFeature, int), setSuppressedVisibility(EStructuralFeature, int, boolean), Constant Field Values

SET

public static final int SET
Identifier for the set accessor.

Since:
2.1
See Also:
isSuppressedVisibility(EStructuralFeature, int), setSuppressedVisibility(EStructuralFeature, int, boolean), Constant Field Values

IS_SET

public static final int IS_SET
Identifier for the isSet accessor.

Since:
2.1
See Also:
isSuppressedVisibility(EStructuralFeature, int), setSuppressedVisibility(EStructuralFeature, int, boolean), Constant Field Values

UNSET

public static final int UNSET
Identifier for the unset accessor.

Since:
2.1
See Also:
isSuppressedVisibility(EStructuralFeature, int), setSuppressedVisibility(EStructuralFeature, int, boolean), Constant Field Values
Constructor Detail

EcoreUtil

public EcoreUtil()
Method Detail

getExistingAdapter

public static Adapter getExistingAdapter(Notifier notifier,
                                         java.lang.Object type)
Returns the specified notifier's existing adapter of the specified type.

Parameters:
notifier - the adapted object.
type - the type of adapter.
Returns:
an adapter associated with the specified notifier or null.

getRegisteredAdapter

public static Adapter getRegisteredAdapter(EObject eObject,
                                           java.lang.Object type)
Returns the specified eObject's adapter of the specified type. If none exists, create and add a new adapter using a registered adapter factory if one exists for the specified type.

Parameters:
eObject - the adapted object.
type - the type of adapter.
Returns:
an adapter associated with the specified eObject or null.

getRegisteredAdapter

public static Adapter getRegisteredAdapter(Resource resource,
                                           java.lang.Object type)
Returns the specified resource's adapter of the specified type. If none exists, create and add a new adapter using a registered adapter factory if one exists for the specified type.

Parameters:
resource - the adapted resource.
type - the type of adapter.
Returns:
an adapter associated with the specified eObject or null.

getAdapter

public static Adapter getAdapter(java.util.List<Adapter> adapters,
                                 java.lang.Object type)
Returns the adapter of the specified type.

Parameters:
adapters - list of adapters to search.
type - the type of adapter.
Returns:
an adapter from the list or null.

getAdapterFactory

public static AdapterFactory getAdapterFactory(java.util.List<AdapterFactory> adapterFactories,
                                               java.lang.Object type)
Returns the adapter factory for the specified adapter type.

Parameters:
adapterFactories - list of adapter factories to search.
type - the type of adapter.
Returns:
an adapter factory from the list or null.

resolve

public static EObject resolve(EObject proxy,
                              ResourceSet resourceSet)
Returns the resolved object represented by proxy. Proxy chains are followed. If resourceSet is null, the global package registry is consulted to obtain a package registered against the proxy URI, less its fragment, in the same manner as the default resource set implementation's fall-back behaviour.

Parameters:
proxy - the proxy to be resolved.
resourceSet - the resource set in which to resolve.
Returns:
the resolved object, or the proxy if unable to resolve.

resolve

public static EObject resolve(EObject proxy,
                              Resource resourceContext)
Returns the resolved object represented by proxy. Proxy chains are followed. If resourceContext is null or not in a resource set, the global package registry is consulted to obtain a package registered against the proxy URI, less its fragment, in the same manner as the default resource set implementation's fall-back behaviour.

Parameters:
proxy - the proxy to be resolved.
resourceContext - a context resource whose resource set is used for the resolve.
Returns:
the resolved object, or the proxy if unable to resolve.

resolve

public static EObject resolve(EObject proxy,
                              EObject objectContext)
Returns the resolved object represented by proxy. Proxy chains are followed. If objectContext is null or not in a resource that is in a resource set, the global package registry is consulted to obtain a package registered against the proxy URI, less its fragment, in the same manner as the default resource set implementation's fall-back behaviour.

Parameters:
proxy - the proxy to be resolved.
objectContext - a context object whose resource set is used for the resolve.
Returns:
the resolved object, or the proxy if unable to resolve.

resolveAll

public static void resolveAll(ResourceSet resourceSet)
Visits all proxies in the resource set and tries to resolve them.

Parameters:
resourceSet - the objects to visit.

resolveAll

public static void resolveAll(Resource resource)
Visits all proxies in the resource and tries to resolve them.

Parameters:
resource - the objects to visit.

resolveAll

public static void resolveAll(EObject eObject)
Visits all proxies referenced by the object or recursively any of it's contained object.

Parameters:
eObject - the object to visit.

getObjectByType

public static java.lang.Object getObjectByType(java.util.Collection<?> objects,
                                               EClassifier type)
Returns the first collection member that is an instance of the type.

Parameters:
objects - a collection of objects to check.
type - the type of object to find.
Returns:
the first object of the specified type.

getObjectsByType

public static <T> java.util.Collection<T> getObjectsByType(java.util.Collection<?> objects,
                                                           EClassifier type)
Returns a collection containing each collection member that is an instance of the type.

Parameters:
objects - a collection of objects to check.
type - the type of object to find.
Returns:
a collection of objects of the specified type.

copy

public static EObject copy(EObject eObject)
Returns a self-contained copy of the eObject.

Parameters:
eObject - the object to copy.
Returns:
the copy.
See Also:
EcoreUtil.Copier

copyAll

public static <T> java.util.Collection<T> copyAll(java.util.Collection<? extends T> eObjects)
Returns a collection of the self-contained copies of each EObject in eObjects.

Parameters:
eObjects - the collection of objects to copy.
Returns:
the collection of copies.
See Also:
EcoreUtil.Copier

getRootContainer

public static EObject getRootContainer(EObject eObject)
Returns the root container; it may be this object itself and it will have a null container.

The root container must be directly contained in a resource for its tree to be serializable.

Parameters:
eObject - the object to get the root container for.
Returns:
the root container.
See Also:
getRootContainer(EObject, boolean), EObject.eResource(), EObject.eContainer()

getRootContainer

public static EObject getRootContainer(EObject eObject,
                                       boolean resolve)
Returns the root container; it may be this object itself and it will have a null container. Container proxies are resolved or not as specified

The root container must be directly contained in a resource for its tree to be serializable.

Parameters:
eObject - the object to get the root container for.
resolve - whether to resolve container proxies.
Returns:
the root container.
See Also:
getRootContainer(EObject), EObject.eResource(), InternalEObject.eInternalContainer()

isAncestor

public static boolean isAncestor(EObject ancestorEObject,
                                 EObject eObject)
Returns whether the second object is directly or indirectly contained by the first object, i.e., whether the second object is in the content tree of the first. Container proxies are not resolved.

Parameters:
ancestorEObject - the ancestor object in question.
eObject - the object to test.
Returns:
whether the first object is an ancestor of the second object.
See Also:
EObject.eContainer()

isAncestor

public static boolean isAncestor(Resource ancestorResource,
                                 EObject eObject)
Returns whether the given resource is that of the object, i.e., whether the object is in the content tree of the resource.

Parameters:
ancestorResource - the ancestor resource in question.
eObject - the object to test.
Returns:
whether the resource is an ancestor of the object.
See Also:
EObject.eContainer(), EObject.eResource()

isAncestor

public static boolean isAncestor(ResourceSet ancestorResourceSet,
                                 EObject eObject)
Returns whether the given resource set is that of the object, i.e., whether the object is in the content tree of the resource set.

Parameters:
ancestorResourceSet - the ancestor resource set in question.
eObject - the object to test.
Returns:
whether the resource set is an ancestor of the object.
See Also:
EObject.eContainer(), EObject.eResource(), Resource.getResourceSet()

isAncestor

public static boolean isAncestor(java.util.Collection<?> ancestorEMFObjects,
                                 EObject eObject)
Returns whether any EObject, Resource, or ResourceSet in the collection is an ancestor of the EObject.

Parameters:
ancestorEMFObjects - the collection of ancestor objects in question.
eObject - the object to test.
Returns:
whether any object in the collection is an ancestor of the object.

filterDescendants

public static java.util.List<EObject> filterDescendants(java.util.Collection<? extends EObject> eObjects)
Returns a subset of the objects such that no object in the result is an ancestor of any other object in the result.

Parameters:
eObjects - the objects to be filtered.
Returns:
a subset of the objects such that no object in the result is an ancestor of any other object in the result.
Since:
2.5

getAllContents

public static <T> TreeIterator<T> getAllContents(java.util.Collection<?> emfObjects)
Returns a tree iterator over the content trees recursively defined by ResourceSet.getResources(), Resource.getContents(), and EObject.eContents(). It uses a special iterator for ResourceSet.getResources that is tolerant of growth in the underlying collection which result from demand loaded resources; the iterator will walk these additional resources.

Parameters:
emfObjects - the collection of objects to iterate over.
Returns:
a tree iterator over the objects and their contents.
See Also:
EcoreUtil.ContentTreeIterator

getAllContents

public static <T> TreeIterator<T> getAllContents(java.util.Collection<?> emfObjects,
                                                 boolean resolve)
Returns a tree iterator over the content trees recursively defined by ResourceSet.getResources(), Resource.getContents(), and EObject.eContents(). It uses a special iterator for ResourceSet.getResources that is tolerant of growth in the underlying collection which result from demand loaded resources; the iterator will walk these additional resources. Contained proxies are resolved or not as specified.

Parameters:
emfObjects - the collection of objects to iterate over.
resolve - whether proxies should be resolved.
Returns:
a tree iterator over the objects and their contents.
See Also:
EcoreUtil.ContentTreeIterator

getAllContents

public static <T> TreeIterator<T> getAllContents(EObject eObject,
                                                 boolean resolve)
Returns a tree iterator that iterates over all the direct contents and indirect contents of the object.

Parameters:
eObject - the object to iterate over.
resolve - whether proxies should be resolved.
Returns:
a tree iterator that iterates over all contents.
See Also:
EObject.eAllContents(), Resource.getAllContents()

getAllContents

public static <T> TreeIterator<T> getAllContents(Resource resource,
                                                 boolean resolve)
Returns a tree iterator that iterates over all the direct contents and indirect contents of the resource.

Parameters:
resource - the resource to iterate over.
resolve - whether proxies should be resolved.
Returns:
a tree iterator that iterates over all contents.
See Also:
EObject.eAllContents(), ResourceSet.getAllContents()

getAllContents

public static <T> TreeIterator<T> getAllContents(ResourceSet resourceSet,
                                                 boolean resolve)
Returns a tree iterator that iterates over all the direct resources in the resource set and over the content tree of each.

Parameters:
resourceSet - the resource set to iterate over.
resolve - whether proxies should be resolved.
Returns:
a tree iterator that iterates over all contents.
See Also:
EObject.eAllContents(), Resource.getAllContents(), getAllProperContents(Resource, boolean)

getAllProperContents

public static <T> TreeIterator<T> getAllProperContents(java.util.Collection<?> emfObjects,
                                                       boolean resolve)
Returns a tree iterator over the content trees recursively defined by ResourceSet.getResources(), Resource.getContents(), and EObject.eContents(), skipping over any child object that's in a different resource from its parent. It uses a special iterator for ResourceSet.getResources that is tolerant of growth in the underlying collection which result from demand loaded resources; the iterator will walk these additional resources. Contained proxies are resolved or not as specified.

Parameters:
emfObjects - the collection of objects to iterate over.
resolve - whether proxies should be resolved.
Returns:
a tree iterator over the objects and their contents.
See Also:
EcoreUtil.ContentTreeIterator

getAllProperContents

public static <T> TreeIterator<T> getAllProperContents(EObject eObject,
                                                       boolean resolve)
Returns a tree iterator that iterates over all the direct contents and indirect contents of the object, skipping over any child object that's in a different resource from its parent.

Parameters:
eObject - the object to iterate over.
resolve - whether proxies should be resolved.
Returns:
a tree iterator that iterates over all contents.
See Also:
EObject.eAllContents(), Resource.getAllContents()

getAllProperContents

public static <T> TreeIterator<T> getAllProperContents(Resource resource,
                                                       boolean resolve)
Returns a tree iterator that iterates over all the direct contents and indirect contents of the resource, skipping over any child object that's in a different resource from its parent.

Parameters:
resource - the resource to iterate over.
resolve - whether proxies should be resolved.
Returns:
a tree iterator that iterates over all contents.
See Also:
EObject.eAllContents(), ResourceSet.getAllContents()

getAllProperContents

public static <T> TreeIterator<T> getAllProperContents(ResourceSet resourceSet,
                                                       boolean resolve)
Returns a tree iterator that iterates over all the direct resources in the resource set and over the content tree of each, skipping over any child object that's in a different resource from its parent.

Parameters:
resourceSet - the resource set to iterate over.
resolve - whether proxies should be resolved.
Returns:
a tree iterator that iterates over all contents.
See Also:
EObject.eAllContents(), Resource.getAllContents(), getAllContents(ResourceSet, boolean)

equals

public static boolean equals(EObject eObject1,
                             EObject eObject2)
Returns true if eObject1 and eObject2 are equal, false otherwise.

Returns:
whether eObject1 and eObject2 are equal.
Since:
2.1.0
See Also:
EcoreUtil.EqualityHelper

getIdentification

public static java.lang.String getIdentification(EObject eObject)
Returns a unique string identification of the eObject; it is structured as follows:
  <java-class-name>[/<dynamic-eClass-name>]@<java-hex-hash-code>{<uri-of-eObject>}

Parameters:
eObject - the object for which to get an identification.
Returns:
the identification string for the object.

getURI

public static URI getURI(EObject eObject)
Returns a URI for the eObject, i.e., either the eProxyURI, the URI of the eResource with the fragment produced by the eResource, or the URI consisting of just the fragment that would be produced by a default Resource with the eObject as its only contents.

Parameters:
eObject - the object for which to get the URI.
Returns:
the URI for the object.

indexOf

@Deprecated
public static int indexOf(java.util.List<?> list,
                                     java.lang.Object o,
                                     int fromIndex)
Deprecated. replaced by ECollections.indexOf(List, Object, int) in 2.1.0

Searches for the first occurrence of the given argument in list starting from a specified index. The equality is tested using the operator == and the equals method.

Parameters:
list -
o - an object (can be null)
fromIndex -
Returns:
the index of the first occurrence of the argument in this list (where index>=fromIndex); returns -1 if the object is not found.

setEList

@Deprecated
public static <T> void setEList(EList<T> eList,
                                           java.util.Collection<? extends T> prototypeCollection)
Deprecated. replaced by ECollections.setEList(EList, List) in 2.1.0

Sets the eList's contents and order to be exactly that of the prototype collection. This implementation minimizes the number of notifications the operation will produce. Objects already in the list will be moved, missing objects will be added, and extra objects will be removed. If eList's contents and order are already exactly that of the prototype collection, no change will be made.

Parameters:
eList - the list to set.
prototypeCollection - the collection representing the desired content and order.

setEList

@Deprecated
public static <T> void setEList(EList<T> eList,
                                           java.util.List<? extends T> prototypeList)
Deprecated. replaced by ECollections.setEList(EList, List) in 2.1.0

Sets the eList's contents and order to be exactly that of the prototype list. This implementation minimizes the number of notifications the operation will produce. Objects already in the list will be moved, missing objects will be added, and extra objects will be removed. If eList's contents and order are already exactly that of the prototype list, no change will be made.

Parameters:
eList - the list to set.
prototypeList - the list representing the desired content and order.

remove

public static void remove(EStructuralFeature.Setting setting,
                          java.lang.Object value)
Removes the value from the setting.

Parameters:
setting - the setting holding the value.
value - the value to remove.

replace

public static void replace(EStructuralFeature.Setting setting,
                           java.lang.Object oldValue,
                           java.lang.Object newValue)
Replaces the old value in the setting with the new value.

Parameters:
setting - the setting holding the values.
oldValue - the value to replace.
newValue - the replacement value.

remove

public static void remove(EObject eObject,
                          EStructuralFeature eStructuralFeature,
                          java.lang.Object value)
Removes the value from the feature of the object.

Parameters:
eObject - the object holding the value.
eStructuralFeature - the feature of the object holding the value.
value - the value to remove.

replace

public static void replace(EObject eObject,
                           EStructuralFeature eStructuralFeature,
                           java.lang.Object oldValue,
                           java.lang.Object newValue)
Replaces the old value in the object's feature with the new value.

Parameters:
eObject - the object holding the values.
eStructuralFeature - the feature of the object holding the values.
oldValue - the value to replace.
newValue - the replacement value.

remove

public static void remove(EObject eObject)
Removes the object from its containing resource and/or its containing object.

Parameters:
eObject - the object to remove.

replace

public static void replace(EObject eObject,
                           EObject replacementEObject)
Replace the object in its containing resource and/or its containing object, with the replacement object.

Parameters:
eObject - the object to replace.
replacementEObject - the replacement object.

delete

public static void delete(EObject eObject)
Deletes the object from its containing resource and/or its containing object as well as from any other feature that references it within the enclosing resource set, resource, or root object.

Parameters:
eObject - the object to delete.
Since:
2.3

delete

public static void delete(EObject eObject,
                          boolean recursive)
Deletes the object from its containing resource and/or its containing object as well as from any other feature that references it within the enclosing resource set, resource, or root object. If recursive true, contained children of the object that are in the same resource are similarly removed from any features that references them.

Parameters:
eObject - the object to delete.
recursive - whether references to contained children should also be removed.
Since:
2.4

create

public static EObject create(EClass eClass)
Creates an instance of the class.

Parameters:
eClass - the class to instantiate.
Returns:
an instance of the class.

createFromString

public static java.lang.Object createFromString(EDataType eDataType,
                                                java.lang.String literal)
Creates an instance of the datatype.

Parameters:
eDataType - the datatype to instantiate.
literal - the string value of the datatype.
Returns:
an instance of the datatype.
See Also:
convertToString(EDataType, Object)

convertToString

public static java.lang.String convertToString(EDataType eDataType,
                                               java.lang.Object value)
Converts an instance of the data type to a string literal representation.

Parameters:
eDataType - the data type to instantiate.
value - a value of the data type.
Returns:
the string literal representation of the value.
See Also:
createFromString(EDataType, String)

getID

public static java.lang.String getID(EObject eObject)
Returns the value of the object's ID attribute as a String. If the object has no ID attribute or the ID attribute is not set, it returns null.

Parameters:
eObject - the object in question.
Returns:
the value of the object's ID attribute as a String.
See Also:
EAttribute.isID(), EClass.getEIDAttribute(), setID(EObject, String)

setID

public static void setID(EObject eObject,
                         java.lang.String id)
Sets the value of the object's ID attribute according to the value represented by the String. A null ID will unset the attribute rather than setting it to null.

Parameters:
eObject - the object in question.
id - the String value of the new ID.
Throws:
java.lang.IllegalArgumentException - if the object has no ID attribute.
See Also:
getID(EObject), EAttribute.isID(), EClass.getEIDAttribute()

wrapperClassFor

public static java.lang.Class<?> wrapperClassFor(java.lang.Class<?> javaClass)
Returns the wrapper class for the primitive class, or the original class, if it's not a primitive class.

Parameters:
javaClass -

getDocumentation

public static java.lang.String getDocumentation(EModelElement eModelElement)

setDocumentation

public static void setDocumentation(EModelElement eModelElement,
                                    java.lang.String documentation)

getConstraints

public static java.util.List<java.lang.String> getConstraints(EModelElement eModelElement)

setConstraints

public static void setConstraints(EModelElement eModelElement,
                                  java.util.List<java.lang.String> constraints)

getAnnotation

public static java.lang.String getAnnotation(EModelElement eModelElement,
                                             java.lang.String sourceURI,
                                             java.lang.String key)

setAnnotation

public static void setAnnotation(EModelElement eModelElement,
                                 java.lang.String sourceURI,
                                 java.lang.String key,
                                 java.lang.String value)

isSuppressedVisibility

public static boolean isSuppressedVisibility(EStructuralFeature eStructuralFeature,
                                             int accessor)
Tests whether the given structural feature has been annotated to prevent generation of accessor methods in its interface.

Parameters:
eStructuralFeature - the structural feature
accessor - the type of accessor method, one of GET, SET, IS_SET, or UNSET
Returns:
whether the specified accessor's visibility is suppressed
Since:
2.1

setSuppressedVisibility

public static void setSuppressedVisibility(EStructuralFeature eStructuralFeature,
                                           int accessor,
                                           boolean suppress)
Sets or removes annotations on the given structural feature to prevent generation of accessor methods in its interface.

Parameters:
eStructuralFeature - the structural feature
accessor - the type of accessor method, one of GET, SET, IS_SET, or UNSET
suppress - whether the specified accessor's visibility should be suppressed
Since:
2.1

isSuppressedVisibility

public static boolean isSuppressedVisibility(EOperation eOperation)
Tests whether the given operation has been annotated to prevent generation of a method declaration in its interface.

Parameters:
eOperation - the operation.
Returns:
whether the visibility is suppressed
Since:
2.4

setSuppressedVisibility

public static void setSuppressedVisibility(EOperation eOperation,
                                           boolean suppress)
Sets or removes the annotation on the given operation to prevent generation of a method declaration in its interface.

Parameters:
eOperation - the operation.
suppress - whether the visibility should be suppressed
Since:
2.4

generateUUID

public static java.lang.String generateUUID()
Generates a universally unique identifier, i.e., a UUID. It encodes the 128 bit UUID in base 64, but rather than padding the encoding with two "=" characters, it prefixes the encoding with a single "_" character, to ensure that the result is a valid ID, i.e., an NCName

Returns:
a universally unique identifier.

generateUUID

public static void generateUUID(byte[] uuid)
Generates a universally unique identifier, i.e., a UUID. The argument is filled in with the 128 bit UUID and hence must be at least 16 bytes in length.

Parameters:
uuid - the value to receive the result.

freeze

public static void freeze(EPackage ePackage)
Marks the package to indicate that it and everything it contains or that its contents depend on can no longer be changed. This helps to improve the performance of the model but has no other effect.


computeDiagnostic

public static Diagnostic computeDiagnostic(Resource resource,
                                           boolean includeWarnings)
Computes a Diagnostic from the errors and warnings stored in the specified resource.

Parameters:
resource -
includeWarnings -
Returns:
Diagnostic

toJavaInstanceTypeName

public static java.lang.String toJavaInstanceTypeName(EGenericType eGenericType)
Converts a generic type to its Java representation.

Parameters:
eGenericType - the generic type to convert.
Returns:
the Java representation of the generic type.

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