|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.eclipse.emf.emfstore.internal.common.model.util.ModelUtil
public final class ModelUtil
Utility class for ModelElements.
Field Summary | |
---|---|
static long |
NO_CHECKSUM
Constant that may be used in case no checksum computation has taken place. |
static org.eclipse.emf.common.util.URI |
VIRTUAL_URI
URI used to serialize EObject with the model util. |
Method Summary | ||
---|---|---|
static boolean |
areEqual(IdEObjectCollection collectionA,
IdEObjectCollection collectionB)
Compares two IdEObjectCollection s. |
|
static
|
clone(List<T> list)
Clone a list of EObjects. |
|
static
|
clone(T eObject)
Clone any EObject. |
|
static List<SettingWithReferencedElement> |
collectOutgoingCrossReferences(IdEObjectCollection collection,
Set<org.eclipse.emf.ecore.EObject> modelElements)
Retrieve all outgoing connections from the model elements to other elements in the collection. |
|
static long |
computeChecksum(org.eclipse.emf.ecore.EObject eObject)
Computes the checksum for a given EObject . |
|
static long |
computeChecksum(IdEObjectCollection collection)
Computes the checksum for a given IdEObjectCollection . |
|
static IdEObjectCollection |
copyIdEObjectCollection(IdEObjectCollection collection,
org.eclipse.emf.ecore.xmi.XMIResource res)
Copies the given IdEObjectCollection and writes the IDs it contains into the given XMIResource . |
|
static ModelElementId |
createModelElementId(String id)
Creates a ModelElementId object from a string. |
|
static void |
deleteIncomingCrossReferencesFromParent(Collection<org.eclipse.emf.ecore.EStructuralFeature.Setting> inverseReferences,
org.eclipse.emf.ecore.EObject modelElement)
Delete the given incoming cross references to the given model element from any other model element in the given project. |
|
static void |
deleteOutgoingCrossReferences(IdEObjectCollection collection,
org.eclipse.emf.ecore.EObject modelElement)
Delete all outgoing cross references of the given model element to any element in the given collection. |
|
static void |
deleteResourcesWithPrefix(org.eclipse.emf.ecore.resource.ResourceSet resourceSet,
String prefix)
Deletes all resources from resourceSet, which string representation of URI starts with prefix. |
|
static String |
eObjectToString(org.eclipse.emf.ecore.EObject eObject)
Copies the given EObject and converts it to a string. |
|
static String |
eObjectToString(org.eclipse.emf.ecore.EObject eObject,
Map<?,?> saveOptions)
Copies the given EObject and converts it to a string. |
|
static
|
flatCloneList(List<T> originalList)
Create a flat clone of the list, the list if cloned but ot its content. |
|
static Set<org.eclipse.emf.ecore.EObject> |
getAllContainedModelElements(Collection<org.eclipse.emf.ecore.EObject> modelElements,
boolean includeTransientContainments,
boolean ignoreSingletonDatatypes)
Get all contained elements of a given collection of model elements. |
|
static Set<org.eclipse.emf.ecore.EObject> |
getAllContainedModelElements(org.eclipse.emf.ecore.EObject modelElement,
boolean includeTransientContainments)
Get all contained elements of a given element. |
|
static Set<org.eclipse.emf.ecore.EObject> |
getAllContainedModelElements(org.eclipse.emf.ecore.EObject modelElement,
boolean includeTransientContainments,
boolean ignoreSingletonDatatypes)
Get all contained elements of a given element. |
|
static Set<org.eclipse.emf.ecore.EObject> |
getAllContainedModelElements(org.eclipse.emf.ecore.resource.Resource resource,
boolean includeTransientContainments,
boolean ignoreSingletonDatatypes)
Get all contained elements of a given resource. |
|
static List<org.eclipse.emf.ecore.EObject> |
getAllContainedModelElementsAsList(org.eclipse.emf.ecore.EObject modelElement,
boolean includeTransientContainments)
Get all contained elements of a given element as a list. |
|
static Set<org.eclipse.emf.ecore.EClass> |
getAllMETypes(org.eclipse.emf.ecore.EPackage ePackage)
Recursively goes through package and returns a list of all EClasses inheriting ModelElement (abstract classes and interfaces are also include). |
|
static Map<Object,Object> |
getChecksumSaveOptions()
Delivers a map of options that is used while computing a checksum. |
|
static org.eclipse.emf.ecore.EObject |
getContainerModelElement(org.eclipse.emf.ecore.EObject modelElement)
Get the container of an EObject. |
|
static ModelElementId |
getModelElementId(org.eclipse.emf.ecore.EObject modelElement)
Searches for the project and then looks for the modelelement id. |
|
static Set<org.eclipse.emf.ecore.EClass> |
getNonAbstractMETypes(org.eclipse.emf.ecore.EPackage ePackage)
Recursively goes through model and create a list of all non-Abstract classes. |
|
static
|
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 Project |
getProject(org.eclipse.emf.ecore.EObject modelElement)
Get Project that contains a model element. |
|
static Map<Object,Object> |
getResourceLoadOptions()
Delivers a map of options for loading resources. |
|
static IResourceLogger |
getResourceLogger()
Returns the resource logger. |
|
static Map<Object,Object> |
getResourceSaveOptions()
Delivers a map of mandatory options for saving resources. |
|
static org.eclipse.emf.ecore.EObject |
getSingleton(ModelElementId singletonId)
Get the singleton instance for a given model element id. |
|
static ModelElementId |
getSingletonModelElementId(org.eclipse.emf.ecore.EObject singleton)
Get the singleton id for a singleton instance. |
|
static boolean |
isAssociationClassElement(org.eclipse.emf.ecore.EClass eClazz)
Whether a EClass is a association class. |
|
static boolean |
isIgnoredDatatype(org.eclipse.emf.ecore.EObject eObject)
Determines whether the type of an EObject is an ignored one. |
|
static boolean |
isSingleton(org.eclipse.emf.ecore.EObject eObject)
Return whether the given eObject instance is a singelton. |
|
static
|
loadEObjectFromResource(org.eclipse.emf.ecore.EClass eClass,
org.eclipse.emf.common.util.URI resourceURI,
boolean checkConstraints)
Load an EObject from a resource, the resource is supposed to contain only one root object of the given EClass type. |
|
static void |
loadResource(org.eclipse.emf.ecore.resource.Resource resource,
IResourceLogger logger)
Loads a given resource and logs any warning and/or errors. |
|
static void |
log(String message,
Throwable exception,
int statusInt)
This will add a new entry to error log view of eclipse. |
|
static void |
logError(String message)
Log a error to the platform log. |
|
static void |
logException(String message,
Throwable exception)
Log an exception to the platform log. |
|
static void |
logException(Throwable exception)
Log an exception to the platform log. |
|
static void |
logInfo(String message)
Log an exception to the platform log. |
|
static void |
logWarning(String message)
Log a warning to the platform log. |
|
static void |
logWarning(String message,
Throwable exception)
Log a warning to the platform log. |
|
static void |
saveEObjectToResource(org.eclipse.emf.ecore.EObject eObject,
org.eclipse.emf.common.util.URI resourceURI)
Save an EObject to a resource. |
|
static void |
saveEObjectToResource(List<? extends org.eclipse.emf.ecore.EObject> eObjects,
org.eclipse.emf.common.util.URI resourceURI)
Save a list of EObjects to the resource with the given URI. |
|
static void |
saveEObjectToResource(List<? extends org.eclipse.emf.ecore.EObject> eObjects,
org.eclipse.emf.common.util.URI resourceURI,
Map<Object,Object> options)
Save a list of EObjects to the resource with the given URI. |
|
static void |
saveResource(org.eclipse.emf.ecore.resource.Resource resource,
IResourceLogger logger)
Saves a given resource and logs any warning and/or errors. |
|
static void |
setXmiIdsOnResource(Project project,
org.eclipse.emf.ecore.xmi.XMIResource xmiResource)
Set all IDs contained in the project as XMI IDs for the model elements in the project. |
|
static boolean |
shouldBeCollected(IdEObjectCollection collection,
Set<org.eclipse.emf.ecore.EObject> allModelElements,
org.eclipse.emf.ecore.EObject referencedElement)
Checks if the referenced elements is an element in the given collection which is not a singleton, not an ignored data type and not already contained in the given set of elements. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final long NO_CHECKSUM
public static final org.eclipse.emf.common.util.URI VIRTUAL_URI
Method Detail |
---|
public static ModelElementId createModelElementId(String id)
id
- as string
public static boolean areEqual(IdEObjectCollection collectionA, IdEObjectCollection collectionB)
IdEObjectCollection
s. Order of the model elements at root level
of a collection does not influence the outcome of this operations
collectionA
- the first collectioncollectionB
- the second collection
public static String eObjectToString(org.eclipse.emf.ecore.EObject eObject) throws SerializationException
eObject
- the eObject to be serialized
eObject
SerializationException
- if a serialization problem occurspublic static String eObjectToString(org.eclipse.emf.ecore.EObject eObject, Map<?,?> saveOptions) throws SerializationException
eObject
- the eObject to be serializedsaveOptions
- the EMF save options to be used during serialization
eObject
SerializationException
- if a serialization problem occurspublic static long computeChecksum(org.eclipse.emf.ecore.EObject eObject) throws SerializationException
EObject
.
eObject
- the EObject for which to compute a checksum
SerializationException
- in case any errors occur during computation of the checksumpublic static long computeChecksum(IdEObjectCollection collection) throws SerializationException
IdEObjectCollection
.
The checksum for a collection is independent of the order of the
collection's elements at the root level.
collection
- the collection for which to compute a checksum
SerializationException
- in case any errors occur during computation of the checksumpublic static IResourceLogger getResourceLogger()
public static IdEObjectCollection copyIdEObjectCollection(IdEObjectCollection collection, org.eclipse.emf.ecore.xmi.XMIResource res)
IdEObjectCollection
and writes the IDs it contains into the given XMIResource
.
collection
- the collection to be copiedres
- the resource into which the collection's IDs should be written into
public static boolean isIgnoredDatatype(org.eclipse.emf.ecore.EObject eObject)
eObject
- the EObject which is to be checked
public static Map<Object,Object> getResourceLoadOptions()
XMLResource.OPTION_DEFER_IDREF_RESOLUTION
which speeds up loading
due to our id based resources.
XMIResource
or XMLResource
.public static Map<Object,Object> getResourceSaveOptions()
XMIResource
or XMLResource
.public static Map<Object,Object> getChecksumSaveOptions()
XMIResource
or XMLResource
.public static void saveResource(org.eclipse.emf.ecore.resource.Resource resource, IResourceLogger logger) throws IOException
resource
- the resource to be savedlogger
- a logger instance which will be used to log warnings and errors on resources
IOException
- in case an exception occurs during savepublic static void loadResource(org.eclipse.emf.ecore.resource.Resource resource, IResourceLogger logger) throws IOException
resource
- the resource to be loadedlogger
- a logger instance which will be used to log warnings and errors on resources
IOException
- in case an exception occurs during loadpublic static Set<org.eclipse.emf.ecore.EClass> getNonAbstractMETypes(org.eclipse.emf.ecore.EPackage ePackage)
ePackage
- the package to start with.
public static Set<org.eclipse.emf.ecore.EClass> getAllMETypes(org.eclipse.emf.ecore.EPackage ePackage)
ePackage
- starting package
public static void log(String message, Throwable exception, int statusInt)
message
- messageexception
- exceptionstatusInt
- severity. Use one of constants in
org.eclipse.core.runtime.Status class.public static void logException(String message, Throwable exception)
message
- the messageexception
- the exceptionpublic static void logException(Throwable exception)
exception
- the exceptionpublic static void logWarning(String message, Throwable exception)
message
- the messageexception
- the exceptionpublic static void logWarning(String message)
message
- the message being loggedpublic static void logError(String message)
message
- the message being loggedpublic static void logInfo(String message)
message
- the messagepublic static <T extends org.eclipse.emf.ecore.EObject> T clone(T eObject)
T
- the Eobject sub typeeObject
- the Eobject instance
public static <T extends org.eclipse.emf.ecore.EObject> List<T> clone(List<T> list)
T
- the EObject sub type the list consists oflist
- the list instance
public static <T extends org.eclipse.emf.ecore.EObject> List<T> flatCloneList(List<T> originalList)
T
- the list type parameteroriginalList
- the original list
public static <T extends org.eclipse.emf.ecore.EObject> T loadEObjectFromResource(org.eclipse.emf.ecore.EClass eClass, org.eclipse.emf.common.util.URI resourceURI, boolean checkConstraints) throws IOException
T
- Type of the EObjecteClass
- the EClass of the EObjectresourceURI
- the resources URIcheckConstraints
- whether to perform additional sanity checks. These checks
basically try to enforce that a resource contains exactly one
object.
IOException
- if loading the object from the resource fails.public static void saveEObjectToResource(List<? extends org.eclipse.emf.ecore.EObject> eObjects, org.eclipse.emf.common.util.URI resourceURI, Map<Object,Object> options) throws IOException
eObjects
- the EObjects to be savedresourceURI
- the URI of the resource, which should be used to save the
EObjectsoptions
- The save options for the resource.
IOException
- if saving to the resource failspublic static void saveEObjectToResource(List<? extends org.eclipse.emf.ecore.EObject> eObjects, org.eclipse.emf.common.util.URI resourceURI) throws IOException
eObjects
- the EObjects to be savedresourceURI
- the URI of the resource, which should be used to save the
EObjects
IOException
- if saving to the resource failspublic static void setXmiIdsOnResource(Project project, org.eclipse.emf.ecore.xmi.XMIResource xmiResource)
project
- a projectxmiResource
- the resource that will contain the XMI IDspublic static void saveEObjectToResource(org.eclipse.emf.ecore.EObject eObject, org.eclipse.emf.common.util.URI resourceURI) throws IOException
eObject
- the objectresourceURI
- the resources URI
IOException
- if saving to the resource fails.public static void deleteResourcesWithPrefix(org.eclipse.emf.ecore.resource.ResourceSet resourceSet, String prefix) throws IOException
resourceSet
- resource setprefix
- string prefix of the resource path
IOException
- if deleting the resource failspublic static Project getProject(org.eclipse.emf.ecore.EObject modelElement)
modelElement
- the model element
public static ModelElementId getModelElementId(org.eclipse.emf.ecore.EObject modelElement)
modelElement
- me
public static <T extends org.eclipse.emf.ecore.EObject> T getParent(Class<T> parent, org.eclipse.emf.ecore.EObject child)
eContainer
is null
.
T
- type of the parent classparent
- the class of the parentchild
- the model element whose container should get returned
public static boolean isAssociationClassElement(org.eclipse.emf.ecore.EClass eClazz)
EClass
is a association class. Association classes are
not displayed as dedicated elements. A link from one element to another
which goes over an association class is displayed by a dedicated widget.
This widgets allows to trace transparently without seeing the association
class.
eClazz
- the EClass
public static Set<org.eclipse.emf.ecore.EObject> getAllContainedModelElements(org.eclipse.emf.ecore.EObject modelElement, boolean includeTransientContainments)
modelElement
- the model elementincludeTransientContainments
- true if transient containments should be included in the
result
public static Set<org.eclipse.emf.ecore.EObject> getAllContainedModelElements(org.eclipse.emf.ecore.EObject modelElement, boolean includeTransientContainments, boolean ignoreSingletonDatatypes)
modelElement
- the model elementincludeTransientContainments
- true if transient containments should be included in the
resultignoreSingletonDatatypes
- whether to ignore singleton datatypes like, for example,
EString
public static Set<org.eclipse.emf.ecore.EObject> getAllContainedModelElements(org.eclipse.emf.ecore.resource.Resource resource, boolean includeTransientContainments, boolean ignoreSingletonDatatypes)
resource
- the resourceincludeTransientContainments
- true if transient containments should be included in the
resultignoreSingletonDatatypes
- whether to ignore singleton datatypes like, for example,
EString
public static Set<org.eclipse.emf.ecore.EObject> getAllContainedModelElements(Collection<org.eclipse.emf.ecore.EObject> modelElements, boolean includeTransientContainments, boolean ignoreSingletonDatatypes)
modelElements
- a collection of elementsincludeTransientContainments
- true if transient containments should be included in the
resultignoreSingletonDatatypes
- whether to ignore singleton datatypes like, for example,
EString
public static org.eclipse.emf.ecore.EObject getContainerModelElement(org.eclipse.emf.ecore.EObject modelElement)
modelElement
- the model element
public static List<org.eclipse.emf.ecore.EObject> getAllContainedModelElementsAsList(org.eclipse.emf.ecore.EObject modelElement, boolean includeTransientContainments)
modelElement
- the model elementincludeTransientContainments
- true if transient containments should be included in the
result
public static void deleteIncomingCrossReferencesFromParent(Collection<org.eclipse.emf.ecore.EStructuralFeature.Setting> inverseReferences, org.eclipse.emf.ecore.EObject modelElement)
inverseReferences
- a collection of inverse referencesmodelElement
- the model elementpublic static void deleteOutgoingCrossReferences(IdEObjectCollection collection, org.eclipse.emf.ecore.EObject modelElement)
collection
- the collectionmodelElement
- the model elementpublic static List<SettingWithReferencedElement> collectOutgoingCrossReferences(IdEObjectCollection collection, Set<org.eclipse.emf.ecore.EObject> modelElements)
collection
- the collectionmodelElements
- the model elements
public static boolean shouldBeCollected(IdEObjectCollection collection, Set<org.eclipse.emf.ecore.EObject> allModelElements, org.eclipse.emf.ecore.EObject referencedElement)
collection
- the collectionallModelElements
- the set of model elementsreferencedElement
- the referenced element
public static org.eclipse.emf.ecore.EObject getSingleton(ModelElementId singletonId)
singletonId
- the id
public static ModelElementId getSingletonModelElementId(org.eclipse.emf.ecore.EObject singleton)
singleton
- the singleton
ESSingletonIdResolver.getSingletonModelElementId(org.eclipse.emf.ecore.EObject)
public static boolean isSingleton(org.eclipse.emf.ecore.EObject eObject)
eObject
- the instance
ESSingletonIdResolver.isSingleton(org.eclipse.emf.ecore.EObject)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |