Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » How to get all the derived classes
How to get all the derived classes [message #422692] Sat, 13 September 2008 10:27 Go to next message
Aline is currently offline AlineFriend
Messages: 32
Registered: July 2009
Member
Hi,

I was wondering if there is an ecore tool (or sthg else) to get all the
types that can be added in a feature. Typically, I have a class Person,
and two derived classes Male and Female and I want to get both classes
when the input of the feature is an instance of Person.

Can anyone help me ?

Thx in advance,

Aline
Re: How to get all the derived classes [message #422693 is a reply to message #422692] Sat, 13 September 2008 10:47 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30823
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------090309040406040401030509
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit

Aline,

This seems related to
< http://ed-merks.blogspot.com/2008/01/creating-children-you-d idnt-know.html>


http://ed-merks.blogspot.com/2008/01/creating-children-you-d idnt-know.html

Generally you can't know all possible derived classes. You need some
way of bounding the search first. Once you have the set of all possible
classes under consideration, you can determine which of them have the
class of interest among its getEAllSuperTypes.


Aline wrote:
> Hi,
>
> I was wondering if there is an ecore tool (or sthg else) to get all
> the types that can be added in a feature. Typically, I have a class
> Person, and two derived classes Male and Female and I want to get
> both classes when the input of the feature is an instance of Person.
>
> Can anyone help me ?
>
> Thx in advance,
>
> Aline
>

--------------090309040406040401030509
Content-Type: text/html; charset=ISO-8859-15
Content-Transfer-Encoding: 8bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-15"
http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Aline,<br>
<br>
This seems related to <a
href=" http://ed-merks.blogspot.com/2008/01/creating-children-you-d idnt-know.html"><br>
</a>
<blockquote><a
href=" http://ed-merks.blogspot.com/2008/01/creating-children-you-d idnt-know.html"> http://ed-merks.blogspot.com/2008/01/creating-children-you-d idnt-know.html</a><br>
</blockquote>
Generally you can't know all possible derived classes.
Re: How to get all the derived classes [message #422710 is a reply to message #422693] Sun, 14 September 2008 16:58 Go to previous messageGo to next message
Aline is currently offline AlineFriend
Messages: 32
Registered: July 2009
Member
Hi,

Thanks for your answer.
I finally found what I needed and it was very simple -_-'
I just needed to do :
ProjetFactory.eINSTANCE.getEPackage().getEClassifiers();
and then work with the list.

Is there a difference between getEPackage() and getProjetPackage() ? The
results seem to be the same...

Thanks in advance,

Aline
Re: How to get all the derived classes [message #422713 is a reply to message #422710] Sun, 14 September 2008 17:43 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30823
Registered: July 2009
Senior Member
Aline,

The generated XyzFactory and XyzPackage have specialized getters,
getXyzPackage and getXyzFactory that are effectively the same as
getEPackage and getEFactory, but with a more specialized type. With
Java 5.0's support for covariant return types, we'd likely have just
reused the method name and specified the more specific type that way.
But this was done before Java 5.0 was on the horizon.

In your case, you probably want to use
ProjectPackage.eINSTANCE.getEClassifiers() directly.


Aline wrote:
> Hi,
>
> Thanks for your answer.
> I finally found what I needed and it was very simple -_-'
> I just needed to do :
> ProjetFactory.eINSTANCE.getEPackage().getEClassifiers();
> and then work with the list.
> Is there a difference between getEPackage() and getProjetPackage() ?
> The results seem to be the same...
>
> Thanks in advance,
>
> Aline
>
Re: How to get all the derived classes [message #422716 is a reply to message #422713] Sun, 14 September 2008 19:45 Go to previous message
Aline is currently offline AlineFriend
Messages: 32
Registered: July 2009
Member
oki thanks very much !
Previous Topic:XSD Schema + Multiple Root Elements + EMF Editor leads to invalid XML file
Next Topic:Problems when referencing ChangeDescription
Goto Forum:
  


Current Time: Tue Jan 28 07:12:52 GMT 2020

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

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

Back to the top