public final class EObjectUtil
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
DEFAULT_EMF_MODEL_IMPLEMENTATION_PACKAGE_SUFFIX |
static int |
DEPTH_INFINITE
Depth constant (value 2) indicating this EObject and its direct and indirect members at any depth.
|
static int |
DEPTH_ONE
Depth constant (value 1) indicating this EObject and its direct members.
|
static int |
DEPTH_ZERO
Depth constant (value 0) indicating this EObject, but not any of its members.
|
Modifier and Type | Method and Description |
---|---|
static org.eclipse.emf.ecore.EObject |
createProxyFrom(org.eclipse.emf.ecore.EObject eObject)
Deprecated.
Use
createProxyFrom(EObject, Resource) instead. |
static org.eclipse.emf.ecore.EObject |
createProxyFrom(org.eclipse.emf.ecore.EObject eObject,
org.eclipse.emf.ecore.resource.Resource contextResource)
Creates a proxy representing given
object . |
static org.eclipse.emf.ecore.EObject |
deproxify(org.eclipse.emf.ecore.EObject eObject)
Turns a given proxy EObject into a normal EObject.
|
static org.eclipse.emf.ecore.EClassifier |
findEClassifier(org.eclipse.emf.ecore.EPackage rootEPackage,
java.lang.Class<?> type)
Return the EClassifier in the given EPakcage by Class
|
static org.eclipse.emf.ecore.EClassifier |
findEClassifier(org.eclipse.emf.ecore.EPackage rootEPackage,
java.lang.String typeName)
Return the EClassifier in the given EPackage by typeName
|
static org.eclipse.emf.ecore.EPackage |
findEPackage(java.lang.Class<?> eClassifierType)
Finds the
EPackage that contains the EClassifier behind given Java eClassifierType . |
static java.util.List<org.eclipse.emf.ecore.EClass> |
findESubTypesOf(org.eclipse.emf.ecore.EClass eClass,
boolean concreteTypesOnly)
Returns all EClasses which are derived from a given EClass.
|
static <T> java.util.List<T> |
getAllInstancesOf(java.util.Collection<org.eclipse.emf.ecore.resource.Resource> resources,
java.lang.Class<T> type,
boolean exactMatch)
Returns all instances of a certain type within a specified set of Resources.
|
static <T> java.util.List<T> |
getAllInstancesOf(org.eclipse.emf.ecore.EObject contextObject,
java.lang.Class<T> type,
boolean exactMatch)
Returns all instances of a certain type within a specified ResourceSet.
|
static java.util.List<org.eclipse.emf.ecore.EObject> |
getAllInstancesOf(org.eclipse.emf.ecore.EObject contextObject,
org.eclipse.emf.ecore.EReference eReference,
boolean exactMatch)
Returns all instances of a certain type within a specified ResourceSet.
|
static <T> java.util.List<T> |
getAllInstancesOf(IModelDescriptor modelDescriptor,
java.lang.Class<T> type,
boolean exactMatch)
Returns all instances of a certain type within a specified ResourceSet.
|
static <T> java.util.List<T> |
getAllInstancesOf(org.eclipse.emf.ecore.resource.Resource contextResource,
java.lang.Class<T> type,
boolean exactMatch)
Returns all instances of a certain type within a specified ResourceSet.
|
static java.util.List<org.eclipse.emf.ecore.EClassifier> |
getAnnotatedEClassifiers(org.eclipse.emf.ecore.EPackage ePackage,
java.lang.String annotationSource,
java.lang.String detailKey,
java.lang.String detailValue) |
static java.util.List<org.eclipse.emf.ecore.EClassifier> |
getEContainerClassifiers(org.eclipse.emf.ecore.EClass eClass)
Return all EClassifiers that are containers and have a containment reference to the specified EClass
|
static java.lang.String |
getEMFModelInterfacePackageName(java.lang.Class<?> ePackageType)
Returns the name of the Java package that contains the interfaces for the EMF metamodel elements defined in the
EPackage behind provided EPackage class. |
static org.eclipse.emf.ecore.EStructuralFeature |
getEStructuralFeature(java.lang.Object owner,
int featureID)
Returns the EStructuralFeature specified by the
featureID . |
static org.eclipse.emf.ecore.EStructuralFeature |
getEStructuralFeature(java.lang.Object owner,
java.lang.String featureName)
Returns the EStructuralFeature specified by the
featureName . |
static java.util.Collection<org.eclipse.emf.ecore.EStructuralFeature.Setting> |
getInverseReferences(org.eclipse.emf.ecore.EObject object,
boolean resolve)
Returns a collection of
settings objects describing the inverse references of
given object , i.e., the objects s and features s that
reference given object . |
static java.lang.String |
getMixedText(org.eclipse.emf.ecore.util.FeatureMap mixed)
Return mixedText of the given FeatureMap
|
static java.util.List<org.eclipse.emf.ecore.EObject> |
getOrphans(org.eclipse.emf.ecore.EObject owner,
org.eclipse.emf.ecore.EReference reference)
Returns all orphan objects referenced by specified source object via given reference.
|
static <T> java.util.List<T> |
getReferencedInstancesOf(org.eclipse.emf.ecore.EObject owner,
org.eclipse.emf.ecore.EReference reference,
java.lang.Class<T> type,
boolean exactMatch)
Return all instance of reference objects (which is many) of the given object
|
static boolean |
isAssignableFrom(org.eclipse.emf.ecore.EClass eClass,
java.lang.String typeName)
Tests if given EClass is assignment compatible with type with specified name, i.e.
|
static org.eclipse.emf.ecore.EObject |
proxify(org.eclipse.emf.ecore.EObject eObject)
Turns given
EObject in to a proxy object using an URI composed of the URI of the resource the
EObject is in plus the URI fragment relative to that resource. |
static org.eclipse.emf.ecore.EObject |
proxify(org.eclipse.emf.ecore.EObject oldOwner,
org.eclipse.emf.ecore.EStructuralFeature oldFeature,
org.eclipse.emf.ecore.EObject eObject)
Turns given
EObject in to a proxy object using an URI composed of the URI of the resource the
EObject is in plus the URI fragment relative to that resource. |
static void |
resolveAll(org.eclipse.emf.ecore.resource.Resource resource)
Visits all proxies in given
resource and tries to resolve them. |
static void |
setMixedText(org.eclipse.emf.ecore.util.FeatureMap mixed,
java.lang.String text)
Set mixed text of the given FeatureMap
|
public static final java.lang.String DEFAULT_EMF_MODEL_IMPLEMENTATION_PACKAGE_SUFFIX
public static final int DEPTH_ZERO
public static final int DEPTH_ONE
public static final int DEPTH_INFINITE
public static java.util.List<org.eclipse.emf.ecore.EObject> getAllInstancesOf(org.eclipse.emf.ecore.EObject contextObject, org.eclipse.emf.ecore.EReference eReference, boolean exactMatch)
contextObject
- The context object used to calculate the context inside which instances of the expected type must be
returned.eReference
- The eReference of objects that must be returned.exactMatch
- The kind of search:
public static <T> java.util.List<T> getAllInstancesOf(org.eclipse.emf.ecore.EObject contextObject, java.lang.Class<T> type, boolean exactMatch)
contextObject
- The context EObject used to calculate the context inside which instances of the expected type must be
returned.type
- The expected type of objects that must be returned.exactMatch
- The kind of search:
public static <T> java.util.List<T> getAllInstancesOf(org.eclipse.emf.ecore.resource.Resource contextResource, java.lang.Class<T> type, boolean exactMatch)
contextResource
- The context resource used to calculate the context inside which instances of the expected type must be
returned.type
- The expected type of objects that must be returned.exactMatch
- The kind of search:
public static <T> java.util.List<T> getAllInstancesOf(IModelDescriptor modelDescriptor, java.lang.Class<T> type, boolean exactMatch)
modelDescriptor
- The model descriptor used to calculate the context inside which instances of the expected type must be
returned.type
- The expected type of objects that must be returned.exactMatch
- The kind of search:
public static <T> java.util.List<T> getAllInstancesOf(java.util.Collection<org.eclipse.emf.ecore.resource.Resource> resources, java.lang.Class<T> type, boolean exactMatch)
resources
- The list of resources inside which instances of the expected type must be returned.type
- The expected type of objects that must be returned.exactMatch
- The kind of search:
public static <T> java.util.List<T> getReferencedInstancesOf(org.eclipse.emf.ecore.EObject owner, org.eclipse.emf.ecore.EReference reference, java.lang.Class<T> type, boolean exactMatch)
owner
- The given object to get referenced instances.reference
- The reference to get.type
- The expected type of objects to returnexactMatch
- The kind of search:
owner
object. Or an empty list if
the owner doesn't have the reference as requiredpublic static java.util.Collection<org.eclipse.emf.ecore.EStructuralFeature.Setting> getInverseReferences(org.eclipse.emf.ecore.EObject object, boolean resolve)
settings
objects describing the inverse references of
given object
, i.e., the objects
s and features
s that
reference given object
.object
- The object
whose inverse references
are to beresolve
- Determines whether or not proxies should be resolved.inverse references
of given object
or and empty collection if no such could be found.public static org.eclipse.emf.ecore.EPackage findEPackage(java.lang.Class<?> eClassifierType)
EPackage
that contains the EClassifier
behind given Java eClassifierType
.eClassifierType
- The Java type of the EClassifier
in question.EPackage
that contains the EClassifier
behind eClassifierType
or
null
if eClassifierType
refers to a Java type that is not an EClassifier or
EPackage for the EClassifier cannot be found.public static java.lang.String getEMFModelInterfacePackageName(java.lang.Class<?> ePackageType)
EPackage
behind provided EPackage class.
Makes the assumption that the interface package is either the same package as the Java package that contains the given EPackage class or its parent package in case that the provided EPackage class resides in a Java package that is postfixed with ".impl" (which corresponds to the default behavior of the EMF code generator).
ePackageType
- The EPackage to be processed.public static org.eclipse.emf.ecore.EClassifier findEClassifier(org.eclipse.emf.ecore.EPackage rootEPackage, java.lang.Class<?> type)
rootEPackage
- The package container of return EClassifierstype
- The specified class to findnull
if there isn't any
EClassifier has the given type
.public static org.eclipse.emf.ecore.EClassifier findEClassifier(org.eclipse.emf.ecore.EPackage rootEPackage, java.lang.String typeName)
rootEPackage
- The package container of return EClassifierstypeName
- The given name of the EClassifier to returnEClassifier
in the given rootPackage and its subPackages .
null
if there isn't any EClassifier has the given typeName
public static java.util.List<org.eclipse.emf.ecore.EClass> findESubTypesOf(org.eclipse.emf.ecore.EClass eClass, boolean concreteTypesOnly)
eClass
- The EClass from which the returned EClasses have to be derived.concreteTypesOnly
- If set to true only EClasses describing concrete classes will be returned. EClasses
describing interfaces and abstract classes will be excluded from the result.eClass
.public static boolean isAssignableFrom(org.eclipse.emf.ecore.EClass eClass, java.lang.String typeName)
eClass
- the EClass to be tested.typeName
- the name of the type.public static java.util.List<org.eclipse.emf.ecore.EClassifier> getEContainerClassifiers(org.eclipse.emf.ecore.EClass eClass)
eClass
- The class whose container classifiers must be returned.public static java.util.List<org.eclipse.emf.ecore.EClassifier> getAnnotatedEClassifiers(org.eclipse.emf.ecore.EPackage ePackage, java.lang.String annotationSource, java.lang.String detailKey, java.lang.String detailValue)
ePackage
- The EPackage container of returned EClassifiersannotationSource
- The full URI representing the type of an annotation to filterdetailKey
- The given key of the annotationSource to filterdetailValue
- The given value of specified key of the annotationSource to filterannotationSource
anddetailKey
anddetailValue
public static org.eclipse.emf.ecore.EStructuralFeature getEStructuralFeature(java.lang.Object owner, java.lang.String featureName)
featureName
. The method will return the
EStructuralFeature if it exists for a given EClass or EObject. If the provided Object is not an EClass or an
EObject or the EStructuralFeature does not exist, null
is returned.owner
- The EClass or EObject from which the EStructuralFeature is to be resolved.featureName
- The name of the EStructuralFeature.object
is an EClass or EObject and the
EStructuralFeature exists, otherwise null
is returned.public static org.eclipse.emf.ecore.EStructuralFeature getEStructuralFeature(java.lang.Object owner, int featureID)
featureID
. The method will return the
EStructuralFeature if it exists for a given EClass or EObject. If the provided Object is not an EClass or an
EObject or the EStructuralFeature does not exist, null
is returned.owner
- The EClass or EObject from which the EStructuralFeature is to be resolved.featureID
- The id of the EStructuralFeature.object
is an EClass or EObject and the
EStructuralFeature exists, otherwise null
is returned.public static java.util.List<org.eclipse.emf.ecore.EObject> getOrphans(org.eclipse.emf.ecore.EObject owner, org.eclipse.emf.ecore.EReference reference)
owner
- The owner object of the returned objectsreference
- The given Reference to find orphanspublic static java.lang.String getMixedText(org.eclipse.emf.ecore.util.FeatureMap mixed)
mixed
- The given FeatureMap to get textpublic static void setMixedText(org.eclipse.emf.ecore.util.FeatureMap mixed, java.lang.String text)
mixed
- The given FeatureMap to set texttext
- The input text set to the FeatureMappublic static org.eclipse.emf.ecore.EObject proxify(org.eclipse.emf.ecore.EObject eObject)
EObject
in to a proxy object using an URI
composed of the URI of the resource the
EObject is in plus the URI fragment relative to that resource.eObject
- The EObject
to be proxified.eObject
is returned. If the proxy could not be created the given
EObject
itself is returned.public static org.eclipse.emf.ecore.EObject proxify(org.eclipse.emf.ecore.EObject oldOwner, org.eclipse.emf.ecore.EStructuralFeature oldFeature, org.eclipse.emf.ecore.EObject eObject)
EObject
in to a proxy object using an URI
composed of the URI of the resource the
EObject is in plus the URI fragment relative to that resource.oldOwner
- The old owner of the EObject
to be proxifiedoldFeature
- The containment reference of the EObject
to be proxifiedeObject
- The EObject
to be proxified.eObject
is returned. If the proxy could not be created the given
EObject
itself is returned.public static org.eclipse.emf.ecore.EObject deproxify(org.eclipse.emf.ecore.EObject eObject)
eObject
.eObject
- The proxy EObject.eObject
is returned.public static org.eclipse.emf.ecore.EObject createProxyFrom(org.eclipse.emf.ecore.EObject eObject, org.eclipse.emf.ecore.resource.Resource contextResource)
object
. The given object is used as a template to create the
proxy, i.e. the resulting proxy will have the same type and a proxy URI
which references the given
object.eObject
- The object
for which the proxy is to be created.contextResource
- The resource
that is going to contain the newly created proxy.null
if no such could be created.@Deprecated public static org.eclipse.emf.ecore.EObject createProxyFrom(org.eclipse.emf.ecore.EObject eObject)
createProxyFrom(EObject, Resource)
instead.public static void resolveAll(org.eclipse.emf.ecore.resource.Resource resource)
resource
and tries to resolve them.
Does principally the same thing as EcoreUtil.resolveAll(Resource)
but provides more robustness by
catching exceptions that are raised during proxy resolution and attaching them as errors on given
resource
.
resource
- The resource
to visit.EcoreUtil.resolveAll(Resource)