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>>elementsByTypeprotected EMFReferenceModelreferenceModelThe metamodel.
-
Constructor Summary
Constructors Constructor Description EMFModel(EMFReferenceModel referenceModel, EMFModelFactory mf)Creates a newEMFModelconforming to the givenEMFReferenceModel.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcommitToResource()Finalizes the model.protected voidfinalize()java.util.Set<org.eclipse.emf.ecore.EObject>getElementsByType(java.lang.Object metaElement)Returns aSetof the elements matching the given type.EMFModelFactorygetModelFactory()Returns the ModelFactory used to create the current model.EMFReferenceModelgetReferenceModel()Returns theIReferenceModel(i.e.org.eclipse.emf.ecore.resource.ResourcegetResource()Returns the resource.booleanisModelOf(java.lang.Object object)Returns true if the given object is contained in this model's resource or a referenced resource.booleanisTarget()Defines if the model is readonly or not.java.lang.ObjectnewElement(java.lang.Object metaElement)Creates a new element in the model.voidsetIsTarget(boolean value)Sets if the model is readonly or not.protected voidsetResource(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 newEMFModelconforming 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:
newElementin 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:
getReferenceModelin interfaceIModel- Returns:
- the
IReferenceModel - See Also:
IModel.getReferenceModel()
-
getElementsByType
public java.util.Set<org.eclipse.emf.ecore.EObject> getElementsByType(java.lang.Object metaElement)
Returns aSetof the elements matching the given type.- Specified by:
getElementsByTypein interfaceIModel- Parameters:
metaElement- a metatype- Returns:
- a
Setof 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:
isTargetin 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:
setIsTargetin 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:
getModelFactoryin 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:
isModelOfin 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:
finalizein classjava.lang.Object- Throws:
java.lang.Throwable- See Also:
Object.finalize()
-
-