Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » Java Extension(does not return anything)
Java Extension [message #526568] Mon, 12 April 2010 10:14 Go to next message
MaximeLecourt  is currently offline MaximeLecourt Friend
Messages: 108
Registered: February 2010
Location: France
Senior Member
I want to call a JAVA method from my Xtend file.

In my Xpand file, it's called like this :
Quote:
package «package(this.name)»;


In Xtend, I defined this extension :
Quote:
Void package (String s) :
JAVA specific.Package.Name(java.lang.String);


And my JAVA file is that :
Quote:
package specific;

public class Package {
public final static void Name(String name){
System.out.println("mypackage"+name);
}
}


But when I run the workflow, I get
Quote:
package ;


What do I need to modify ?


One day I shall master M2T, but that day has yet to come...

[Updated on: Mon, 12 April 2010 10:14]

Report message to a moderator

Re: Java Extension [message #526571 is a reply to message #526568] Mon, 12 April 2010 10:29 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
hi,

Quote:

package ;



is actually that what you tell the gerneator to produce in your template

package <<nothing>>; => package ;

what is your expected result?


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Java Extension [message #526577 is a reply to message #526568] Mon, 12 April 2010 10:40 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi again,

if you want to let the java extension calculate your package name your should modify your code like this

String package (String s) :
JAVA specific.Package.Name(java.lang.String);


package specific;

public class Package {
public final static String Name(String name){ 
 return "mypackage"+name;
}
}


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Java Extension [message #526586 is a reply to message #526568] Mon, 12 April 2010 11:23 Go to previous messageGo to next message
Darius Jockel is currently offline Darius JockelFriend
Messages: 63
Registered: July 2009
Member
Hello Maxime,

thank you very much for your question. This feature is not good described in the Xpand documentation. I will update this part of the documentation.
Please try:
public class Package {
public final static String Name(String name){
return ("mypackage"+name);
}
}


You have forgot to specify the return.
The System.out.println inside the documentation is for logging to the console but does no generator output.

Regards
Darius
Re: Java Extension [message #526588 is a reply to message #526568] Mon, 12 April 2010 11:25 Go to previous message
MaximeLecourt  is currently offline MaximeLecourt Friend
Messages: 108
Registered: February 2010
Location: France
Senior Member
expected resultat was
package mypackageName;

Your solution is indeed working, thank you.


One day I shall master M2T, but that day has yet to come...
Previous Topic:[XPand][AOP][Sculptor] problem calling the metamodel
Next Topic:Defining package from workflow
Goto Forum:
  


Current Time: Sat Apr 20 00:05:40 GMT 2024

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

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

Back to the top