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:
AutoCloseable,IModel
- Direct Known Subclasses:
AbstractReflectiveEmfModel,EmfMetaModel,VirtualEmfModel
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.eclipse.epsilon.eol.models.IModel
IModel.AmbiguityCheckResult -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanprotected org.eclipse.emf.ecore.resource.Resourcestatic final StringOne of the keys used to construct the first argument toModel.load(StringProperties, String).static final StringWhether to perform getAllOfKind and getAllOfType operations in parallel.protected org.eclipse.emf.ecore.EPackage.Registryprotected EmfModelTransactionSupportFields inherited from class org.eclipse.epsilon.eol.models.CachedModel
allContentsCache, kindCache, PROPERTY_CACHED, PROPERTY_CONCURRENT, typeCacheFields 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 -
Method Summary
Modifier and TypeMethodDescriptionvoidaddMetamodelUri(String nsUri) protected Collection<org.eclipse.emf.ecore.EObject>checkAmbiguity(String type) Used to test if a given type name is ambiguous or not within a model.protected Stream<org.eclipse.emf.ecore.EClass>classesForName(String name, org.eclipse.emf.ecore.EPackage.Registry registry) org.eclipse.emf.ecore.EClassclassForName(String name) protected org.eclipse.emf.ecore.EClassclassForName(String name, boolean absolute, org.eclipse.emf.ecore.EPackage pkg) protected org.eclipse.emf.ecore.EClassclassForName(String name, org.eclipse.emf.ecore.EPackage.Registry registry) protected org.eclipse.emf.ecore.EObjectcreateInstanceInModel(String type) protected booleandeleteElementInModel(Object instance) Returns true iff the given instance was deleted from the model.voidprotected Collection<org.eclipse.emf.ecore.EObject>getAllOfKindFromModel(String kind) protected Collection<org.eclipse.emf.ecore.EObject>getAllOfTypeFromModel(String type) getAllTypeNamesOf(Object instance) Returns the fully qualified names of every type to which the given object conforms.getCacheKeyForType(String type) Returns an identity for the given type, which will be used byCachedModelas a key for the memoization of model elements by type.getContainerOf(Object object) getElementById(String id) getElementId(Object instance) getEnumerationValue(String enumeration, String label) protected StringgetFullyQualifiedName(org.eclipse.emf.ecore.EClassifier eClassifier) getFullyQualifiedTypeNameOf(Object instance) Returns a string representing the fully-qualified type of the instance object.protected InputStreamgetInputStream(String file) org.eclipse.emf.ecore.resource.ResourceDeprecated.protected org.eclipse.emf.ecore.EPackage.RegistryGet the (cached) package registry belonging to the model implementation, if no registry is available the global one is providedorg.eclipse.emf.ecore.resource.Resourceprotected List<org.eclipse.emf.ecore.resource.Resource>getTypeNameOf(Object instance) Returns a string representing the type of the instance object.protected booleanhasAdapter(Class<? extends org.eclipse.emf.ecore.util.EContentAdapter> adapterType) Determines whether this model has an adapter matching the specified type.booleanprotected voidSets the caches based on this model's properties.booleanisExpand()booleanisInstantiable(String type) booleanisLoaded()Convenience method for determining when a model has been loaded.booleanisModelElement(Object instance) Used to test whether a Java object can be contained by this model.booleanbooleanbooleanbooleanisPropertySet(Object instance, String property) Returnstrueif this instance has an explicit value for this property.booleanknowsAboutProperty(Object instance, String property) Returnstrueif this instance could have this property at some point.protected booleanknowsAboutProperty(org.eclipse.emf.ecore.EObject instance, String property) voidload(StringProperties properties, IRelativePathResolver resolver) booleanUsed to test whether an object is contained in this model.putResourceLoadOption(Object key, Object value) putResourceStoreOption(Object key, Object value) voidsetElementId(Object instance, 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(Map<Object, Object> options) voidsetResourceStoreOptions(Map<Object, Object> options) booleanstore(OutputStream os) booleanbooleanstore(org.eclipse.emf.common.util.URI uri) voidvalidate()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, wrapUnmodifiableMethods inherited from class org.eclipse.epsilon.eol.models.Model
allInstances, createInstance, getAliases, getMetamodel, getName, getPropertyGetter, getPropertySetter, isReadOnLoad, isStoredOnDisposal, load, load, setName, setReadOnLoad, setStoredOnDisposal
-
Field Details
-
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:
-
PROPERTY_PARALLELALLOF
Whether to perform getAllOfKind and getAllOfType operations in parallel. False by default.- See Also:
-
modelImpl
protected org.eclipse.emf.ecore.resource.Resource modelImpl -
expand
protected boolean expand -
registry
protected org.eclipse.emf.ecore.EPackage.Registry registry -
resourceLoadOptions
-
resourceStoreOptions
-
transactionSupport
-
-
Constructor Details
-
AbstractEmfModel
public AbstractEmfModel()
-
-
Method Details
-
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
- Throws:
IOException
-
addMetamodelUri
-
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 Object getEnumerationValue(String enumeration, String label) throws EolEnumerationValueNotFoundException -
knowsAboutProperty
Description copied from interface:IModelReturnstrueif this instance could have this property at some point.- Specified by:
knowsAboutPropertyin interfaceIModel- Overrides:
knowsAboutPropertyin classModel
-
knowsAboutProperty
-
isPropertySet
Description 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 Collection<org.eclipse.emf.ecore.EObject> getAllOfTypeFromModel(String type) throws EolModelElementTypeNotFoundException - Specified by:
getAllOfTypeFromModelin classCachedModel<org.eclipse.emf.ecore.EObject>- Throws:
EolModelElementTypeNotFoundException
-
getAllOfKindFromModel
protected Collection<org.eclipse.emf.ecore.EObject> getAllOfKindFromModel(String kind) throws EolModelElementTypeNotFoundException - Specified by:
getAllOfKindFromModelin classCachedModel<org.eclipse.emf.ecore.EObject>- Throws:
EolModelElementTypeNotFoundException
-
getCacheKeyForType
Description 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(String name) throws EolModelElementTypeNotFoundException -
classForName
protected org.eclipse.emf.ecore.EClass classForName(String name, org.eclipse.emf.ecore.EPackage.Registry registry) -
classesForName
-
classForName
protected org.eclipse.emf.ecore.EClass classForName(String name, boolean absolute, org.eclipse.emf.ecore.EPackage pkg) -
allContentsFromModel
- Specified by:
allContentsFromModelin classCachedModel<org.eclipse.emf.ecore.EObject>
-
createInstanceInModel
protected org.eclipse.emf.ecore.EObject createInstanceInModel(String type) throws EolModelElementTypeNotFoundException, EolNotInstantiableModelElementTypeException - Specified by:
createInstanceInModelin classCachedModel<org.eclipse.emf.ecore.EObject>- Throws:
EolModelElementTypeNotFoundExceptionEolNotInstantiableModelElementTypeException
-
getTransactionSupport
- Specified by:
getTransactionSupportin interfaceIModel- Overrides:
getTransactionSupportin classModel
-
deleteElementInModel
Description 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
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
-
store
public boolean store(org.eclipse.emf.common.util.URI uri) -
store
-
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.UsegetResource()instead -
setModelImpl
public void setModelImpl(org.eclipse.emf.ecore.resource.Resource modelImpl) Deprecated.UsesetResource(Resource)instead -
getResources
-
getElementById
-
getElementId
-
setElementId
-
getTypeOf
-
getTypeNameOf
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
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
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
-
hasType
-
checkAmbiguity
Description copied from interface:IModelUsed to test if a given type name is ambiguous or not within a model. For example, the package registry in an EMF model could include multiple EClasses with the same name. -
hasAdapter
protected boolean hasAdapter(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
-
isModelElement
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(Object instance, String metaClass) throws EolModelElementTypeNotFoundException - Specified by:
isOfKindin interfaceIModel- Overrides:
isOfKindin classModel- Throws:
EolModelElementTypeNotFoundException
-
isOfType
public boolean isOfType(Object instance, String metaClass) throws EolModelElementTypeNotFoundException - Specified by:
isOfTypein interfaceIModel- Overrides:
isOfTypein classModel- Throws:
EolModelElementTypeNotFoundException
-
getContainerOf
-
validate
- Throws:
EolModelLoadingException
-
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
- Since:
- 2.3.0
-
setResourceLoadOptions
- Since:
- 2.3.0
-
putResourceLoadOption
- Since:
- 2.3.0
-
getResourceStoreOptions
- Since:
- 2.3.0
-
setResourceStoreOptions
- Since:
- 2.3.0
-
putResourceStoreOption
- Since:
- 2.3.0
-
getResource()instead