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.EmfModel
-
- All Implemented Interfaces:
java.lang.AutoCloseable,IModel,IReflectiveModel
- Direct Known Subclasses:
DecoratorEmfModel,EmfM0Model,InMemoryEmfModel,ModelSpy,UmlModel,XmlModel
public class EmfModel extends AbstractEmfModel implements IReflectiveModel
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected classEmfModel.CachedContentsAdapterThis 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 java.util.Map<java.lang.String,java.util.List<org.eclipse.emf.ecore.EPackage>>fileBasedMetamodelsprotected static java.util.Map<java.lang.String,java.lang.Long>fileBasedMetamodelTimestampsprotected booleanisMetamodelFileBasedDeprecated.protected java.util.List<org.eclipse.emf.common.util.URI>metamodelFileUrisprotected java.util.List<org.eclipse.emf.common.util.URI>metamodelUrisprotected org.eclipse.emf.common.util.URImodelUriprotected java.util.List<org.eclipse.emf.ecore.EPackage>packagesstatic java.lang.StringPROPERTY_FILE_BASED_METAMODEL_URIOne of the keys used to construct the first argument toModel.load(StringProperties, String).static java.lang.StringPROPERTY_IS_METAMODEL_FILE_BASEDDeprecated.PROPERTY_METAMODEL_URIandPROPERTY_FILE_BASED_METAMODEL_URIare now interpreted as comma-separated lists of 0+ metamodel locations, and it is allowed to mix both types of metamodels now.static java.lang.StringPROPERTY_METAMODEL_FILEDeprecated.Replaced byPROPERTY_FILE_BASED_METAMODEL_URI.static java.lang.StringPROPERTY_METAMODEL_URIOne of the keys used to construct the first argument toModel.load(StringProperties, String).static java.lang.StringPROPERTY_MODEL_FILEDeprecated.Replaced byPROPERTY_MODEL_URI.static java.lang.StringPROPERTY_MODEL_URIOne of the keys used to construct the first argument toModel.load(StringProperties, String).static java.lang.StringPROPERTY_REUSE_UNMODIFIED_FILE_BASED_METAMODELSOne of the keys used to construct the first argument toModel.load(StringProperties, String).protected booleanreuseUnmodifiedFileBasedMetamodelsprotected booleanuseExtendedMetadata-
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 voidaddToCache(java.lang.String type, org.eclipse.emf.ecore.EObject instance)protected org.eclipse.emf.ecore.resource.ResourceSetcreateResourceSet()protected voiddeterminePackagesFrom(org.eclipse.emf.ecore.resource.ResourceSet resourceSet)protected voidforceAddToCache(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 voidforceRemoveFromCache(org.eclipse.emf.ecore.EObject instance)java.lang.StringgetEnumerationLabelOf(java.lang.Object literal)Returns the enumeration label of the literal parameter.java.lang.StringgetEnumerationTypeOf(java.lang.Object literal)Returns the name of the enumeration type of the literal parameter.MetamodelgetMetamodel(StringProperties properties, IRelativePathResolver resolver)java.util.List<java.lang.String>getMetamodelFiles()java.util.List<org.eclipse.emf.common.util.URI>getMetamodelFileUris()java.util.List<java.lang.String>getMetamodelUris()java.lang.StringgetModelFile()org.eclipse.emf.common.util.URIgetModelFileUri()java.util.Collection<java.lang.String>getPropertiesOf(java.lang.String type)Returns a collection containing all of the properties that instances of type know about.IReflectivePropertySettergetPropertySetter()booleanhasPackage(java.lang.String packageName)Returns true iff this model contains a package with the given name.booleanhasProperty(java.lang.String type, java.lang.String property)booleanisEnumerationValue(java.lang.Object object)Returns true iff object is an enumeration value.booleanisMetamodelFileBased()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.booleanisReuseUnmodifiedFileBasedMetamodels()voidload(StringProperties properties, IRelativePathResolver resolver)Load the model using the set of properties specified by the first argument.protected voidloadModel()voidloadModelFromUri()booleanpreventLoadingOfExternalModelElements()Prevents the loading of model elements that are referenced by this model but are not contained in this model.protected voidremoveFromCache(org.eclipse.emf.ecore.EObject instance)voidsetCachingEnabled(boolean cachingEnabled)voidsetMetamodelFile(java.lang.String path)voidsetMetamodelFileBased(boolean isMetamodelFileBased)Deprecated.This value is no longer honored anymore.voidsetMetamodelFiles(java.util.List<java.lang.String> paths)voidsetMetamodelFileUri(org.eclipse.emf.common.util.URI uri)voidsetMetamodelFileUris(java.util.List<org.eclipse.emf.common.util.URI> fileUris)voidsetMetamodelUri(java.lang.String uri)voidsetMetamodelUris(java.util.List<java.lang.String> uris)voidsetModelFile(java.lang.String path)voidsetModelFileUri(org.eclipse.emf.common.util.URI modelFileUri)voidsetReuseUnmodifiedFileBasedMetamodels(boolean reuseUnmodifiedFileBasedMetamodels)voidsetupContainmentChangeListeners()booleanstore()java.lang.StringtoString()-
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
-
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 java.lang.String PROPERTY_IS_METAMODEL_FILE_BASED
Deprecated.PROPERTY_METAMODEL_URIandPROPERTY_FILE_BASED_METAMODEL_URIare 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 java.lang.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_URIto 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 java.lang.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 moreURIs that can be used to locate some of the metamodels to which this model conforms. Users may combine this key withPROPERTY_METAMODEL_URIto load both file-based and URI-based metamodels at the same time.- See Also:
- Constant Field Values
-
PROPERTY_METAMODEL_FILE
@Deprecated public static final java.lang.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 java.lang.String PROPERTY_MODEL_URI
One of the keys used to construct the first argument toModel.load(StringProperties, String). This key is paired with aURIthat 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 java.lang.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 java.lang.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
-
metamodelUris
protected java.util.List<org.eclipse.emf.common.util.URI> metamodelUris
-
packages
protected java.util.List<org.eclipse.emf.ecore.EPackage> packages
-
isMetamodelFileBased
@Deprecated protected boolean isMetamodelFileBased
Deprecated.
-
modelUri
protected org.eclipse.emf.common.util.URI modelUri
-
metamodelFileUris
protected java.util.List<org.eclipse.emf.common.util.URI> metamodelFileUris
-
useExtendedMetadata
protected boolean useExtendedMetadata
-
reuseUnmodifiedFileBasedMetamodels
protected boolean reuseUnmodifiedFileBasedMetamodels
-
fileBasedMetamodels
protected static java.util.Map<java.lang.String,java.util.List<org.eclipse.emf.ecore.EPackage>> fileBasedMetamodels
-
fileBasedMetamodelTimestamps
protected static java.util.Map<java.lang.String,java.lang.Long> fileBasedMetamodelTimestamps
-
-
Method Detail
-
getPropertySetter
public IReflectivePropertySetter getPropertySetter()
- Specified by:
getPropertySetterin interfaceIModel- Specified by:
getPropertySetterin interfaceIReflectiveModel- Overrides:
getPropertySetterin classModel
-
getPropertiesOf
public java.util.Collection<java.lang.String> getPropertiesOf(java.lang.String type) throws EolModelElementTypeNotFoundExceptionDescription copied from interface:IReflectiveModelReturns a collection containing all of the properties that instances of type know about.- Specified by:
getPropertiesOfin interfaceIReflectiveModel- Parameters:
type- The type of model object whose properties are to be determined.- Returns:
- all of the properties that instances of type knows about.
- Throws:
EolModelElementTypeNotFoundException- when this model has no such type
-
preventLoadingOfExternalModelElements
public boolean preventLoadingOfExternalModelElements()
Description copied from interface:IReflectiveModelPrevents the loading of model elements that are referenced by this model but are not contained in this model. This is useful for clients, such as Epsilon Flock, which create a clone or conservative copy of this model.- Specified by:
preventLoadingOfExternalModelElementsin interfaceIReflectiveModel- Returns:
- true iff this method had an effect (i.e. when this model supports external references, was configured to load external references and is no longer configured to load external references).
-
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:
loadin interfaceIModel- Overrides:
loadin 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:
loadModelin classCachedModel<org.eclipse.emf.ecore.EObject>- Throws:
EolModelLoadingException
-
addToCache
protected void addToCache(java.lang.String type, org.eclipse.emf.ecore.EObject instance) throws EolModelElementTypeNotFoundException- Overrides:
addToCachein classCachedModel<org.eclipse.emf.ecore.EObject>- Throws:
EolModelElementTypeNotFoundException
-
removeFromCache
protected void removeFromCache(org.eclipse.emf.ecore.EObject instance) throws EolModelElementTypeNotFoundException- Overrides:
removeFromCachein classCachedModel<org.eclipse.emf.ecore.EObject>- Throws:
EolModelElementTypeNotFoundException
-
forceAddToCache
protected void forceAddToCache(org.eclipse.emf.ecore.EObject instance) throws EolModelElementTypeNotFoundExceptionWe 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:
setCachingEnabledin classCachedModel<org.eclipse.emf.ecore.EObject>- Since:
- 1.6
-
getMetamodelFiles
public java.util.List<java.lang.String> getMetamodelFiles()
-
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.
-
getMetamodelUris
public java.util.List<java.lang.String> getMetamodelUris()
-
getModelFile
public java.lang.String getModelFile()
-
getModelFileUri
public org.eclipse.emf.common.util.URI getModelFileUri()
-
setModelFileUri
public void setModelFileUri(org.eclipse.emf.common.util.URI modelFileUri)
-
getMetamodelFileUris
public java.util.List<org.eclipse.emf.common.util.URI> getMetamodelFileUris()
-
setMetamodelFileUris
public void setMetamodelFileUris(java.util.List<org.eclipse.emf.common.util.URI> fileUris)
-
setMetamodelFileUri
public void setMetamodelFileUri(org.eclipse.emf.common.util.URI uri)
-
setMetamodelUris
public void setMetamodelUris(java.util.List<java.lang.String> uris)
-
setMetamodelUri
public void setMetamodelUri(java.lang.String uri)
-
setMetamodelFiles
public void setMetamodelFiles(java.util.List<java.lang.String> paths)
-
setMetamodelFile
public void setMetamodelFile(java.lang.String path)
-
setModelFile
public void setModelFile(java.lang.String path)
-
isReuseUnmodifiedFileBasedMetamodels
public boolean isReuseUnmodifiedFileBasedMetamodels()
-
setReuseUnmodifiedFileBasedMetamodels
public void setReuseUnmodifiedFileBasedMetamodels(boolean reuseUnmodifiedFileBasedMetamodels)
-
hasProperty
public boolean hasProperty(java.lang.String type, java.lang.String property) throws EolModelElementTypeNotFoundException- Specified by:
hasPropertyin interfaceIReflectiveModel- Throws:
EolModelElementTypeNotFoundException
-
isEnumerationValue
public boolean isEnumerationValue(java.lang.Object object)
Description copied from interface:IReflectiveModelReturns true iff object is an enumeration value.- Specified by:
isEnumerationValuein interfaceIReflectiveModel
-
getEnumerationTypeOf
public java.lang.String getEnumerationTypeOf(java.lang.Object literal) throws EolNotAnEnumerationValueExceptionDescription copied from interface:IReflectiveModelReturns the name of the enumeration type of the literal parameter.- Specified by:
getEnumerationTypeOfin interfaceIReflectiveModel- Throws:
EolNotAnEnumerationValueException- when literal is not an enumeration value
-
getEnumerationLabelOf
public java.lang.String getEnumerationLabelOf(java.lang.Object literal) throws EolNotAnEnumerationValueExceptionDescription copied from interface:IReflectiveModelReturns the enumeration label of the literal parameter.- Specified by:
getEnumerationLabelOfin interfaceIReflectiveModel- Throws:
EolNotAnEnumerationValueException- when literal is not an enumeration value
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
determinePackagesFrom
protected void determinePackagesFrom(org.eclipse.emf.ecore.resource.ResourceSet resourceSet) throws EolModelLoadingException- Throws:
EolModelLoadingException
-
hasPackage
public boolean hasPackage(java.lang.String packageName)
Description copied from interface:IReflectiveModelReturns true iff this model contains a package with the given name. In general, a "package" is a group of types (and potentially other packages) and a namespace for the grouped elements. The precise semantics of "package" is specific to the implementation. For example, an Ecore implementation might use EPackage. An XML implementation might use XML namespaces. A CSV implementation might not support any notion of packages (and hence always return false).- Specified by:
hasPackagein interfaceIReflectiveModel
-
getMetamodel
public Metamodel getMetamodel(StringProperties properties, IRelativePathResolver resolver)
- Specified by:
getMetamodelin interfaceIModel- Overrides:
getMetamodelin classModel
-
-