Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » how to read EAnnotations separately in for loop?
how to read EAnnotations separately in for loop? [message #1826574] Mon, 27 April 2020 11:03 Go to next message
Fatima Rani is currently offline Fatima RaniFriend
Messages: 22
Registered: April 2020
Junior Member
Hi!

I want to separate the "key" attribute and its "value" in for loop but its printing all keys & values together.can any1 help?

Code:

[for (c: EClass | anEPackage.eAllContents())]
Class Name = [c.name/]
[for (ea: EAnnotation | c.eAllContents())]Annotation Type = [ea.source/]
Key Type = "[ea.details.key/]"
Value Type = "[ea.details.value/]"
[/for]
[/for]

output:
Class Name = Node
Annotation Type = gmf.node
Key Type = "labelborder.colorborder.styleborder.widthfigure"
Value Type = "name0,0,255solid3ellipse"

Reagrds,
fatima
Re: how to read EAnnotations separately in for loop? [message #1826582 is a reply to message #1826574] Mon, 27 April 2020 13:39 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7670
Registered: July 2009
Senior Member
Hi

If you read the metamodel you will see that details is a collection and so details.key is a shortform for details->collect(key).

Regards

Ed Willink
Re: how to read EAnnotations separately in for loop? [message #1826586 is a reply to message #1826582] Mon, 27 April 2020 14:16 Go to previous messageGo to next message
Fatima Rani is currently offline Fatima RaniFriend
Messages: 22
Registered: April 2020
Junior Member
i want to store them one by one in separate variables or arraylist(in pair of key & value). But i dont know how to do this in Acceleo?

Regards,
fatima
Re: how to read EAnnotations separately in for loop? [message #1826611 is a reply to message #1826586] Mon, 27 April 2020 18:08 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7670
Registered: July 2009
Senior Member
Hi

You are still very vague, but if you look at the print out that you orially complained about, it was the print out of all the keys in a single collection , and then all the values in another collection. The only purpose of the for loop is to turn the one-dimensional execution of the implicit collect into a two dimensional iteration that does everything N times more often than you want. Scrap the for loop.

Regards

Ed Willink
Re: how to read EAnnotations separately in for loop? [message #1826727 is a reply to message #1826611] Wed, 29 April 2020 14:43 Go to previous messageGo to next message
Fatima Rani is currently offline Fatima RaniFriend
Messages: 22
Registered: April 2020
Junior Member
hi! from the following code if i want to access any specific key and its corresponding value then how to get it :( :(
(e.g; if key = "width" get the value= "2").

<eAnnotations source="gmf.link">
<details key="label" value="name"/>
<details key="source" value="source"/>
<details key="target" value="target"/>
<details key="style" value="dash"/>
<details key="width" value="2"/>
<details key="color" value="255,255,0"/>
<details key="source.decoration" value="filledsquare"/>
</eAnnotations>

Regards,
fatima
Re: how to read EAnnotations separately in for loop? [message #1826732 is a reply to message #1826727] Wed, 29 April 2020 15:16 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7670
Registered: July 2009
Senior Member
HI

The time has clearly come for you to read the OCL book.

https://www.amazon.co.uk/Object-Constraint-Language-Addison-Wesley-Technology/dp/0321179366

Regards

Ed Willink
Re: how to read EAnnotations separately in for loop? [message #1826885 is a reply to message #1826732] Mon, 04 May 2020 02:41 Go to previous messageGo to next message
Fatima Rani is currently offline Fatima RaniFriend
Messages: 22
Registered: April 2020
Junior Member
Hi!
Thanks Willink ! i have ordered the book let see when it will reach!
The problem i was facing , i got the idea to solve it :),hence it solved.
Just few small questions :
1* how can i use OR operator in Acceleo e.g, in it [if ea.details.value->at(2) = 'rounded ' || 'rectangle']
2* is there any function in Acceleo which can convert decimal to hex ?
3* can i define use functions and then use them in Acceleo?

Many Thanks!
Regards,
fatima
Re: how to read EAnnotations separately in for loop? [message #1826895 is a reply to message #1826885] Mon, 04 May 2020 06:54 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7670
Registered: July 2009
Senior Member
Hi

Sorry. A forum is for help on a problem. It is not a documentation query service.

Regards

Ed Willink
Re: how to read EAnnotations separately in for loop? [message #1826897 is a reply to message #1826895] Mon, 04 May 2020 08:41 Go to previous message
Fatima Rani is currently offline Fatima RaniFriend
Messages: 22
Registered: April 2020
Junior Member
ok!
Previous Topic:How to read the graphical notations?
Next Topic:How can I get a class which is inherited from another class in acceleo
Goto Forum:
  


Current Time: Tue Sep 24 20:48:24 GMT 2024

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

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

Back to the top