In this step, we will add a javadoc to the generated Java file, introducing template inclusion.
First create a Javadoc template:
Change the Javadoc.tgt
contents to:
[#package tutorial.java] [#template public Javadoc()] /* * Generated by ${System.getProperty("user.name")} * on ${java.util.Calendar.getInstance().getTime()} */ [/#template]
Note that this template does not define a file directive: it means this template is not a generation entry-point, it's a fragment designed to be included in another template. This template does not expect any parameter.
This template uses the getProperty()
method of the class java.lang.System
to retrieve the name of the current user.
It also uses the class java.util.Calendar
to compute the current time.
We can include this Javadoc in the template JavaSource.tgt:
[#package tutorial.java] [#template public JavaSource(class : uml21.Class)] [#file]generated/${class.name}.java[/#file] [#include Javadoc()] public [#if class.isAbstract]abstract [/#if]class ${class.name} { ...
Relaunch the generation and open the file Order.java:
/* * Generated by SODIUS * on Wed May 17 12:01:36 CEST 2006 */ public abstract class Order { ...