Package org.eclipse.epsilon.emc.emf
Class AbstractEmfModel
- 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
-
- All Implemented Interfaces:
java.lang.AutoCloseable,IModel
- Direct Known Subclasses:
EmfMetaModel,EmfModel,VirtualEmfModel
public abstract class AbstractEmfModel extends CachedModel<org.eclipse.emf.ecore.EObject>
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanexpandprotected org.eclipse.emf.ecore.resource.ResourcemodelImplstatic java.lang.StringPROPERTY_EXPANDOne of the keys used to construct the first argument toModel.load(StringProperties, String).static java.lang.StringPROPERTY_PARALLELALLOFWhether to perform getAllOfKind and getAllOfType operations in parallel.protected org.eclipse.emf.ecore.EPackage.Registryregistryprotected java.util.Map<java.lang.Object,java.lang.Object>resourceLoadOptionsprotected java.util.Map<java.lang.Object,java.lang.Object>resourceStoreOptionsprotected EmfModelTransactionSupporttransactionSupport-
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 AbstractEmfModel()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddMetamodelUri(java.lang.String nsUri)protected java.util.Collection<org.eclipse.emf.ecore.EObject>allContentsFromModel()org.eclipse.emf.ecore.EClassclassForName(java.lang.String name)protected org.eclipse.emf.ecore.EClassclassForName(java.lang.String name, boolean absolute, org.eclipse.emf.ecore.EPackage pkg)protected org.eclipse.emf.ecore.EClassclassForName(java.lang.String name, org.eclipse.emf.ecore.EPackage.Registry registry)protected org.eclipse.emf.ecore.EObjectcreateInstanceInModel(java.lang.String type)protected booleandeleteElementInModel(java.lang.Object instance)Returns true iff the given instance was deleted from the model.voiddisposeModel()protected java.util.Collection<org.eclipse.emf.ecore.EObject>getAllOfKindFromModel(java.lang.String kind)protected java.util.Collection<org.eclipse.emf.ecore.EObject>getAllOfTypeFromModel(java.lang.String type)java.util.Collection<java.lang.String>getAllTypeNamesOf(java.lang.Object instance)Returns the fully qualified names of every type to which the given object conforms.java.lang.ObjectgetCacheKeyForType(java.lang.String type)Returns an identity for the given type, which will be used byCachedModelas a key for the memoization of model elements by type.java.lang.ObjectgetContainerOf(java.lang.Object object)java.lang.ObjectgetElementById(java.lang.String id)java.lang.StringgetElementId(java.lang.Object instance)java.lang.ObjectgetEnumerationValue(java.lang.String enumeration, java.lang.String label)protected java.lang.StringgetFullyQualifiedName(org.eclipse.emf.ecore.EClassifier eClassifier)java.lang.StringgetFullyQualifiedTypeNameOf(java.lang.Object instance)Returns a string representing the fully-qualified type of the instance object.protected java.io.InputStreamgetInputStream(java.lang.String file)org.eclipse.emf.ecore.resource.ResourcegetModelImpl()Deprecated.UsegetResource()insteadprotected org.eclipse.emf.ecore.EPackage.RegistrygetPackageRegistry()Get the (cached) package registry belonging to the model implementation, if no registry is available the global one is providedorg.eclipse.emf.ecore.resource.ResourcegetResource()java.util.Map<java.lang.Object,java.lang.Object>getResourceLoadOptions()protected java.util.List<org.eclipse.emf.ecore.resource.Resource>getResources()java.util.Map<java.lang.Object,java.lang.Object>getResourceStoreOptions()IModelTransactionSupportgetTransactionSupport()java.lang.StringgetTypeNameOf(java.lang.Object instance)Returns a string representing the type of the instance object.java.lang.ObjectgetTypeOf(java.lang.Object instance)protected booleanhasAdapter(java.lang.Class<? extends org.eclipse.emf.ecore.util.EContentAdapter> adapterType)Determines whether this model has an adapter matching the specified type.booleanhasType(java.lang.String type)protected voidinitCaches()Sets the caches based on this model's properties.booleanisExpand()booleanisInstantiable(java.lang.String type)booleanisLoaded()Convenience method for determining when a model has been loaded.booleanisModelElement(java.lang.Object instance)Used to test whether a Java object can be contained by this model.booleanisOfKind(java.lang.Object instance, java.lang.String metaClass)booleanisOfType(java.lang.Object instance, java.lang.String metaClass)booleanisParallelAllOf()booleanisPropertySet(java.lang.Object instance, java.lang.String property)Returnstrueif this instance has an explicit value for this property.booleanknowsAboutProperty(java.lang.Object instance, java.lang.String property)Returnstrueif this instance could have this property at some point.protected booleanknowsAboutProperty(org.eclipse.emf.ecore.EObject instance, java.lang.String property)voidload(StringProperties properties, IRelativePathResolver resolver)booleanowns(java.lang.Object instance)Used to test whether an object is contained in this model.java.lang.ObjectputResourceLoadOption(java.lang.Object key, java.lang.Object value)java.lang.ObjectputResourceStoreOption(java.lang.Object key, java.lang.Object value)voidsetElementId(java.lang.Object instance, java.lang.String newId)voidsetExpand(boolean expand)voidsetModelImpl(org.eclipse.emf.ecore.resource.Resource modelImpl)Deprecated.UsesetResource(Resource)insteadvoidsetParallelAllOf(boolean parallel)voidsetResource(org.eclipse.emf.ecore.resource.Resource resource)voidsetResourceLoadOptions(java.util.Map<java.lang.Object,java.lang.Object> options)voidsetResourceStoreOptions(java.util.Map<java.lang.Object,java.lang.Object> options)booleanstore(java.io.OutputStream os)booleanstore(java.lang.String fileName)booleanstore(org.eclipse.emf.common.util.URI uri)-
Methods inherited from class org.eclipse.epsilon.eol.models.CachedModel
addToCache, allContents, clearCache, createInstance, deleteElement, dispose, getAllOfKind, getAllOfKindOrType, getAllOfType, isCachingEnabled, isConcurrent, load, loadModel, removeFromCache, setCachingEnabled, setConcurrent, wrap
-
Methods inherited from class org.eclipse.epsilon.eol.models.Model
allInstances, createInstance, getAliases, getMetamodel, getName, getPropertyGetter, getPropertySetter, isReadOnLoad, isStoredOnDisposal, load, load, setName, setReadOnLoad, setStoredOnDisposal
-
-
-
-
Field Detail
-
PROPERTY_EXPAND
public static final java.lang.String PROPERTY_EXPAND
One of the keys used to construct the first argument toModel.load(StringProperties, String). When paired with "true", external references will be resolved during loading. Otherwise, external references are not resolved. Paired with "true" by default.- See Also:
- Constant Field Values
-
PROPERTY_PARALLELALLOF
public static final java.lang.String PROPERTY_PARALLELALLOF
Whether to perform getAllOfKind and getAllOfType operations in parallel. False by default.- See Also:
- Constant Field Values
-
modelImpl
protected org.eclipse.emf.ecore.resource.Resource modelImpl
-
expand
protected boolean expand
-
registry
protected org.eclipse.emf.ecore.EPackage.Registry registry
-
resourceLoadOptions
protected java.util.Map<java.lang.Object,java.lang.Object> resourceLoadOptions
-
resourceStoreOptions
protected java.util.Map<java.lang.Object,java.lang.Object> resourceStoreOptions
-
transactionSupport
protected EmfModelTransactionSupport transactionSupport
-
-
Method Detail
-
initCaches
protected void initCaches()
Description copied from class:CachedModelSets the caches based on this model's properties. This method should only be called if there has been a change to the properties (CachedModel.cachingEnabledorCachedModel.concurrent) as the caches will be reset.- Overrides:
initCachesin classCachedModel<org.eclipse.emf.ecore.EObject>
-
getInputStream
protected java.io.InputStream getInputStream(java.lang.String file) throws java.io.IOException- Throws:
java.io.IOException
-
addMetamodelUri
public void addMetamodelUri(java.lang.String nsUri)
-
getPackageRegistry
protected org.eclipse.emf.ecore.EPackage.Registry getPackageRegistry()
Get the (cached) package registry belonging to the model implementation, if no registry is available the global one is provided- Returns:
- the (global) package registry
-
getEnumerationValue
public java.lang.Object getEnumerationValue(java.lang.String enumeration, java.lang.String label) throws EolEnumerationValueNotFoundException
-
knowsAboutProperty
public boolean knowsAboutProperty(java.lang.Object instance, java.lang.String property)Description copied from interface:IModelReturnstrueif this instance could have this property at some point.- Specified by:
knowsAboutPropertyin interfaceIModel- Overrides:
knowsAboutPropertyin classModel
-
knowsAboutProperty
protected boolean knowsAboutProperty(org.eclipse.emf.ecore.EObject instance, java.lang.String property)
-
isPropertySet
public boolean isPropertySet(java.lang.Object instance, java.lang.String property) throws EolRuntimeExceptionDescription copied from interface:IModelReturnstrueif this instance has an explicit value for this property. This would be equivalent to eIsSet in EMF.- Specified by:
isPropertySetin interfaceIModel- Overrides:
isPropertySetin classModel- Throws:
EolRuntimeException
-
getAllOfTypeFromModel
protected java.util.Collection<org.eclipse.emf.ecore.EObject> getAllOfTypeFromModel(java.lang.String type) throws EolModelElementTypeNotFoundException- Specified by:
getAllOfTypeFromModelin classCachedModel<org.eclipse.emf.ecore.EObject>- Throws:
EolModelElementTypeNotFoundException
-
getAllOfKindFromModel
protected java.util.Collection<org.eclipse.emf.ecore.EObject> getAllOfKindFromModel(java.lang.String kind) throws EolModelElementTypeNotFoundException- Specified by:
getAllOfKindFromModelin classCachedModel<org.eclipse.emf.ecore.EObject>- Throws:
EolModelElementTypeNotFoundException
-
getCacheKeyForType
public java.lang.Object getCacheKeyForType(java.lang.String type) throws EolModelElementTypeNotFoundExceptionDescription copied from class:CachedModelReturns an identity for the given type, which will be used byCachedModelas a key for the memoization of model elements by type.- Specified by:
getCacheKeyForTypein classCachedModel<org.eclipse.emf.ecore.EObject>- Throws:
EolModelElementTypeNotFoundException
-
classForName
public org.eclipse.emf.ecore.EClass classForName(java.lang.String name) throws EolModelElementTypeNotFoundException
-
classForName
protected org.eclipse.emf.ecore.EClass classForName(java.lang.String name, org.eclipse.emf.ecore.EPackage.Registry registry)
-
classForName
protected org.eclipse.emf.ecore.EClass classForName(java.lang.String name, boolean absolute, org.eclipse.emf.ecore.EPackage pkg)
-
allContentsFromModel
protected java.util.Collection<org.eclipse.emf.ecore.EObject> allContentsFromModel()
- Specified by:
allContentsFromModelin classCachedModel<org.eclipse.emf.ecore.EObject>
-
createInstanceInModel
protected org.eclipse.emf.ecore.EObject createInstanceInModel(java.lang.String type) throws EolModelElementTypeNotFoundException, EolNotInstantiableModelElementTypeException- Specified by:
createInstanceInModelin classCachedModel<org.eclipse.emf.ecore.EObject>- Throws:
EolModelElementTypeNotFoundExceptionEolNotInstantiableModelElementTypeException
-
getTransactionSupport
public IModelTransactionSupport getTransactionSupport()
- Specified by:
getTransactionSupportin interfaceIModel- Overrides:
getTransactionSupportin classModel
-
deleteElementInModel
protected boolean deleteElementInModel(java.lang.Object instance) throws EolRuntimeExceptionDescription copied from class:CachedModelReturns true iff the given instance was deleted from the model.- Specified by:
deleteElementInModelin classCachedModel<org.eclipse.emf.ecore.EObject>- Throws:
EolRuntimeException
-
owns
public boolean owns(java.lang.Object instance)
Description copied from interface:IModelUsed to test whether an object is contained in this model.- Parameters:
instance- the Java object to test.- Returns:
- true if and only if instance is contained by this model.
-
store
public boolean store(java.lang.String fileName)
-
store
public boolean store(org.eclipse.emf.common.util.URI uri)
-
store
public boolean store(java.io.OutputStream os)
-
disposeModel
public void disposeModel()
- Specified by:
disposeModelin classCachedModel<org.eclipse.emf.ecore.EObject>
-
getResource
public org.eclipse.emf.ecore.resource.Resource getResource()
-
setResource
public void setResource(org.eclipse.emf.ecore.resource.Resource resource)
-
getModelImpl
@Deprecated public org.eclipse.emf.ecore.resource.Resource getModelImpl()
Deprecated.UsegetResource()instead
-
setModelImpl
public void setModelImpl(org.eclipse.emf.ecore.resource.Resource modelImpl)
Deprecated.UsesetResource(Resource)instead
-
getResources
protected java.util.List<org.eclipse.emf.ecore.resource.Resource> getResources()
-
getElementById
public java.lang.Object getElementById(java.lang.String id)
-
getElementId
public java.lang.String getElementId(java.lang.Object instance)
-
setElementId
public void setElementId(java.lang.Object instance, java.lang.String newId)
-
getTypeOf
public java.lang.Object getTypeOf(java.lang.Object instance)
-
getTypeNameOf
public java.lang.String getTypeNameOf(java.lang.Object instance)
Description copied from interface:IModelReturns a string representing the type of the instance object. The value returned by this function can be passed to createInstance to instantiate another object of the same type as instance.- Parameters:
instance- The model object whose type is to be determined.- Returns:
- the name of the type of the model object, instance.
-
getFullyQualifiedTypeNameOf
public java.lang.String getFullyQualifiedTypeNameOf(java.lang.Object instance)
Description copied from interface:IModelReturns a string representing the fully-qualified type of the instance object. The value returned by this function can be passed to createInstance to instantiate another object of the same type as instance.- Specified by:
getFullyQualifiedTypeNameOfin interfaceIModel- Overrides:
getFullyQualifiedTypeNameOfin classModel- Parameters:
instance- The model object whose type is to be determined.- Returns:
- the name of the type of the model object, instance.
-
getAllTypeNamesOf
public java.util.Collection<java.lang.String> getAllTypeNamesOf(java.lang.Object instance)
Description copied from class:CachedModelReturns the fully qualified names of every type to which the given object conforms. The values are used by byCachedModelfor the memoization of model elements by their kind (CachedModel.getAllOfKind(String)).- Specified by:
getAllTypeNamesOfin classCachedModel<org.eclipse.emf.ecore.EObject>
-
isInstantiable
public boolean isInstantiable(java.lang.String type)
-
hasType
public boolean hasType(java.lang.String type)
-
hasAdapter
protected boolean hasAdapter(java.lang.Class<? extends org.eclipse.emf.ecore.util.EContentAdapter> adapterType)
Determines whether this model has an adapter matching the specified type.- Parameters:
adapterType- The adapter class.- Returns:
trueif this model's adapters contains the specified adapter type.- Since:
- 1.6
-
getFullyQualifiedName
protected java.lang.String getFullyQualifiedName(org.eclipse.emf.ecore.EClassifier eClassifier)
-
isModelElement
public boolean isModelElement(java.lang.Object instance)
Description copied from interface:IModelUsed to test whether a Java object can be contained by this model. For example, EMF models can contain instances of EObject, but not instances of just Object.- Specified by:
isModelElementin interfaceIModel- Overrides:
isModelElementin classModel- Parameters:
instance- the Java object to test.- Returns:
- true if and only if instance can be contained by this model.
-
isOfKind
public boolean isOfKind(java.lang.Object instance, java.lang.String metaClass) throws EolModelElementTypeNotFoundException- Specified by:
isOfKindin interfaceIModel- Overrides:
isOfKindin classModel- Throws:
EolModelElementTypeNotFoundException
-
isOfType
public boolean isOfType(java.lang.Object instance, java.lang.String metaClass) throws EolModelElementTypeNotFoundException- Specified by:
isOfTypein interfaceIModel- Overrides:
isOfTypein classModel- Throws:
EolModelElementTypeNotFoundException
-
getContainerOf
public java.lang.Object getContainerOf(java.lang.Object object)
-
isExpand
public boolean isExpand()
-
setExpand
public void setExpand(boolean expand)
-
setParallelAllOf
public void setParallelAllOf(boolean parallel)
- Parameters:
parallel-- Since:
- 1.6
-
isParallelAllOf
public boolean isParallelAllOf()
- Returns:
- Since:
- 1.6
-
load
public void load(StringProperties properties, IRelativePathResolver resolver) throws EolModelLoadingException
- Specified by:
loadin interfaceIModel- Overrides:
loadin classCachedModel<org.eclipse.emf.ecore.EObject>- Throws:
EolModelLoadingException
-
isLoaded
public boolean isLoaded()
Description copied from class:CachedModelConvenience method for determining when a model has been loaded.- Overrides:
isLoadedin classCachedModel<org.eclipse.emf.ecore.EObject>- Returns:
- Whether the cache has been populated.
- Since:
- 1.6
-
getResourceLoadOptions
public java.util.Map<java.lang.Object,java.lang.Object> getResourceLoadOptions()
- Since:
- 2.3.0
-
setResourceLoadOptions
public void setResourceLoadOptions(java.util.Map<java.lang.Object,java.lang.Object> options)
- Since:
- 2.3.0
-
putResourceLoadOption
public java.lang.Object putResourceLoadOption(java.lang.Object key, java.lang.Object value)- Since:
- 2.3.0
-
getResourceStoreOptions
public java.util.Map<java.lang.Object,java.lang.Object> getResourceStoreOptions()
- Since:
- 2.3.0
-
setResourceStoreOptions
public void setResourceStoreOptions(java.util.Map<java.lang.Object,java.lang.Object> options)
- Since:
- 2.3.0
-
putResourceStoreOption
public java.lang.Object putResourceStoreOption(java.lang.Object key, java.lang.Object value)- Since:
- 2.3.0
-
-