Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Package: get EClass by name?
Package: get EClass by name? [message #503115] Thu, 10 December 2009 22:41 Go to next message
No real name is currently offline No real nameFriend
Messages: 62
Registered: July 2009
Member
Hi,

is there a way to get an EClass returned from the Package by giving it
the name of the class as a String?

Example: I have the String "InputEvent" and want to get the EClass
InputEvent from my package. I've seen that there are methods like
'Package.eINSTANCE.getInputEvent()' which returns the EClass InputEvent.
So I could use that method and a Mapping<String, EClass> to map every
String to its corresponding class, but a method like 'getEClass(String
eClassName)' would be more comfortable.

Is there anytinhg like that?

Thanks,
Matthias
Re: Package: get EClass by name? [message #503145 is a reply to message #503115] Fri, 11 December 2009 06:47 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 5574
Registered: July 2009
Senior Member
Hi Matthias,

An EClass is an EClassifier, hence you can call:

eClass = (EClass) ePackage.getEClassifier("MyClass");

Cheers
/Eike

----
http://thegordian.blogspot.com
http://twitter.com/eikestepper



Matthias Schmeling schrieb:
> Hi,
>
> is there a way to get an EClass returned from the Package by giving it
> the name of the class as a String?
>
> Example: I have the String "InputEvent" and want to get the EClass
> InputEvent from my package. I've seen that there are methods like
> 'Package.eINSTANCE.getInputEvent()' which returns the EClass
> InputEvent. So I could use that method and a Mapping<String, EClass>
> to map every String to its corresponding class, but a method like
> 'getEClass(String eClassName)' would be more comfortable.
>
> Is there anytinhg like that?
>
> Thanks,
> Matthias
Re: Package: get EClass by name? [message #1027405 is a reply to message #503145] Tue, 26 March 2013 23:42 Go to previous messageGo to next message
Roza Ghamari is currently offline Roza GhamariFriend
Messages: 70
Registered: January 2013
Member
I have a followup question. How can I get the related ePackage from a class name?

Thanks,
Roza
Re: Package: get EClass by name? [message #1027764 is a reply to message #1027405] Wed, 27 March 2013 11:39 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 26235
Registered: July 2009
Senior Member
Roza,

Different packages can have classifiers for the same class name, so
there isn't a general one-to-one mapping from class name to classifier.


On 26/03/2013 7:42 PM, Roza Ghamari wrote:
> I have a followup question. How can I get the related ePackage from a
> class name?
>
> Thanks,
> Roza
>
Previous Topic:Exporting multiple XSD schemas to ecore programmatically
Next Topic:Question on teneo.mapping.join_table_for_non_contained_associations [Teneo]
Goto Forum:
  


Current Time: Fri Nov 28 04:47:19 GMT 2014

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

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