Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » get SuperTypes of EClasses???
get SuperTypes of EClasses??? [message #394950] Thu, 11 August 2005 16:12 Go to next message
Karl is currently offline KarlFriend
Messages: 92
Registered: July 2009
Member
Hi,

I want to read the SuperTypes of an EClass in an EcoreXML-File.
The problem is not to read it. The problem is, that I get all SuperTypes
(SuperTypes of the SuperTypes of the SuperTypes) too.

For example when I want to read the Ecore.ecore:
When I say:
for (Iterator i = eclass.getESuperTypes().iterator(); i.hasNext();){
supertypeclass = (EClass) i.next();
System.out.println(supertypeclass.getName());
}
// in this case "eclass.getName()" is "EAttribute"

The result of the System.out.println is:
EAnnotation
EClass
EClassifier
EDataType
EEnum
EEnumLiteral
EFactory
EModelElement
ENamedElement
EObject
EOperation
EPackage
EParameter
EReference
EStructuralFeature
ETypedElement
EStringToStrongMapEntry.

OK I know that is right, but I only want to read the "direct SuperTypes"
which you can see in the Editor and which is the only mentioned
SuperType(s) in the Ecore.ecore (in the case of EAttribute it is
EStructuralFeature).

Does anyone know how to filter the rest of the SuperTypes?

Thanks in advance,
Karl
Re: get SuperTypes of EClasses??? [message #394951 is a reply to message #394950] Thu, 11 August 2005 16:53 Go to previous messageGo to next message
Marcelo Paternostro is currently offline Marcelo PaternostroFriend
Messages: 602
Registered: July 2009
Senior Member
Hi Karl,

I've created the following class in a Java project that has
org.eclipse.emf.ecore as one of its dependencies. It printed out
exactly what you are looking for (ie, "EStructurealFeature").

public class Test
{
public static void main(String[] args)
{
EClass eclass = EcorePackage.eINSTANCE.getEAttribute();
for (Iterator i = eclass.getESuperTypes().iterator(); i.hasNext();)
{
EClass supertypeclass = (EClass)i.next();
System.out.println(supertypeclass.getName());
}
}
}

Maybe you could post here a small test reproducing the problem you are
seeing.

Cheers,
Marcelo

Karl wrote:
> Hi,
>
> I want to read the SuperTypes of an EClass in an EcoreXML-File.
> The problem is not to read it. The problem is, that I get all SuperTypes
> (SuperTypes of the SuperTypes of the SuperTypes) too.
>
> For example when I want to read the Ecore.ecore:
> When I say:
> for (Iterator i = eclass.getESuperTypes().iterator(); i.hasNext();){
> supertypeclass = (EClass) i.next();
> System.out.println(supertypeclass.getName());
> }
> // in this case "eclass.getName()" is "EAttribute"
>
> The result of the System.out.println is:
> EAnnotation
> EClass
> EClassifier
> EDataType
> EEnum
> EEnumLiteral
> EFactory
> EModelElement
> ENamedElement
> EObject
> EOperation
> EPackage
> EParameter
> EReference
> EStructuralFeature
> ETypedElement
> EStringToStrongMapEntry.
>
> OK I know that is right, but I only want to read the "direct SuperTypes"
> which you can see in the Editor and which is the only mentioned
> SuperType(s) in the Ecore.ecore (in the case of EAttribute it is
> EStructuralFeature).
>
> Does anyone know how to filter the rest of the SuperTypes?
>
> Thanks in advance, Karl
>
Re: get SuperTypes of EClasses??? [message #394952 is a reply to message #394951] Thu, 11 August 2005 17:49 Go to previous messageGo to next message
Karl is currently offline KarlFriend
Messages: 92
Registered: July 2009
Member
Hi, maybe my description was unclear

I read the EClassifier EAttribute from the File "Ecore.ecore" from the
filesystem. It can be found in the plugin-directory of Eclipse in the
Folder:
org.eclipse.emf.source_2.0.3\src\org.eclipse.emf.ecore_2.0.3 \runtime\ecoresrc.zip

I loaded the EcoreFile stand alone(created a resource set, registered it
to a resource factory, etc) like in:
http://eclipse.org/emf/docs.php?doc=references/overview/EMF. html
section: "Saving and loading resources"

I hope it becomes more understandable?

Regards,
Karl
Re: get SuperTypes of EClasses??? [message #394953 is a reply to message #394952] Thu, 11 August 2005 18:44 Go to previous messageGo to next message
Marcelo Paternostro is currently offline Marcelo PaternostroFriend
Messages: 602
Registered: July 2009
Senior Member
Hi,

You were perfectly clear before ;-) My point is that since everything
is OK when I work with a direct reference of the EAttribute eclass, the
problem is somehow related to the way you are loading the resource.
Better than trying to guess what you are doing, it would be good if you
could provide a simple example.

Cheers,
Marcelo.

Karl wrote:
> Hi, maybe my description was unclear
> I read the EClassifier EAttribute from the File "Ecore.ecore" from the
> filesystem. It can be found in the plugin-directory of Eclipse in the
> Folder:
> org.eclipse.emf.source_2.0.3\src\org.eclipse.emf.ecore_2.0.3 \runtime\ecoresrc.zip
>
>
> I loaded the EcoreFile stand alone(created a resource set, registered it
> to a resource factory, etc) like in:
> http://eclipse.org/emf/docs.php?doc=references/overview/EMF. html
> section: "Saving and loading resources"
>
> I hope it becomes more understandable?
>
> Regards,
> Karl
>
>
Re: get SuperTypes of EClasses??? [message #394956 is a reply to message #394953] Thu, 11 August 2005 20:02 Go to previous messageGo to next message
Karl is currently offline KarlFriend
Messages: 92
Registered: July 2009
Member
Hi Marcelo,

...I'm so mortified.
The problem is solved. I wrote 2 loops. The first iterates the classifiers
and the second iterates the SuperTypes of this classifiers. In the second
loop I iterated the first one.

Thanks for your help!

Regards, Karl
Re: get SuperTypes of EClasses??? [message #394957 is a reply to message #394956] Thu, 11 August 2005 20:11 Go to previous message
Marcelo Paternostro is currently offline Marcelo PaternostroFriend
Messages: 602
Registered: July 2009
Senior Member
My pleasure ;-)

Karl wrote:
> Hi Marcelo,
>
> ...I'm so mortified.
> The problem is solved. I wrote 2 loops. The first iterates the
> classifiers and the second iterates the SuperTypes of this classifiers.
> In the second loop I iterated the first one.
>
> Thanks for your help!
>
> Regards, Karl
>
Previous Topic:Enum default selection
Next Topic:NPE EMFPlugin$EclipsePlugin.getString()
Goto Forum:
  


Current Time: Fri Sep 27 04:21:03 GMT 2024

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

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

Back to the top