org.eclipse.emf.cdo.common.model
Class EMFUtil

java.lang.Object
  extended by org.eclipse.emf.cdo.common.model.EMFUtil

public final class EMFUtil
extends Object

Various static helper methods for dealing with EMF meta models.

Since:
2.0

Nested Class Summary
static class EMFUtil.ExtResourceSet
          An extension of ResourceSetImpl that allows demandLoading of resources and delegation of resource lookups, to be switched on/off as desired.
 
Field Summary
static Predicate<EStructuralFeature> ATTRIBUTES
           
static String CDO_ANNOTATION_KEY_PERSISTENT
           
static String CDO_ANNOTATION_SOURCE
           
static Predicate<EStructuralFeature> CONTAINER_REFERENCES
           
static Predicate<EStructuralFeature> CONTAINMENT_REFERENCES
           
static Predicate<EStructuralFeature> CROSS_REFERENCES
           
static EReference ECLASS_EGENERIC_SUPER_TYPES
           
static EReference ECLASS_ESUPER_TYPES
           
static EAttribute ECLASSIFIER_INSTANCE_CLASS_NAME
           
static EAttribute ECLASSIFIER_INSTANCE_TYPE_NAME
           
static EReference EOPERATION_EEXCEPTIONS
           
static EReference EOPERATION_EGENERIC_EXCEPTIONS
           
static EReference ETYPED_ELEMENT_EGENERIC_TYPE
           
static EReference ETYPED_ELEMENT_ETYPE
           
static Predicate<EStructuralFeature> REFERENCES
           
 
Method Summary
static void addAdapter(Notifier notifier, Adapter adapter)
           
static EAttribute createEAttribute(EClass eClass, String name, EClassifier type)
           
static EClass createEClass(EPackage ePackage, String name, boolean isAbstract, boolean isInterface)
           
static EPackage createEPackage(String uri, byte[] bytes, boolean zipped, ResourceSet resourceSet, boolean lookForResource)
           
static EPackage createEPackage(String name, String nsPrefix, String nsURI)
           
static EReference createEReference(EClass eClass, String name, EClassifier type, boolean isRequired, boolean isMany)
           
static EMFUtil.ExtResourceSet createExtResourceSet(InternalCDOPackageRegistry packageRegistry, boolean delegating, boolean demandLoading)
           
static
<T> T
getAdapter(Notifier notifier, Class<T> type)
           
static EPackage[] getAllPackages(EPackage ePackage)
           
static EClass[] getConcreteClasses(EPackage ePackage)
           
static byte[] getEPackageBytes(EPackage ePackage, boolean zipped, EPackage.Registry packageRegistry)
           
static EPackage getGeneratedEPackage(EPackage ePackage)
           
static String getParentURI(EPackage ePackage)
           
static EClass[] getPersistentClasses(EPackage ePackage)
           
static List<EStructuralFeature> getPersistentFeatures(EList<EStructuralFeature> eFeatures)
          Deprecated. This method is expensive and will be removed in the future.
static URI getPositionalURI(InternalEObject internalEObject)
           
static String getQualifiedName(EClassifier classifier, String separator)
           
static String getQualifiedName(EPackage ePackage, String separator)
           
static Map.Entry<String,Object>[] getSortedRegistryEntries(EPackage.Registry packageRegistry)
           
static EPackage getTopLevelPackage(EPackage ePackage)
           
static boolean isDynamicEPackage(Object value)
           
static boolean isPersistent(EStructuralFeature feature)
          Returns true if CDO considers the given feature persistent, false otherwise.
static ResourceSet newEcoreResourceSet()
           
static ResourceSet newEcoreResourceSet(EPackage.Registry packageRegistry)
           
static ResourceSet newResourceSet(Resource.Factory resourceFactory)
           
static void registerPackage(EPackage ePackage, EPackage.Registry... packageRegistries)
           
static EObject safeResolve(EObject proxy, ResourceSet resourceSet)
           
static void safeResolveAll(ResourceSet resourceSet)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CDO_ANNOTATION_SOURCE

public static final String CDO_ANNOTATION_SOURCE
Since:
3.0
See Also:
Constant Field Values

CDO_ANNOTATION_KEY_PERSISTENT

public static final String CDO_ANNOTATION_KEY_PERSISTENT
Since:
3.0
See Also:
Constant Field Values

EOPERATION_EEXCEPTIONS

public static final EReference EOPERATION_EEXCEPTIONS
Since:
4.2

ETYPED_ELEMENT_ETYPE

public static final EReference ETYPED_ELEMENT_ETYPE
Since:
4.2

ECLASS_ESUPER_TYPES

public static final EReference ECLASS_ESUPER_TYPES
Since:
4.2

ECLASSIFIER_INSTANCE_CLASS_NAME

public static final EAttribute ECLASSIFIER_INSTANCE_CLASS_NAME
Since:
4.2

EOPERATION_EGENERIC_EXCEPTIONS

public static final EReference EOPERATION_EGENERIC_EXCEPTIONS
Since:
4.2

ETYPED_ELEMENT_EGENERIC_TYPE

