Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [XPAND] how to derive the interface implement in xpand
[XPAND] how to derive the interface implement in xpand [message #505434] Wed, 30 December 2009 15:47 Go to next message
Wafi Dahman is currently offline Wafi DahmanFriend
Messages: 15
Registered: November 2009
Junior Member
hello,

I want to write all the possible scenarios of java class definition, one of them is the implementing of interface.. I tried multiple options but it seems that it did not work correctly..
can you give some hints.

the definition I want to write e.g.

foreach implmented interface / list of interfaces

public class ClassName extends MyClass implements MyInterface/ListOfInterfaces {}

the question is about the underlined text..

Thanx in-advance!
Re: [XPAND] how to derive the interface implement in xpand [message #505439 is a reply to message #505434] Wed, 30 December 2009 16:08 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14720
Registered: July 2009
Senior Member
Hello,

can you tell more about the context you are asking the question within. which metamodel are you using? which templates do you use at to moment?


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com
Re: [XPAND] how to derive the interface implement in xpand [message #505444 is a reply to message #505439] Wed, 30 December 2009 17:11 Go to previous messageGo to next message
Wafi Dahman is currently offline Wafi DahmanFriend
Messages: 15
Registered: November 2009
Junior Member
hello,

I am using UML for modeling. I managed to get all elements for class definition like
«visibility» class «name-» «IF !superClass.isEmpty» extends «superClass.first().name» «ENDIF» {}


If the class implements one or more interfaces how can I extract it/them from the model automatically?


Re: [XPAND] how to derive the interface implement in xpand [message #505445 is a reply to message #505444] Wed, 30 December 2009 17:27 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14720
Registered: July 2009
Senior Member
Hello this.interfaceRealization.contract delivers a list of implemented interfaces of an uml::Class. see Chapter 7.3.25 of OMG Unified Modeling LanguageTM (OMG UML),
Superstructure
for more information. You can find the document (here)


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com
Re: [XPAND] how to derive the interface implement in xpand [message #505450 is a reply to message #505445] Wed, 30 December 2009 20:34 Go to previous messageGo to next message
Wafi Dahman is currently offline Wafi DahmanFriend
Messages: 15
Registered: November 2009
Junior Member
it works but it displays the brackets [, ]
do you know how to ignore them?

it returns the same output as getAllImplementedInterfaces()...!

thanx for your patience and help.

[Updated on: Wed, 30 December 2009 15:46]

Report message to a moderator

Re: [XPAND] how to derive the interface implement in xpand [message #505452 is a reply to message #505450] Wed, 30 December 2009 20:53 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14720
Registered: July 2009
Senior Member
hi that is the behaviour of all lists in xpand if you just output them as they are. you have to use foreach or something like this to generate code e.g. something like this one:

«IF this.interfaceRealization.contract.size > 0»implements «FOREACH this.interfaceRealization.contract AS i SEPARATOR ","»«i.name»«ENDFOREACH»«ENDIF»


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com

[Updated on: Wed, 30 December 2009 20:54]

Report message to a moderator

Re: [XPAND] how to derive the interface implement in xpand [message #505478 is a reply to message #505450] Thu, 31 December 2009 07:04 Go to previous messageGo to next message
ekkehard gentz is currently offline ekkehard gentzFriend
Messages: 118
Registered: July 2009
Location: rosenheim, Germany, bavar...
Senior Member

This is a multi-part message in MIME format.
--------------070806050704030203060406
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

Am 30.12.09 21:34, schrieb Wafi Dahman:
> it works but it displays the brackets [, ]
> do you know how to ignore them?
>
>
> thanx for your patience and help.
if you only want to remove the brackets, its easy using Xtend:

String withoutBrackets (String s) :
s.replaceAll("[\\[\\]]","");

but as Christian told you the correct way is using a FOREACH construct

I'm using the withoutBrackets() extension per ex. while logging the
content of a list
--

ekke (ekkehard gentz)
independent software-architect
senior erp-consultant
eclipse | osgi | equinox | mdsd | oaw | emf | uml
max-josefs-platz 30, D-83022 rosenheim, germany
mailto:ekke@ekkes-corner.org
homepage (de): http://gentz-software.de
blog (en): http://ekkes-corner.org
twitter: @ekkescorner
skype: ekkes-corner
Steuer-Nr: 156/220/30931 FA Rosenheim, UST-ID: DE189929490


--------------070806050704030203060406
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 8bit

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Am 30.12.09 21:34, schrieb Wafi Dahman:
<blockquote cite="mid:hhgdgj$et2$1@build.eclipse.org" type="cite">it
works but it displays the brackets [,  ]
<br>
do you know how to ignore them?
<br>
<br>
<br>
thanx for your patience and help.
<br>
</blockquote>
if you only want to remove the brackets, its easy using Xtend:<br>
<br>
String withoutBrackets (String s) :<br>
    s.replaceAll("[\\[\\]]","");<br>
<br>
but as Christian told you the correct way is using a FOREACH construct<br>
<br>
I'm using the withoutBrackets() extension per ex. while logging the
content of a list<br>
<div class="moz-signature">-- <br>
<p style="margin-bottom: 0cm;"> <font ,="" color="#808080"
face="Verdana, sans-serif"> <font size="4">ekke (ekkehard gentz)<br>
</font> <font size="3"> independent software-architect<br>
senior erp-consultant<br>
</font> <font size="2">eclipse | osgi | equinox | mdsd | oaw | emf |
uml<br>
max-josefs-platz 30, D-83022 rosenheim, germany<br>
<a class="moz-txt-link-freetext" href="mailto:ekke@ekkes-corner.org">mailto:ekke@ekkes-corner.org</a><br>
homepage (de): <a class="moz-txt-link-freetext" href="http://gentz-software.de">http://gentz-software.de</a><br>
blog (en): <a class="moz-txt-link-freetext" href="http://ekkes-corner.org">http://ekkes-corner.org</a><br>
twitter: @ekkescorner<br>
skype: ekkes-corner<br>
</font> <font size="1"> Steuer-Nr: 156/220/30931 FA Rosenheim, UST-ID:
DE189929490<br>
</font> </font> </p>
</div>
</body>
</html>

--------------070806050704030203060406--


ekke
independent software architect

blog: http://ekkes-corner.org
twitter: @ekkescorner
Re: [XPAND] how to derive the interface implement in xpand [message #505490 is a reply to message #505434] Thu, 31 December 2009 10:47 Go to previous messageGo to next message
Wafi Dahman is currently offline Wafi DahmanFriend
Messages: 15
Registered: November 2009
Junior Member
Thank you all...
the one from christian worked more than good...

Re: [XPAND] how to derive the interface implement in xpand [message #505664 is a reply to message #505452] Mon, 04 January 2010 10:14 Go to previous message
Sven Efftinge is currently offline Sven EfftingeFriend
Messages: 1823
Registered: July 2009
Senior Member
Christian Dietrich schrieb:
> hi that is the behaviour of all lists in xpand if you just output them
> as they are. you have to use foreach or something like this to generate
> code e.g. something like this one:
>
> «IF this.interfaceRealization.contract.size > 0»«FOREACH
> this.interfaceRealization.contract AS i SEPARATOR
> ","»«i.name»«ENDFOREACH»«ENDIF»
>

Or a bit more concise:
«interfaceRealization.contract.name.toString(',')»

Regards,
Sven

--
Need professional support for Xtext and EMF?
Go to: http://xtext.itemis.com
Twitter : @svenefftinge
Blog : blog.efftinge.de
Previous Topic:Re: Xtext Maven Plugin
Next Topic:[Acceleo] Cannot find referenced template while can navigate to whith "F3" key
Goto Forum:
  


Current Time: Thu Oct 03 20:28:01 GMT 2024

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

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

Back to the top