ch.sahits.codegen.generator
Class JETGateway

java.lang.Object
  extended by ch.sahits.codegen.generator.AbstractGenerator
      extended by ch.sahits.codegen.generator.JETGateway
All Implemented Interfaces:
IBaseGenerator, IGenerator
Direct Known Subclasses:
AbstractJETTemplateGenerator

public class JETGateway
extends AbstractGenerator
implements IGenerator

This class encapsulates access to the JET and JMerge packages.

Since:
0.9.0
Author:
Remko Popma, Andi Hotz

Constructor Summary
JETGateway()
          Default constructor
 
Method Summary
 void cleanup()
          Delete the JETEmitter project.
 java.lang.String generate()
          Generate the code by passing the call to generate(IProgressMonitor)
 java.lang.String generate(IProgressMonitor _monitor)
          Invokes the JETemplate specified in the Config with the model specified in the Config and returns the generated text as a String.
 JETEmitter getJETEmitter()
          Retrieve a JETEmitter.
 int getWorkload()
          Define how expensive the generation process is.
 void init()
          Initialize the monitor
 void init(IJetGatewayConfiguration config)
          Initialize the configuration This initializing method is called by the generators once the Object is created dynamically
 boolean isInitialized()
          Check whether the generator is properly initialized
 void setMonitor(IProgressMonitor _monitor)
          Set the monitor for the progress
 
Methods inherited from class ch.sahits.codegen.generator.AbstractGenerator
createIfNull, findOrCreateContainer, getConfig, save, setConfig
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface ch.sahits.codegen.generator.IGenerator
getConfig, save
 

Constructor Detail

JETGateway

public JETGateway()
Default constructor

Method Detail

init

public void init(IJetGatewayConfiguration config)
Initialize the configuration This initializing method is called by the generators once the Object is created dynamically

Specified by:
init in interface IBaseGenerator
Parameters:
config -

generate

public java.lang.String generate(IProgressMonitor _monitor)
                          throws CoreException
Invokes the JETemplate specified in the Config with the model specified in the Config and returns the generated text as a String.

This implementation uses a JETEmitter to translate the template to a Java implementation class. The translated class is created in a hidden project called .JETEmitters.

In order to be able to compile the translated template implementation class, the classes used by the model specified in the Config must be availabel in the classpath. For this reason, this method sets the first runtime library of the plugin specified in the Config as a classpath variable to the .JETEmitters project.

Parameters:
_monitor - the progress monitor to use. May be null.
Returns:
the source code text generated by the JET template
Throws:
CoreException

generate

public java.lang.String generate()
Generate the code by passing the call to generate(IProgressMonitor)

Specified by:
generate in interface IBaseGenerator
Returns:
String representation of the generated class

init

public void init()
Initialize the monitor

Specified by:
init in interface IGenerator

setMonitor

public final void setMonitor(IProgressMonitor _monitor)
Set the monitor for the progress

Specified by:
setMonitor in interface IGenerator
Parameters:
_monitor - the monitor to set

cleanup

public void cleanup()
             throws CoreException
Delete the JETEmitter project. If this method is overridden make sure to call the super method or insure in some other way that the cleanup method is called every time a .JETEmitters project is created.

Specified by:
cleanup in interface IGenerator
Throws:
CoreException

getWorkload

public int getWorkload()
Define how expensive the generation process is.

Specified by:
getWorkload in interface IGenerator
Returns:
number of work-units

isInitialized

public boolean isInitialized()
Check whether the generator is properly initialized

Specified by:
isInitialized in interface IBaseGenerator
Returns:
true if initialization took place

getJETEmitter

public final JETEmitter getJETEmitter()
Retrieve a JETEmitter. In the case that a specific emitter is needed this method can easily be overriden. The overriding may cause errors when using with JETEmitterInitializer.

Returns:
default JETEmitter