Package org.eclipse.m2m.atl.core.emf
Class EMFModel
- java.lang.Object
-
- org.eclipse.m2m.atl.core.emf.EMFModel
-
- All Implemented Interfaces:
IModel
- Direct Known Subclasses:
AtlResourceImpl.EMFModelWrapper
,EMFReferenceModel
public class EMFModel extends java.lang.Object implements IModel
The EMF implementation ofIModel
.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Map<org.eclipse.emf.ecore.EClass,java.util.Set<org.eclipse.emf.ecore.EObject>>
elementsByType
protected EMFReferenceModel
referenceModel
The metamodel.
-
Constructor Summary
Constructors Constructor Description EMFModel(EMFReferenceModel referenceModel, EMFModelFactory mf)
Creates a newEMFModel
conforming to the givenEMFReferenceModel
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
commitToResource()
Finalizes the model.protected void
finalize()
java.util.Set<org.eclipse.emf.ecore.EObject>
getElementsByType(java.lang.Object metaElement)
Returns aSet
of the elements matching the given type.EMFModelFactory
getModelFactory()
Returns the ModelFactory used to create the current model.EMFReferenceModel
getReferenceModel()
Returns theIReferenceModel
(i.e.org.eclipse.emf.ecore.resource.Resource
getResource()
Returns the resource.boolean
isModelOf(java.lang.Object object)
Returns true if the given object is contained in this model's resource or a referenced resource.boolean
isTarget()
Defines if the model is readonly or not.java.lang.Object
newElement(java.lang.Object metaElement)
Creates a new element in the model.void
setIsTarget(boolean value)
Sets if the model is readonly or not.protected void
setResource(org.eclipse.emf.ecore.resource.Resource resource)
Sets the resource with the resource value.
-
-
-
Field Detail
-
referenceModel
protected EMFReferenceModel referenceModel
The metamodel.
-
elementsByType
protected java.util.Map<org.eclipse.emf.ecore.EClass,java.util.Set<org.eclipse.emf.ecore.EObject>> elementsByType
-
-
Constructor Detail
-
EMFModel
public EMFModel(EMFReferenceModel referenceModel, EMFModelFactory mf)
Creates a newEMFModel
conforming to the givenEMFReferenceModel
.- Parameters:
referenceModel
- the metamodel.mf
- the model factory that is creating this model.
-
-
Method Detail
-
newElement
public java.lang.Object newElement(java.lang.Object metaElement)
Creates a new element in the model.- Specified by:
newElement
in interfaceIModel
- Parameters:
metaElement
- the new element metatype- Returns:
- the newly created element
- See Also:
IModel.newElement(java.lang.Object)
-
getReferenceModel
public EMFReferenceModel getReferenceModel()
Returns theIReferenceModel
(i.e. the metamodel).- Specified by:
getReferenceModel
in interfaceIModel
- Returns:
- the
IReferenceModel
- See Also:
IModel.getReferenceModel()
-
getElementsByType
public java.util.Set<org.eclipse.emf.ecore.EObject> getElementsByType(java.lang.Object metaElement)
Returns aSet
of the elements matching the given type.- Specified by:
getElementsByType
in interfaceIModel
- Parameters:
metaElement
- a metatype- Returns:
- a
Set
of the elements matching the given type - See Also:
IModel.getElementsByType(java.lang.Object)
-
isTarget
public boolean isTarget()
Defines if the model is readonly or not.- Specified by:
isTarget
in interfaceIModel
- Returns:
- true if the model allows writing
- See Also:
IModel.isTarget()
-
setIsTarget
public void setIsTarget(boolean value)
Sets if the model is readonly or not.- Specified by:
setIsTarget
in interfaceIModel
- Parameters:
value
- true if the model allows writing- See Also:
IModel.setIsTarget(boolean)
-
getResource
public org.eclipse.emf.ecore.resource.Resource getResource()
Returns the resource.- Returns:
- the resource
-
setResource
protected void setResource(org.eclipse.emf.ecore.resource.Resource resource)
Sets the resource with the resource value.- Parameters:
resource
- the resource to set
-
getModelFactory
public EMFModelFactory getModelFactory()
Returns the ModelFactory used to create the current model.- Specified by:
getModelFactory
in interfaceIModel
- Returns:
- true if the model allows writing
- See Also:
IModel.getModelFactory()
-
commitToResource
public void commitToResource()
Finalizes the model.
-
isModelOf
public boolean isModelOf(java.lang.Object object)
Returns true if the given object is contained in this model's resource or a referenced resource.- Specified by:
isModelOf
in interfaceIModel
- Parameters:
object
- the model element- Returns:
- true if object is contained in this model's resource or a referenced resource
- See Also:
IModel.isModelOf(java.lang.Object)
-
finalize
protected void finalize() throws java.lang.Throwable
- Overrides:
finalize
in classjava.lang.Object
- Throws:
java.lang.Throwable
- See Also:
Object.finalize()
-
-