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
Modifier and TypeFieldDescriptionprotected boolean
protected org.eclipse.emf.ecore.resource.Resource
static final String
One of the keys used to construct the first argument toModel.load(StringProperties, String)
.static final String
Whether to perform getAllOfKind and getAllOfType operations in parallel.protected org.eclipse.emf.ecore.EPackage.Registry
protected EmfModelTransactionSupport
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
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addMetamodelUri
(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.EClass
classForName
(String name) protected org.eclipse.emf.ecore.EClass
classForName
(String name, boolean absolute, org.eclipse.emf.ecore.EPackage pkg) protected org.eclipse.emf.ecore.EClass
classForName
(String name, org.eclipse.emf.ecore.EPackage.Registry registry) protected org.eclipse.emf.ecore.EObject
createInstanceInModel
(String type) protected boolean
deleteElementInModel
(Object instance) Returns true iff the given instance was deleted from the model.void
protected 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 byCachedModel
as 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 String
getFullyQualifiedName
(org.eclipse.emf.ecore.EClassifier eClassifier) getFullyQualifiedTypeNameOf
(Object instance) Returns a string representing the fully-qualified type of the instance object.protected InputStream
getInputStream
(String file) org.eclipse.emf.ecore.resource.Resource
Deprecated.protected org.eclipse.emf.ecore.EPackage.Registry
Get the (cached) package registry belonging to the model implementation, if no registry is available the global one is providedorg.eclipse.emf.ecore.resource.Resource
protected List<org.eclipse.emf.ecore.resource.Resource>
getTypeNameOf
(Object instance) Returns a string representing the type of the instance object.protected boolean
hasAdapter
(Class<? extends org.eclipse.emf.ecore.util.EContentAdapter> adapterType) Determines whether this model has an adapter matching the specified type.boolean
protected void
Sets the caches based on this model's properties.boolean
isExpand()
boolean
isInstantiable
(String type) boolean
isLoaded()
Convenience method for determining when a model has been loaded.boolean
isModelElement
(Object instance) Used to test whether a Java object can be contained by this model.boolean
boolean
boolean
boolean
isPropertySet
(Object instance, String property) Returnstrue
if this instance has an explicit value for this property.boolean
knowsAboutProperty
(Object instance, String property) Returnstrue
if this instance could have this property at some point.protected boolean
knowsAboutProperty
(org.eclipse.emf.ecore.EObject instance, String property) void
load
(StringProperties properties, IRelativePathResolver resolver) boolean
Used to test whether an object is contained in this model.putResourceLoadOption
(Object key, Object value) putResourceStoreOption
(Object key, Object value) void
setElementId
(Object instance, String newId) void
setExpand
(boolean expand) void
setModelImpl
(org.eclipse.emf.ecore.resource.Resource modelImpl) Deprecated.UsesetResource(Resource)
insteadvoid
setParallelAllOf
(boolean parallel) void
setResource
(org.eclipse.emf.ecore.resource.Resource resource) void
setResourceLoadOptions
(Map<Object, Object> options) void
setResourceStoreOptions
(Map<Object, Object> options) boolean
store
(OutputStream os) boolean
boolean
store
(org.eclipse.emf.common.util.URI uri) void
validate()
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 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:CachedModel
Sets the caches based on this model's properties. This method should only be called if there has been a change to the properties (CachedModel.cachingEnabled
orCachedModel.concurrent
) as the caches will be reset.- Overrides:
initCaches
in 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:IModel
Returnstrue
if this instance could have this property at some point.- Specified by:
knowsAboutProperty
in interfaceIModel
- Overrides:
knowsAboutProperty
in classModel
-
knowsAboutProperty
-
isPropertySet
Description copied from interface:IModel
Returnstrue
if this instance has an explicit value for this property. This would be equivalent to eIsSet in EMF.- Specified by:
isPropertySet
in interfaceIModel
- Overrides:
isPropertySet
in classModel
- Throws:
EolRuntimeException
-
getAllOfTypeFromModel
protected Collection<org.eclipse.emf.ecore.EObject> getAllOfTypeFromModel(String type) throws EolModelElementTypeNotFoundException - Specified by:
getAllOfTypeFromModel
in classCachedModel<org.eclipse.emf.ecore.EObject>
- Throws:
EolModelElementTypeNotFoundException
-
getAllOfKindFromModel
protected Collection<org.eclipse.emf.ecore.EObject> getAllOfKindFromModel(String kind) throws EolModelElementTypeNotFoundException - Specified by:
getAllOfKindFromModel
in classCachedModel<org.eclipse.emf.ecore.EObject>
- Throws:
EolModelElementTypeNotFoundException
-
getCacheKeyForType
Description copied from class:CachedModel
Returns an identity for the given type, which will be used byCachedModel
as a key for the memoization of model elements by type.- Specified by:
getCacheKeyForType
in 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:
allContentsFromModel
in classCachedModel<org.eclipse.emf.ecore.EObject>
-
createInstanceInModel
protected org.eclipse.emf.ecore.EObject createInstanceInModel(String type) throws EolModelElementTypeNotFoundException, EolNotInstantiableModelElementTypeException - Specified by:
createInstanceInModel
in classCachedModel<org.eclipse.emf.ecore.EObject>
- Throws:
EolModelElementTypeNotFoundException
EolNotInstantiableModelElementTypeException
-
getTransactionSupport
- Specified by:
getTransactionSupport
in interfaceIModel
- Overrides:
getTransactionSupport
in classModel
-
deleteElementInModel
Description copied from class:CachedModel
Returns true iff the given instance was deleted from the model.- Specified by:
deleteElementInModel
in classCachedModel<org.eclipse.emf.ecore.EObject>
- Throws:
EolRuntimeException
-
owns
Description copied from interface:IModel
Used 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:
disposeModel
in 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:IModel
Returns 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:IModel
Returns 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:
getFullyQualifiedTypeNameOf
in interfaceIModel
- Overrides:
getFullyQualifiedTypeNameOf
in 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:CachedModel
Returns the fully qualified names of every type to which the given object conforms. The values are used by byCachedModel
for the memoization of model elements by their kind (CachedModel.getAllOfKind(String)
).- Specified by:
getAllTypeNamesOf
in classCachedModel<org.eclipse.emf.ecore.EObject>
-
isInstantiable
-
hasType
-
checkAmbiguity
Description copied from interface:IModel
Used 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:
true
if this model's adapters contains the specified adapter type.- Since:
- 1.6
-
getFullyQualifiedName
-
isModelElement
Description copied from interface:IModel
Used 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:
isModelElement
in interfaceIModel
- Overrides:
isModelElement
in 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:
isOfKind
in interfaceIModel
- Overrides:
isOfKind
in classModel
- Throws:
EolModelElementTypeNotFoundException
-
isOfType
public boolean isOfType(Object instance, String metaClass) throws EolModelElementTypeNotFoundException - Specified by:
isOfType
in interfaceIModel
- Overrides:
isOfType
in 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:
load
in interfaceIModel
- Overrides:
load
in classCachedModel<org.eclipse.emf.ecore.EObject>
- Throws:
EolModelLoadingException
-
isLoaded
public boolean isLoaded()Description copied from class:CachedModel
Convenience method for determining when a model has been loaded.- Overrides:
isLoaded
in 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