Package org.eclipse.epsilon.emc.emf
Class EmfModel
- java.lang.Object
-
- org.eclipse.epsilon.eol.models.Model
-
- org.eclipse.epsilon.eol.models.CachedModel<org.eclipse.emf.ecore.EObject>
-
- org.eclipse.epsilon.emc.emf.AbstractEmfModel
-
- org.eclipse.epsilon.emc.emf.AbstractReflectiveEmfModel
-
- org.eclipse.epsilon.emc.emf.EmfModel
-
- All Implemented Interfaces:
AutoCloseable
,IModel
,IReflectiveModel
- Direct Known Subclasses:
DecoratorEmfModel
,EmfM0Model
,InMemoryEmfModel
,ModelSpy
,UmlModel
,XmlModel
public class EmfModel extends AbstractReflectiveEmfModel
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected class
EmfModel.CachedContentsAdapter
This listener is the one that keeps the cached .allInstances and model .allContents() lists up to date, instead of the usual createInstance/deleteInstance methods.
-
Field Summary
Fields Modifier and Type Field Description protected static Map<String,List<org.eclipse.emf.ecore.EPackage>>
fileBasedMetamodels
protected static Map<String,Long>
fileBasedMetamodelTimestamps
protected boolean
isMetamodelFileBased
Deprecated.protected List<org.eclipse.emf.common.util.URI>
metamodelFileUris
protected List<org.eclipse.emf.common.util.URI>
metamodelUris
protected org.eclipse.emf.common.util.URI
modelUri
protected List<org.eclipse.emf.ecore.EPackage>
packages
static String
PROPERTY_FILE_BASED_METAMODEL_URI
One of the keys used to construct the first argument toModel.load(StringProperties, String)
.static String
PROPERTY_IS_METAMODEL_FILE_BASED
Deprecated.PROPERTY_METAMODEL_URI
andPROPERTY_FILE_BASED_METAMODEL_URI
are now interpreted as comma-separated lists of 0+ metamodel locations, and it is allowed to mix both types of metamodels now.static String
PROPERTY_METAMODEL_FILE
Deprecated.Replaced byPROPERTY_FILE_BASED_METAMODEL_URI
.static String
PROPERTY_METAMODEL_URI
One of the keys used to construct the first argument toModel.load(StringProperties, String)
.static String
PROPERTY_MODEL_FILE
Deprecated.Replaced byPROPERTY_MODEL_URI
.static String
PROPERTY_MODEL_URI
One of the keys used to construct the first argument toModel.load(StringProperties, String)
.static String
PROPERTY_REUSE_UNMODIFIED_FILE_BASED_METAMODELS
One of the keys used to construct the first argument toModel.load(StringProperties, String)
.static String
PROPERTY_VALIDATE
One of the keys used to construct the first argument toModel.load(StringProperties, String)
.protected boolean
reuseUnmodifiedFileBasedMetamodels
protected boolean
useExtendedMetadata
protected boolean
validate
-
Fields inherited from class org.eclipse.epsilon.emc.emf.AbstractEmfModel
expand, modelImpl, PROPERTY_EXPAND, PROPERTY_PARALLELALLOF, registry, resourceLoadOptions, resourceStoreOptions, transactionSupport
-
Fields inherited from class org.eclipse.epsilon.eol.models.CachedModel
allContentsCache, kindCache, PROPERTY_CACHED, PROPERTY_CONCURRENT, typeCache
-
Fields inherited from class org.eclipse.epsilon.eol.models.Model
aliases, ENV_PREFIX, name, PROPERTY_ALIASES, PROPERTY_NAME, PROPERTY_READONLOAD, PROPERTY_READONLY, PROPERTY_STOREONDISPOSAL, propertyGetter, propertySetter, readOnLoad, storeOnDisposal
-
-
Constructor Summary
Constructors Constructor Description EmfModel()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected void
addToCache(String type, org.eclipse.emf.ecore.EObject instance)
protected org.eclipse.emf.ecore.resource.ResourceSet
createResourceSet()
protected void
determinePackagesFrom(org.eclipse.emf.ecore.resource.ResourceSet resourceSet)
protected void
forceAddToCache(org.eclipse.emf.ecore.EObject instance)
We want to use the overridden method, but not fromCachedModel.createInstance(String)
, but rather from the adapter we set up to track additions and removals from the contents of a model.protected void
forceRemoveFromCache(org.eclipse.emf.ecore.EObject instance)
Metamodel
getMetamodel(StringProperties properties, IRelativePathResolver resolver)
List<String>
getMetamodelFiles()
List<org.eclipse.emf.common.util.URI>
getMetamodelFileUris()
List<String>
getMetamodelUris()
String
getModelFile()
org.eclipse.emf.common.util.URI
getModelFileUri()
boolean
isMetamodelFileBased()
Deprecated.This value is no longer used to load models: it is only kept for backwards compatibility, and it now simply indicates whether a file metamodel was loaded at all, or not.boolean
isReuseUnmodifiedFileBasedMetamodels()
boolean
isValidate()
void
load(StringProperties properties, IRelativePathResolver resolver)
Load the model using the set of properties specified by the first argument.protected void
loadModel()
void
loadModelFromUri()
protected void
removeFromCache(org.eclipse.emf.ecore.EObject instance)
void
setCachingEnabled(boolean cachingEnabled)
void
setMetamodelFile(String path)
void
setMetamodelFileBased(boolean isMetamodelFileBased)
Deprecated.This value is no longer honored anymore.void
setMetamodelFiles(List<String> paths)
void
setMetamodelFileUri(org.eclipse.emf.common.util.URI uri)
void
setMetamodelFileUris(List<org.eclipse.emf.common.util.URI> fileUris)
void
setMetamodelUri(String uri)
void
setMetamodelUris(List<String> uris)
void
setModelFile(String path)
void
setModelFileUri(org.eclipse.emf.common.util.URI modelFileUri)
void
setReuseUnmodifiedFileBasedMetamodels(boolean reuseUnmodifiedFileBasedMetamodels)
void
setupContainmentChangeListeners()
void
setValidate(boolean validate)
boolean
store()
String
toString()
-
Methods inherited from class org.eclipse.epsilon.emc.emf.AbstractReflectiveEmfModel
getEnumerationLabelOf, getEnumerationTypeOf, getPropertiesOf, getPropertySetter, hasPackage, hasProperty, isEnumerationValue, preventLoadingOfExternalModelElements
-
Methods inherited from class org.eclipse.epsilon.emc.emf.AbstractEmfModel
addMetamodelUri, allContentsFromModel, classForName, classForName, classForName, createInstanceInModel, deleteElementInModel, disposeModel, getAllOfKindFromModel, getAllOfTypeFromModel, getAllTypeNamesOf, getCacheKeyForType, getContainerOf, getElementById, getElementId, getEnumerationValue, getFullyQualifiedName, getFullyQualifiedTypeNameOf, getInputStream, getModelImpl, getPackageRegistry, getResource, getResourceLoadOptions, getResources, getResourceStoreOptions, getTransactionSupport, getTypeNameOf, getTypeOf, hasAdapter, hasType, initCaches, isExpand, isInstantiable, isLoaded, isModelElement, isOfKind, isOfType, isParallelAllOf, isPropertySet, knowsAboutProperty, knowsAboutProperty, owns, putResourceLoadOption, putResourceStoreOption, setElementId, setExpand, setModelImpl, setParallelAllOf, setResource, setResourceLoadOptions, setResourceStoreOptions, store, store, store, validate
-
Methods inherited from class org.eclipse.epsilon.eol.models.CachedModel
allContents, clearCache, createInstance, deleteElement, dispose, getAllOfKind, getAllOfKindOrType, getAllOfType, isCachingEnabled, isConcurrent, load, setConcurrent, wrap
-
Methods inherited from class org.eclipse.epsilon.eol.models.Model
allInstances, createInstance, getAliases, getName, getPropertyGetter, isReadOnLoad, isStoredOnDisposal, load, load, setName, setReadOnLoad, setStoredOnDisposal
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.eclipse.epsilon.eol.models.IModel
allContents, close, createInstance, createInstance, deleteElement, dispose, getAliases, getAllOfKind, getAllOfType, getElementById, getElementId, getEnumerationValue, getFullyQualifiedTypeNameOf, getName, getPropertyGetter, getTransactionSupport, getTypeNameOf, getTypeOf, hasType, isInstantiable, isModelElement, isOfKind, isOfType, isPropertySet, isReadOnLoad, isStoredOnDisposal, knowsAboutProperty, load, load, load, owns, setElementId, setName, setReadOnLoad, setStoredOnDisposal, store
-
Methods inherited from interface org.eclipse.epsilon.eol.models.IReflectiveModel
getContainerOf
-
-
-
-
Field Detail
-
PROPERTY_IS_METAMODEL_FILE_BASED
@Deprecated public static final String PROPERTY_IS_METAMODEL_FILE_BASED
Deprecated.PROPERTY_METAMODEL_URI
andPROPERTY_FILE_BASED_METAMODEL_URI
are now interpreted as comma-separated lists of 0+ metamodel locations, and it is allowed to mix both types of metamodels now. This property is no longer used.- See Also:
- Constant Field Values
-
PROPERTY_METAMODEL_URI
public static final String PROPERTY_METAMODEL_URI
One of the keys used to construct the first argument toModel.load(StringProperties, String)
. This key is a comma-separated list of zero or more namespaces URI of some of the metamodels to which this model conforms. Users may combine this key withPROPERTY_FILE_BASED_METAMODEL_URI
to load both file-based and URI-based metamodels at the same time.- See Also:
- Constant Field Values
-
PROPERTY_FILE_BASED_METAMODEL_URI
public static final String PROPERTY_FILE_BASED_METAMODEL_URI
One of the keys used to construct the first argument toModel.load(StringProperties, String)
. This key is a comma-separated list of zero or moreURI
s that can be used to locate some of the metamodels to which this model conforms. Users may combine this key withPROPERTY_METAMODEL_URI
to load both file-based and URI-based metamodels at the same time.- See Also:
- Constant Field Values
-
PROPERTY_METAMODEL_FILE
@Deprecated public static final String PROPERTY_METAMODEL_FILE
Deprecated.Replaced byPROPERTY_FILE_BASED_METAMODEL_URI
. This property will be removed in a future release of Epsilon.- See Also:
- Constant Field Values
-
PROPERTY_MODEL_URI
public static final String PROPERTY_MODEL_URI
One of the keys used to construct the first argument toModel.load(StringProperties, String)
. This key is paired with aURI
that can be used to locate this model. This key must always be paired with a value.- See Also:
- Constant Field Values
-
PROPERTY_MODEL_FILE
@Deprecated public static final String PROPERTY_MODEL_FILE
Deprecated.Replaced byPROPERTY_MODEL_URI
. This property will be removed in a future release of Epsilon.- See Also:
- Constant Field Values
-
PROPERTY_REUSE_UNMODIFIED_FILE_BASED_METAMODELS
public static final String PROPERTY_REUSE_UNMODIFIED_FILE_BASED_METAMODELS
One of the keys used to construct the first argument toModel.load(StringProperties, String)
. This key is a Boolean value that if set totrue
(the default), tries to reuse previously registered file-based EPackages that have not been modified since the last time they were registered.- See Also:
- Constant Field Values
-
PROPERTY_VALIDATE
public static final String PROPERTY_VALIDATE
One of the keys used to construct the first argument toModel.load(StringProperties, String)
. This key is a Boolean value that if set totrue
it triggers validation of all the resources in the model's resource set after loading (default isfalse
)- See Also:
- Constant Field Values
-
metamodelUris
protected List<org.eclipse.emf.common.util.URI> metamodelUris
-
packages
protected List<org.eclipse.emf.ecore.EPackage> packages
-
isMetamodelFileBased
@Deprecated protected boolean isMetamodelFileBased
Deprecated.
-
modelUri
protected org.eclipse.emf.common.util.URI modelUri
-
metamodelFileUris
protected List<org.eclipse.emf.common.util.URI> metamodelFileUris
-
useExtendedMetadata
protected boolean useExtendedMetadata
-
validate
protected boolean validate
-
reuseUnmodifiedFileBasedMetamodels
protected boolean reuseUnmodifiedFileBasedMetamodels
-
fileBasedMetamodels
protected static Map<String,List<org.eclipse.emf.ecore.EPackage>> fileBasedMetamodels
-
-
Method Detail
-
load
public void load(StringProperties properties, IRelativePathResolver resolver) throws EolModelLoadingException
Load the model using the set of properties specified by the first argument.- Specified by:
load
in interfaceIModel
- Overrides:
load
in classAbstractEmfModel
- Throws:
EolModelLoadingException
- See Also:
PROPERTY_MODEL_URI
,PROPERTY_IS_METAMODEL_FILE_BASED
,AbstractEmfModel.PROPERTY_EXPAND
, Rationale for deprecating the FILE properties.
-
loadModel
protected void loadModel() throws EolModelLoadingException
- Specified by:
loadModel
in classCachedModel<org.eclipse.emf.ecore.EObject>
- Throws:
EolModelLoadingException
-
addToCache
protected void addToCache(String type, org.eclipse.emf.ecore.EObject instance) throws EolModelElementTypeNotFoundException
- Overrides:
addToCache
in classCachedModel<org.eclipse.emf.ecore.EObject>
- Throws:
EolModelElementTypeNotFoundException
-
removeFromCache
protected void removeFromCache(org.eclipse.emf.ecore.EObject instance) throws EolModelElementTypeNotFoundException
- Overrides:
removeFromCache
in classCachedModel<org.eclipse.emf.ecore.EObject>
- Throws:
EolModelElementTypeNotFoundException
-
forceAddToCache
protected void forceAddToCache(org.eclipse.emf.ecore.EObject instance) throws EolModelElementTypeNotFoundException
We want to use the overridden method, but not fromCachedModel.createInstance(String)
, but rather from the adapter we set up to track additions and removals from the contents of a model. For this reason, we leave the overridden method empty and define this one that can be safely called from the adapter.
-
forceRemoveFromCache
protected void forceRemoveFromCache(org.eclipse.emf.ecore.EObject instance) throws EolModelElementTypeNotFoundException
- Throws:
EolModelElementTypeNotFoundException
- See Also:
#forceAddToCache(String, EObject)
-
setupContainmentChangeListeners
public void setupContainmentChangeListeners()
-
createResourceSet
protected org.eclipse.emf.ecore.resource.ResourceSet createResourceSet()
-
loadModelFromUri
public void loadModelFromUri() throws EolModelLoadingException
- Throws:
EolModelLoadingException
-
setCachingEnabled
public void setCachingEnabled(boolean cachingEnabled)
- Overrides:
setCachingEnabled
in classCachedModel<org.eclipse.emf.ecore.EObject>
- Since:
- 1.6
-
isMetamodelFileBased
@Deprecated public boolean isMetamodelFileBased()
Deprecated.This value is no longer used to load models: it is only kept for backwards compatibility, and it now simply indicates whether a file metamodel was loaded at all, or not.
-
setMetamodelFileBased
@Deprecated public void setMetamodelFileBased(boolean isMetamodelFileBased)
Deprecated.This value is no longer honored anymore. Please populate the lists ingetMetamodelUris()
(URI-based metamodels) andgetMetamodelFileUris()
(file-based metamodels) appropriately instead.
-
getModelFile
public String getModelFile()
-
getModelFileUri
public org.eclipse.emf.common.util.URI getModelFileUri()
-
setModelFileUri
public void setModelFileUri(org.eclipse.emf.common.util.URI modelFileUri)
-
getMetamodelFileUris
public List<org.eclipse.emf.common.util.URI> getMetamodelFileUris()
-
setMetamodelFileUris
public void setMetamodelFileUris(List<org.eclipse.emf.common.util.URI> fileUris)
-
setMetamodelFileUri
public void setMetamodelFileUri(org.eclipse.emf.common.util.URI uri)
-
setMetamodelUri
public void setMetamodelUri(String uri)
-
setMetamodelFile
public void setMetamodelFile(String path)
-
setModelFile
public void setModelFile(String path)
-
isReuseUnmodifiedFileBasedMetamodels
public boolean isReuseUnmodifiedFileBasedMetamodels()
-
setReuseUnmodifiedFileBasedMetamodels
public void setReuseUnmodifiedFileBasedMetamodels(boolean reuseUnmodifiedFileBasedMetamodels)
-
determinePackagesFrom
protected void determinePackagesFrom(org.eclipse.emf.ecore.resource.ResourceSet resourceSet) throws EolModelLoadingException
- Throws:
EolModelLoadingException
-
getMetamodel
public Metamodel getMetamodel(StringProperties properties, IRelativePathResolver resolver)
- Specified by:
getMetamodel
in interfaceIModel
- Overrides:
getMetamodel
in classModel
-
store
public boolean store()
-
isValidate
public boolean isValidate()
-
setValidate
public void setValidate(boolean validate)
-
-