Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [Xpand] Issues retrieving enumeration literal from UML stereotype property
[Xpand] Issues retrieving enumeration literal from UML stereotype property [message #647539] Thu, 06 January 2011 22:44 Go to next message
Eclipse User is currently offline Eclipse UserFriend
Messages: 14
Registered: January 2011
Junior Member
I am using Xpand templates to generate code from a UML model that uses custom profile stereotypes. When I tried to use the following line in my Xpand template to get the value of a stereotype property (implemented as an enum)...

«this.getValue(this.getAppliedStereotype(MyProfile::MyMeter .toString()), "level")»

I get the following output in the target file:

org.eclipse.uml2.uml.internal.impl.EnumerationLiteralImpl@4dd84dd8 (name: LOW, visibility: <unset>)

What additional steps do I need to make to just get the enumeration literal value "LOW" to be the output? I've been trying different variations without much success.

Thanks!
Re: [Xpand] Issues retrieving enumeration literal from UML stereotype property [message #647541 is a reply to message #647539] Thu, 06 January 2011 22:59 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi, just asking it for its name (.name) does not work? you may have to cast it first to its actual type. (uml::EnumerationLiteral)

«((uml::EnumerationLiteral)this.getValue(this.getAppliedStereotype(test::Bean .toString()), "lala")).name»


Having a look at the the Java Classes might help to solve such problems
org.eclipse.uml2.uml.EnumerationLiteral has a getName() inherited from org.eclipse.uml2.uml.NamedElement

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Thu, 06 January 2011 23:08]

Report message to a moderator

Re: [Xpand] Issues retrieving enumeration literal from UML stereotype property [message #647597 is a reply to message #647541] Fri, 07 January 2011 09:24 Go to previous messageGo to next message
Karsten Thoms is currently offline Karsten ThomsFriend
Messages: 762
Registered: July 2009
Location: Dortmund, Germany
Senior Member

Accessing the name property of an enumeration literal won't work directly, since the internal type of an enumeration literal is its enumeration and thus you get the name of the enumeration, not the literal. You have to write a Java extension to access a literal's name.

~Karsten


Need professional support for Xtext, EMF, Eclipse IDE?
Go to: http://devhub.karakun.com
Twitter : @kthoms
Blog : www.karsten-thoms.de
Re: [Xpand] Issues retrieving enumeration literal from UML stereotype property [message #647602 is a reply to message #647597] Fri, 07 January 2011 09:42 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
@Karsten i tried my code and it works with uml enumerations.

«DEFINE main FOR test::Bean»
«FILE getFQPN().replaceAll("\\.","/")+"/"+name+".java"»
//«((uml::EnumerationLiteral)this.getValue(this.getAppliedStereotype(test::Bean .toString()), "lala")).name»«REM»will work«ENDREM»
//«this.lala.name»«REM»will work too«ENDREM»
package «getFQPN()»;
public class «name» {

}
«ENDFILE»
«ENDDEFINE»


~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Fri, 07 January 2011 10:20]

Report message to a moderator

Re: [Xpand] Issues retrieving enumeration literal from UML stereotype property [message #647656 is a reply to message #647602] Fri, 07 January 2011 15:39 Go to previous message
Eclipse User is currently offline Eclipse UserFriend
Messages: 14
Registered: January 2011
Junior Member
Thanks very much Christian! I tried out both suggestions and they worked as advertised. Smile
Previous Topic:[MWE2,XPAND] Loading workflow in OSGi w/o workspace
Next Topic:[Xpand] How to get xmi id from an xpand template
Goto Forum:
  


Current Time: Thu Apr 25 03:58:49 GMT 2024

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

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

Back to the top