Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
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 13:28 Go to next message
Pi is currently offline PiFriend
Messages: 12
Registered: July 2009
Junior Member
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 #431111 is a reply to message #431110] Mon, 29 June 2009 13:39 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: richkulp.us.NO_SPAM.ibm.com

Hi,

The connection is through the Efactories and the EDataType. In EMF
datatype instances (such as Strong, long, etc.) are not EMF objects in
themselves. An EDataType instance can be any Java class. The EDataType
model object contains as an attribute setting on it the java class that
the EDataType model object is modeling. Then the EFactory is then used
to serialize the datatype to an XMI file and to reconstruct the datatype
from the XMI file. By default for datatypes it assumes that it can use
toString() to put it out to an XMI file and use a constructor on the
Java class that takes a String to create the instance. If the desired
datatype java class does not follow both of these conventions then the
EFactory must be customized to handle it.

Enumerations are handled entirely in specialized code for enums.

--
Thanks,
Rich Kulp
Re: How is EDataType modeled to relate to its instances EString, EInt and so on [message #431114 is a reply to message #431111] Mon, 29 June 2009 15:03 Go to previous messageGo to next message
Pi is currently offline PiFriend
Messages: 12
Registered: July 2009
Junior Member
What I was more heading to is how things are done in the meta metamodel
and not in a metamodel, created using ecore. So the question is more how
ecore knows that EInt, EDate or whatever is an instance of EDataType as
there is no association, aggregation or generalisation from EDatatype to
its instances or without having any attribute(of the class EDataType) that
is of a primitive data type(or any Java Class) set to any of the modeled
E* types.
10x, Petko
Re: How is EDataType modeled to relate to its instances EString, EInt and so on [message #431117 is a reply to message #431114] Mon, 29 June 2009 16:27 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Petko,

Comments below.

Petko wrote:
> What I was more heading to is how things are done in the meta
> metamodel and not in a metamodel, created using ecore.
Yet another meta above Ecore. I think that's still Ecore...
> So the question is more how ecore knows that EInt, EDate or whatever
> is an instance of EDataType as there is no association, aggregation or
> generalisation from EDatatype to its instances or without having any
> attribute(of the class EDataType) that is of a primitive data type(or
> any Java Class) set to any of the modeled E* types.
That sentence hurt my brain. I'm really not sure what you're asking.
EInt is an EObject and the eClass() for it is EDataType's EClass...
> 10x, Petko
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: How is EDataType modeled to relate to its instances EString, EInt and so on [message #431120 is a reply to message #431114] Mon, 29 June 2009 16:33 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: richkulp.us.NO_SPAM.ibm.com

Hi,

We really don't talk about meta meta models. It is far too confusing and
it really doesn't help to make things clearer.

In EMF there is the model, and the instances. That's basically it. The
model is the EClasses and EDataTypes and their settings. The instances
are EObjects and java objects. The EClasses describe the EObjects and
EDataTypes describe the java classes. That's it. Very simple.

Petko wrote:
> What I was more heading to is how things are done in the meta metamodel
> and not in a metamodel, created using ecore. So the question is more how
> ecore knows that EInt, EDate or whatever is an instance of EDataType as
> there is no association, aggregation or generalisation from EDatatype to
> its instances or without having any attribute(of the class EDataType)
> that is of a primitive data type(or any Java Class) set to any of the
> modeled E* types.
> 10x, Petko
>

--
Thanks,
Rich Kulp
Re: How is EDataType modeled to relate to its instances EString, EInt and so on [message #431123 is a reply to message #431120] Mon, 29 June 2009 16:38 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: richkulp.us.NO_SPAM.ibm.com

As for how it knows that an EInt is a primitive java int, that is done
in the initialization of the ECorePackageImpl. It uses the line:

initEDataType(eIntEDataType, int.class, "EInt", IS_SERIALIZABLE,
!IS_GENERATED_INSTANCE_CLASS);

where int.class is the java class of the datatype.

--
Thanks,
Rich Kulp
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 09:10 Go to previous messageGo to next message
Pi is currently offline PiFriend
Messages: 12
Registered: July 2009
Junior Member
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 09:22 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
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
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: How is EDataType modeled to relate to its instances EString, EInt and so on [message #431152 is a reply to message #431143] Tue, 30 June 2009 10:22 Go to previous messageGo to next message
Pi is currently offline PiFriend
Messages: 12
Registered: July 2009
Junior Member
> 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 but then how to connect them to the DataType class?
I still do not get it. Or how to have the data types predefined? How do I
model the collection of the data types?

10x, 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 10:52 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
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
>
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:Converting EMF model instance to Ecore
Next Topic:Regarding XPand template file
Goto Forum:
  


Current Time: Wed Apr 24 23:58:05 GMT 2024

Powered by FUDForum. Page generated in 0.03717 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top