|
|
|
|
Re: [XPAND] accessing <<FILE ...>> from Java [message #493910 is a reply to message #493905] |
Wed, 28 October 2009 13:30 |
|
Sorry for the typos in my previous posts. my phases might have been a bit misunderstandable:
here an example who to write code from a Java Extension into a file using the xpand / xtend / java - queue:
Java:
public class MyJavaExtensions {
public String myXtendFunction(Parameter param) {
String result = "";
// do some calculation
return result;
}
}
Xtend
String myXtendFuntion(Parameter param):
JAVA path.MyJavaExtensions.myXtendFunction(oath.Parameter);
Xpand
<< FILE "test.txt">>
<<myXtendFuntion(param)>>
<<ENDFILE>>
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com
|
|
|
Re: [XPAND] accessing <<FILE ...>> from Java [message #494100 is a reply to message #493903] |
Thu, 29 October 2009 08:47 |
|
If you just want to assign dynamic values to your Entity instances, use Xtend stdlib ElementProperties extensions. You will find a reference in the docs. In your Java code you could call ElementPropertiesExtensions.get/setProperty().
Coming back to your initial request: You could access the FILE statement from Java with some hacks: You'd need to implement a Callback that is registered to the Generator component. This gets informed on any statement evaluated. Then recognize opening FILE statements and store a handle to this instance in a ThreadLocal. This ThreadLocal must be made accessible from your Java method that needs the File statement. Since this is a real hack you see that's not a common use case.
Best wishes,
~Karsten
Need professional support for Xtext, EMF, Eclipse IDE?
Go to: http://devhub.karakun.com
Twitter : @kthoms
Blog : www.karsten-thoms.de
|
|
|
Powered by
FUDForum. Page generated in 0.25545 seconds