Generating jet1 implementation classes with jet2 [message #59985] |
Mon, 27 April 2009 10:21  |
Eclipse User |
|
|
|
Originally posted by: neko.ticino.com
Hi,
I'm using jet1 to generate java files, now I'm trying jet2 but it does
not generate the implementation classes like in jet1.
This implementation class is taken from an example from the tutorial:
public class TranslationDemoTemplate
{
protected final String NL = System.getProperties().getProperty("line.separator");
protected final String TEXT_1 = "Hello, ";
protected final String TEXT_2 = "!";
public String generate(Object argument)
{
StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append(TEXT_1);
stringBuffer.append(argument);
stringBuffer.append(TEXT_2);
stringBuffer.append("Hello again!");
return stringBuffer.toString();
}
}
In jet1 there were skeleton files to modify the java output, now if I
want to have this kind of output in jet2 (a java file with the generate
method), do I have to write a template my own or there is another way
to have this result?
Thank you!
Alex
|
|
|
Re: Generating jet1 implementation classes with jet2 [message #60251 is a reply to message #59985] |
Thu, 30 April 2009 11:21  |
Eclipse User |
|
|
|
Alex Nekoti wrote:
> I'm using jet1 to generate java files, now I'm trying jet2 but it does
> not generate the implementation classes like in jet1.
snip
> In jet1 there were skeleton files to modify the java output, now if I
> want to have this kind of output in jet2 (a java file with the generate
> method), do I have to write a template my own or there is another way
> to have this result?
JET2 doesn't have the equivalent of a skeleton file. But there are
alternatives:
1) JET2 templates support embedded members to the generated class via the
<%! ... %> markup:
<%!
// declare a class field
private int foo;
// declare a method
private int getFoo() {
return foo;
}
%>
2) You can get have file and class comments inserted into the generated
java file by using special keywords in JET comments:
<%-- @class
This a Javadoc comment for the class
--%>
<%-- @header
This a comment that will appear as the header comment on the .java file. It
is a suitable place to put Java doc
--%>
Paul
|
|
|
Powered by
FUDForum. Page generated in 0.02249 seconds