public static final EReference ETYPED_ELEMENT_EGENERIC_TYPE
Since:
4.2

ECLASS_EGENERIC_SUPER_TYPES

public static final EReference ECLASS_EGENERIC_SUPER_TYPES
Since:
4.2

ECLASSIFIER_INSTANCE_TYPE_NAME

public static final EAttribute ECLASSIFIER_INSTANCE_TYPE_NAME
Since:
4.2

ATTRIBUTES

public static final Predicate<EStructuralFeature> ATTRIBUTES
Since:
4.2

REFERENCES

public static final Predicate<EStructuralFeature> REFERENCES
Since:
4.2

CONTAINER_REFERENCES

public static final Predicate<EStructuralFeature> CONTAINER_REFERENCES
Since:
4.2

CROSS_REFERENCES

public static final Predicate<EStructuralFeature> CROSS_REFERENCES
Since:
4.2

CONTAINMENT_REFERENCES

public static final Predicate<EStructuralFeature> CONTAINMENT_REFERENCES
Since:
4.2
Method Detail

getPositionalURI

public static URI getPositionalURI(InternalEObject internalEObject)
Since:
4.2

getGeneratedEPackage

public static EPackage getGeneratedEPackage(EPackage ePackage)

getSortedRegistryEntries

public static Map.Entry<String,Object>[] getSortedRegistryEntries(EPackage.Registry packageRegistry)

getTopLevelPackage

public static EPackage getTopLevelPackage(EPackage ePackage)

createEPackage

public static EPackage createEPackage(String name,
                                      String nsPrefix,
                                      String nsURI)
Since:
2.0

createEClass

public static EClass createEClass(EPackage ePackage,
                                  String name,
                                  boolean isAbstract,
                                  boolean isInterface)
Since:
2.0

createEAttribute

public static EAttribute createEAttribute(EClass eClass,
                                          String name,
                                          EClassifier type)
Since:
2.0

createEReference

public static EReference createEReference(EClass eClass,
                                          String name,
                                          EClassifier type,
                                          boolean isRequired,
                                          boolean isMany)
Since:
2.0

getConcreteClasses

public static EClass[] getConcreteClasses(EPackage ePackage)
Since:
4.2

getPersistentClasses

public static EClass[] getPersistentClasses(EPackage ePackage)

getPersistentFeatures

@Deprecated
public static List<EStructuralFeature> getPersistentFeatures(EList<EStructuralFeature> eFeatures)
Deprecated. This method is expensive and will be removed in the future.

Since:
3.0
See Also:
isPersistent(EStructuralFeature)

isPersistent

public static boolean isPersistent(EStructuralFeature feature)
Returns true if CDO considers the given feature persistent, false otherwise.

Note that CDO persistent is not identical to non-transient because that can be overridden with CDO_ANNOTATION_KEY_PERSISTENT. Another reason for possible deviations is that CDO considers transient references persistent if they have a persistent opposite.

Note also that the checks for the aforementioned deviations from EStructuralFeature.isTransient() make this method somewhat expensive. Whenever possible CDOClassInfo.isPersistent() should be called instead.

Since:
3.0

isDynamicEPackage

public static boolean isDynamicEPackage(Object value)

getParentURI

public static String getParentURI(EPackage ePackage)

registerPackage

public static void registerPackage(EPackage ePackage,
                                   EPackage.Registry... packageRegistries)

getEPackageBytes

public static byte[] getEPackageBytes(EPackage ePackage,
                                      boolean zipped,
                                      EPackage.Registry packageRegistry)

createEPackage

public static EPackage createEPackage(String uri,
                                      byte[] bytes,
                                      boolean zipped,
                                      ResourceSet resourceSet,
                                      boolean lookForResource)
Since:
3.0

getAdapter

public static <T> T getAdapter(Notifier notifier,
                               Class<T> type)
Since:
4.2

addAdapter

public static void addAdapter(Notifier notifier,
                              Adapter adapter)

getAllPackages

public static EPackage[] getAllPackages(EPackage ePackage)

getQualifiedName

public static String getQualifiedName(EPackage ePackage,
                                      String separator)

getQualifiedName

public static String getQualifiedName(EClassifier classifier,
                                      String separator)

newResourceSet

public static ResourceSet newResourceSet(Resource.Factory resourceFactory)

newEcoreResourceSet

public static ResourceSet newEcoreResourceSet(EPackage.Registry packageRegistry)

newEcoreResourceSet

public static ResourceSet newEcoreResourceSet()

safeResolve

public static EObject safeResolve(EObject proxy,
                                  ResourceSet resourceSet)
Since:
3.0

safeResolveAll

public static void safeResolveAll(ResourceSet resourceSet)
Since:
3.0

createExtResourceSet

public static EMFUtil.ExtResourceSet createExtResourceSet(InternalCDOPackageRegistry packageRegistry,
                                                          boolean delegating,
                                                          boolean demandLoading)
Since:
4.0
See Also:
EMFUtil.ExtResourceSet


Copyright (c) 2011, 2012 Eike Stepper (Berlin, Germany) and others.