Generator g = new Generator(); g.generate( "template.jtm" );You can specify the template using a String file path or a File object.
Generator
uses the default internal configuration so that it will work without any configuration files. To use Jostraca configuration files, specify a configuration folder using the constructors {@link #Generator(File)}or {@link #Generator(String)}.
You can also specify the settings to use when generating by passing in a {@link PropertySet} object, with your required settings.For example:
Generator g = new Generator(); PropertySet ps = new PropertySet(); ps.set( "main.MakeBackup", "no" ); g.setCmdPropertySet( ps ); g.generate( "template.jtm" );For a complete list of all configuration settings see the {@link Configuration Settings} reference.
To generate more than one template, use the {@link #generate(String[])}and {@link #generate(File[])} methods.
You can use the same Generator
object multiple times.
If the template you are generating only generates one output file, you can retrieve the result of the generation by calling {@link Template#getResult} on the {@link Template} object that is returned by the generate
methods.Note that this only works when you are using Java as the template script, and when you execute the template CodeWriter internally (this is the default).
To gain access to any error messages use the {@link #getUserMessageHandler} method.This returns a {@link org.jostraca.util.RecordingUserMessageHandler} object by default,which you will need to cast from the {@link org.jostraca.util.UserMessageHandler} interface returned by getUserMessageHandler.To use your own UserMessageHandler, use the method {@link #generate(String,UserMessageHandler)} and its equivalents.To send output to STDOUT
, use the {@link org.jostraca.util.CommandLineUserMessageHandler} as the UserMessageHandler parameter.
|
|
|
|
|
|
|
|
|
|