Home » Modeling » EMF » How is EDataType modeled to relate to its instances EString, EInt and so on
How is EDataType modeled to relate to its instances EString, EInt and so on [message #431110] |
Mon, 29 June 2009 09:28  |
Eclipse User |
|
|
|
Hi,
I am looking at the ecore metamodel at or.eclipse.emf.ecore.metamodel and
I am wondering how exactly is it specified that the primitive data types
with instance classes the corresponding java types are connected to
EDataType. There is no "visible" connection. Attributes have
eattributeType reference to EDataType and then is the link to the
primitive data types lost for me. If I look at the serialized version of
the ecore, I can see that EInt, EString and so on are instances of
EDataType, but I definetely do not see this in the model.
I am trying to do a small metamodel of mine. which lets say has just
classe, which have attributes, and the attributes have a type, how do I
model this (I want it to be the same as in Ecore, as I will also have
enumerations).
Thank you for your help and for making things clear.
|
|
| | | | | |
Re: How is EDataType modeled to relate to its instances EString, EInt and so on [message #431141 is a reply to message #431123] |
Tue, 30 June 2009 05:10   |
Eclipse User |
|
|
|
Ok, so I really didn't explain my question correctly from the very
beginning, sorry for that, let me try to say it with other words.
So here is the scenario that I have. I want to have a metamodel of mine,
which has a "Class" Eclass (similarly to the "EClass" Eclass in ecore) I
also want this class to aggregate(contain) another EClass called Attribute
(similarly to the "EAttribute" EClass) so I am a kind of rewriting and
simplyfying the ecore model. Now I want the instances of the "Attribute"
class to have a type, which is either one of the primitive data types or
to be an enumeration type. That is why I am modeling other classes,
meaning the "DataType" Eclass and the "Enumeration" Class that inherits
form it (Untill now everything is as copied from ecore with EDataType and
EEnum). And the question is how do I model now, that my attributes (the
instances of the "Attribute" EClass) have a primitive data type? Here is
the piece that I am missing also in ecore, how are all the listed
EdataTypes( EInt, EString etc.) modeled as instances of "EDataType". So I
want to do it the very same way for my "DataType" EClass.
I hope now the question is a bit clearer.
Greets, Petko
|
|
|
Re: How is EDataType modeled to relate to its instances EString, EInt and so on [message #431143 is a reply to message #431141] |
Tue, 30 June 2009 05:22   |
Eclipse User |
|
|
|
Petko,
Comments below.
Petko wrote:
> Ok, so I really didn't explain my question correctly from the very
> beginning, sorry for that, let me try to say it with other words.
> So here is the scenario that I have. I want to have a metamodel of
> mine, which has a "Class" Eclass (similarly to the "EClass" Eclass in
> ecore) I also want this class to aggregate(contain) another EClass
> called Attribute (similarly to the "EAttribute" EClass) so I am a kind
> of rewriting and simplyfying the ecore model. Now I want the instances
> of the "Attribute" class to have a type, which is either one of the
> primitive data types or to be an enumeration type. That is why I am
> modeling other classes, meaning the "DataType" Eclass and the
> "Enumeration" Class that inherits form it (Untill now everything is as
> copied from ecore with EDataType and EEnum). And the question is how
> do I model now, that my attributes (the instances of the "Attribute"
> EClass) have a primitive data type?
There isn't a special EDataType subclass for primitives. Any EDataType
can wrap a primitive, i.e., can be such that
eDataType.getInstanceClass().isPrimitive() is true. Note that
java.lang.String is not a primitive type.
> Here is the piece that I am missing also in ecore, how are all the
> listed EdataTypes( EInt, EString etc.) modeled as instances of
> "EDataType".
An EPackage contains EClassifiers that can be either EClasses or
EDataTypes. So the EPackage instance that represents Ecore contains
EDataTypes such as EInt. I'm not sure if your simplified types and
properties model has packages, but the idea is that you'd want to have a
collection of predefined/built-in data types somewhere...
> So I want to do it the very same way for my "DataType" EClass.
> I hope now the question is a bit clearer.
Have you looked closely at Ecore.ecore? I.e.,
platform:/plugin/org.eclipse.emf.ecore/model/Ecore.ecore. Maybe that
makes it more clear?
> Greets, Petko
>
|
|
| |
Re: How is EDataType modeled to relate to its instances EString, EInt and so on [message #431153 is a reply to message #431152] |
Tue, 30 June 2009 06:52  |
Eclipse User |
|
|
|
Petko,
Comments below.
Petko wrote:
>
>> Have you looked closely at Ecore.ecore? I.e.,
>> platform:/plugin/org.eclipse.emf.ecore/model/Ecore.ecore. Maybe that
>> makes it more clear?
>
> I am looking at the Ecore.ecore ... and I do not see an additional
> package that contains the predefined data types, so they have to be
> somehow built-in?
>> An EPackage contains EClassifiers that can be either EClasses or
>> EDataTypes. So the EPackage instance that represents Ecore contains
>> EDataTypes such as EInt. I'm not sure if your simplified types and
>> properties model has packages, but the idea is that you'd want to
>> have a collection of predefined/built-in data types somewhere...
>
> How exactly do I do this in my model, make a package, that contains
> the data types that I want
Yes, or perhaps just list them as root objects in some omnipresent resource.
> but then how to connect them to the DataType class?
They're instances of the DataType class...
> I still do not get it. Or how to have the data types predefined?
Note that Ecore.ecore is an instance of an EPackage and that it is self
defining. So it contains EDataType instances that are used to define
other parts of the Ecore model.
> How do I model the collection of the data types?
Instances of DataType, just as EcorePackage.Literals.EINT.eClass() ==
EcorePackage.Literals.EDATA_TYPE.
>
> 10x, Petko
>
>
>
|
|
|
Goto Forum:
Current Time: Wed Jul 23 08:21:05 EDT 2025
Powered by FUDForum. Page generated in 0.10601 seconds
|