Skip to main content



      Home
Home » Modeling » M2T (model-to-text transformation) » Java Extension(does not return anything)
Java Extension [message #526568] Mon, 12 April 2010 06:14 Go to next message
Eclipse UserFriend
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 ?

[Updated on: Mon, 12 April 2010 06:14] by Moderator

Re: Java Extension [message #526571 is a reply to message #526568] Mon, 12 April 2010 06:29 Go to previous messageGo to next message
Eclipse UserFriend
hi,

Quote:

package ;



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

package <<nothing>>; => package ;

what is your expected result?
Re: Java Extension [message #526577 is a reply to message #526568] Mon, 12 April 2010 06:40 Go to previous messageGo to next message
Eclipse UserFriend
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;
}
}
Re: Java Extension [message #526586 is a reply to message #526568] Mon, 12 April 2010 07:23 Go to previous messageGo to next message
Eclipse UserFriend
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 07:25 Go to previous message
Eclipse UserFriend
expected resultat was
package mypackageName;

Your solution is indeed working, thank you.
Previous Topic:[XPand][AOP][Sculptor] problem calling the metamodel
Next Topic:Defining package from workflow
Goto Forum:
  


Current Time: Sun Jul 06 15:01:18 EDT 2025

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

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

Back to the top