Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Setting EEnum using reflective API
Setting EEnum using reflective API [message #426709] Mon, 19 January 2009 14:09 Go to next message
Morten MacFly is currently offline Morten MacFlyFriend
Messages: 69
Registered: July 2009
Member
Dear all,

I am trying (hard) to set an EAttribute to an EEnumLiteral I am
obtaining from a string (user input in the end) using reflective API.
However - I don't get it to work.

Searching this NG revealed the following code (from 2003):
((EEnum) ea.getEType()).getEEnumLiteral(nodeValue).instance();
which does not work for me as .instance() is not present (anymore?!).

I am doing the following:
void setEEnum(EObject eo /* parent */, String valueAsString) {
EAttribute ea = ecorePackage.Literals.PORT_ID;
EEnum ee = ecorePackage.Literals.PORT_ID_ENUM;
EEnumLiteral eel = ee.getEEnumLiteral(valueAsString);
// ...
// And now?
}

With best regards, Morten.
Re: Setting EEnum using reflective API [message #426750 is a reply to message #426709] Tue, 20 January 2009 04:16 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33142
Registered: July 2009
Senior Member
Morten,

Comments below.

Morten MacFly wrote:
> Dear all,
>
> I am trying (hard) to set an EAttribute to an EEnumLiteral I am
> obtaining from a string (user input in the end) using reflective API.
> However - I don't get it to work.
>
> Searching this NG revealed the following code (from 2003):
> ((EEnum) ea.getEType()).getEEnumLiteral(nodeValue).instance();
> which does not work for me as .instance() is not present (anymore?!).
>
A typo maybe? EEnumLiteral.getInstance() should work...
> I am doing the following:
> void setEEnum(EObject eo /* parent */, String valueAsString) {
> EAttribute ea = ecorePackage.Literals.PORT_ID;
> EEnum ee = ecorePackage.Literals.PORT_ID_ENUM;
> EEnumLiteral eel = ee.getEEnumLiteral(valueAsString);
> // ...
> // And now?
> }
>
> With best regards, Morten.
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:refactoring imports in a XSD
Next Topic:Resource$IOWrappedException on saving item in EMF editor
Goto Forum:
  


Current Time: Fri Apr 26 07:48:23 GMT 2024

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

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

Back to the top