Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » How to figure out all attributes and associations of any model class
How to figure out all attributes and associations of any model class [message #495243] Wed, 04 November 2009 10:18 Go to next message
Eclipse UserFriend
Originally posted by: formatzeh.gmx.de

I'm currently working in an environment where several generated EMF
meta-models can be situated. So it happens that I get a concrete model
and want to print out some information about it. For example I get the
root EObject with the following statement:

EObject root = resource.getContents().get(0);

Now I want to iterate over every class in this class hierarchy and want
to print out every property which where modeled in the meta-model. Is it
possible anyhow to figure out generically for any model class for any
meta-model the properties? Until now I only do reflection to see if an
EObject has a "getName()" method to print out the name. I hope I
expressed myself understandable.

best regards,
Gilbert
Re: How to figure out all attributes and associations of any model class [message #495316 is a reply to message #495243] Wed, 04 November 2009 14:52 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: c.krause.cwi.nl

Hi Gilbert,

EMF is fully reflective. Try root.eClass(). This gives you the
corresponding ECLass from where you can explore the whole class and
package content. It might also help to take a look at the Ecore metamodel.

Cheers,
Christian

Gilbert Mirenque wrote:
> I'm currently working in an environment where several generated EMF
> meta-models can be situated. So it happens that I get a concrete model
> and want to print out some information about it. For example I get the
> root EObject with the following statement:
>
> EObject root = resource.getContents().get(0);
>
> Now I want to iterate over every class in this class hierarchy and want
> to print out every property which where modeled in the meta-model. Is it
> possible anyhow to figure out generically for any model class for any
> meta-model the properties? Until now I only do reflection to see if an
> EObject has a "getName()" method to print out the name. I hope I
> expressed myself understandable.
>
> best regards,
> Gilbert
Re: How to figure out all attributes and associations of any model class [message #495353 is a reply to message #495316] Wed, 04 November 2009 15:42 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
Registered: July 2009
Senior Member
Specifically you can call getEAllStructuralFeatures on that EClass and
use those with eGet to access all "properties" of the instance.

Christian Krause wrote:
> Hi Gilbert,
>
> EMF is fully reflective. Try root.eClass(). This gives you the
> corresponding ECLass from where you can explore the whole class and
> package content. It might also help to take a look at the Ecore
> metamodel.
>
> Cheers,
> Christian
>
> Gilbert Mirenque wrote:
>> I'm currently working in an environment where several generated EMF
>> meta-models can be situated. So it happens that I get a concrete model
>> and want to print out some information about it. For example I get the
>> root EObject with the following statement:
>>
>> EObject root = resource.getContents().get(0);
>>
>> Now I want to iterate over every class in this class hierarchy and want
>> to print out every property which where modeled in the meta-model. Is it
>> possible anyhow to figure out generically for any model class for any
>> meta-model the properties? Until now I only do reflection to see if an
>> EObject has a "getName()" method to print out the name. I hope I
>> expressed myself understandable.
>>
>> best regards,
>> Gilbert


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: How to figure out all attributes and associations of any model class [message #495554 is a reply to message #495353] Thu, 05 November 2009 10:49 Go to previous message
Eclipse UserFriend
Originally posted by: formatzeh.gmx.de

Thanks to you both. Very nice
Previous Topic:Resource URL oddity
Next Topic:child creation extenders
Goto Forum:
  


Current Time: Sat Apr 20 00:08:59 GMT 2024

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

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

Back to the top