org.eclipse.emf.emfstore.internal.common
Class CommonUtil

java.lang.Object
  extended by org.eclipse.emf.emfstore.internal.common.CommonUtil

public final class CommonUtil
extends Object

Utility class to retrieve meta model information.

Author:
koegel

Method Summary
static Set<org.eclipse.emf.ecore.EClass> getAllEContainments(org.eclipse.emf.ecore.EClass eClass)
          Gives all registryEClasses which can be contained in a given EClass.
static Set<org.eclipse.emf.ecore.EClass> getAllModelElementEClasses()
          Retrieve all EClasses from the ECore package registry.
static Set<org.eclipse.emf.ecore.EClass> getAllSubEClasses(org.eclipse.emf.ecore.EClass eClass)
          Retrieve all EClasses from the ECore package registry that are subclasses of the given EClass.
static String getEncoding()
          Returns the file encoding in use.
static Set<org.eclipse.emf.ecore.EObject> getNonTransientContents(org.eclipse.emf.ecore.EObject eObject)
          Get all contained EObjects not including transient containment features.
static
<T extends org.eclipse.emf.ecore.EObject>
T
getParent(Class<T> parent, org.eclipse.emf.ecore.EObject child)
          Get the EContainer that contains the given model element and whose EContainer is null.
static org.eclipse.emf.ecore.EReference getPossibleContainingReference(org.eclipse.emf.ecore.EObject containee, org.eclipse.emf.ecore.EObject parent)
          Returns a containing reference of the parent that may contain the given containee.
static boolean isSelfContained(org.eclipse.emf.ecore.EObject object)
          Check an EObject and its containment tree whether it is self-contained.
static boolean isSelfContained(org.eclipse.emf.ecore.EObject eObject, boolean ignoreContainer)
          Check an EObject and its containment tree whether it is self-contained.
A containment tree is self contained if it does not have references to EObjects outside the tree.
static boolean isSingletonEObject(org.eclipse.emf.ecore.EObject eObject)
          Determines whether an EObject is a singleton object.
static boolean isTesting()
           
static Set<org.eclipse.emf.ecore.EObject> loadFromResource(org.eclipse.emf.ecore.resource.Resource resource, List<String> errorStrings)
          Loads a Set of EObject from a given resource.
static void setTesting(boolean testing)
          If we are running tests.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getPossibleContainingReference

public static org.eclipse.emf.ecore.EReference getPossibleContainingReference(org.eclipse.emf.ecore.EObject containee,
                                                                              org.eclipse.emf.ecore.EObject parent)
Returns a containing reference of the parent that may contain the given containee.

Parameters:
containee - the EObject that may be contained by the parent's reference, if any
parent - The EObject to get the containment references from
Returns:
the parent's container reference

getAllEContainments

public static Set<org.eclipse.emf.ecore.EClass> getAllEContainments(org.eclipse.emf.ecore.EClass eClass)
Gives all registryEClasses which can be contained in a given EClass.

Parameters:
eClass - the EClass
Returns:
all Classes which can be contained

getAllSubEClasses

public static Set<org.eclipse.emf.ecore.EClass> getAllSubEClasses(org.eclipse.emf.ecore.EClass eClass)
Retrieve all EClasses from the ECore package registry that are subclasses of the given EClass. Does not include abstract classes or interfaces.

Parameters:
eClass - the superClass of the subClasses to retrieve
Returns:
a set of EClasses

getAllModelElementEClasses

public static Set<org.eclipse.emf.ecore.EClass> getAllModelElementEClasses()
Retrieve all EClasses from the ECore package registry.

Returns:
a set of EClasses

getParent

public static <T extends org.eclipse.emf.ecore.EObject> T getParent(Class<T> parent,
                                                                    org.eclipse.emf.ecore.EObject child)
Get the EContainer that contains the given model element and whose EContainer is null.

Type Parameters:
T - parent type
Parameters:
parent - the Class of the parent
child - the model element whose container should get returned
Returns:
the container

isSelfContained

public static boolean isSelfContained(org.eclipse.emf.ecore.EObject object)
Check an EObject and its containment tree whether it is self-contained. A containment tree is self contained if it does not have references to EObjects outside the tree.

Parameters:
object - the eObject that is checked whether it is self-contained
Returns:
true if it is self-contained, false otherwise

isSelfContained

public static boolean isSelfContained(org.eclipse.emf.ecore.EObject eObject,
                                      boolean ignoreContainer)
Check an EObject and its containment tree whether it is self-contained.
A containment tree is self contained if it does not have references to EObjects outside the tree.

Parameters:
eObject - the EObject that is checked whether it is self-contained
ignoreContainer - true, if references of object to its container should be ignored in the check
Returns:
true if it is self-contained, false otherwise

getNonTransientContents

public static Set<org.eclipse.emf.ecore.EObject> getNonTransientContents(org.eclipse.emf.ecore.EObject eObject)
Get all contained EObjects not including transient containment features.

Parameters:
eObject - the EObject whose non-transient contents should be retrieved
Returns:
a set of contained elements not including root (the passed EObject itself)

isSingletonEObject

public static boolean isSingletonEObject(org.eclipse.emf.ecore.EObject eObject)
Determines whether an EObject is a singleton object. All EObjects being children of ECorePackage are considered as singletons.

Parameters:
eObject - the EObject that will be checked whether it is a singleton
Returns:
true if it is a singleton, false otherwise

loadFromResource

public static Set<org.eclipse.emf.ecore.EObject> loadFromResource(org.eclipse.emf.ecore.resource.Resource resource,
                                                                  List<String> errorStrings)
Loads a Set of EObject from a given resource. Content which couldn't be loaded creates a error string which will be added to the errorStrings list. After the return from the method to the caller the return value contains the loaded EObjects.

Parameters:
resource - contains the items which should be loaded.
errorStrings - contains all messages about items which couldn't be loaded by the method.
Returns:
Set with the loaded an valid EObjects

setTesting

public static void setTesting(boolean testing)
If we are running tests. In this case the workspace will be created in USERHOME/.emfstore.test.

Parameters:
testing - the testing to set

isTesting

public static boolean isTesting()
Returns:
if we are running tests. In this case the workspace will be created in USERHOME/.emfstore.test.

getEncoding

public static String getEncoding()
Returns the file encoding in use.

Returns:
the file encoding


Copyright © 2015. All Rights Reserved.