Overview

 
Package  Use  Tree  Deprecated  Index  Help 
 PREV CLASS   NEXT CLASS FRAMES    NO FRAMES  
SUMMARY: NESTED | FIELD | CONSTR | METHOD DETAIL: FIELD | CONSTR | METHOD


 

org.eclipse.emf.codegen.jet
Class JETEmitter

java.lang.Object
  extended byorg.eclipse.emf.codegen.jet.JETEmitter


public class JETEmitter
extends Object

A convenience class for compiling and invoking a template dynamically.


Nested Class Summary
protected  class JETEmitter.MyJETCompiler
           
 
Field Summary
protected  ClassLoader classLoader
           
protected  List classpathEntries
           
protected  String encoding
           
protected  Method method
           
protected  Object object
           
protected  String projectName
           
protected  String templateURI
           
protected  String[] templateURIPath
           
 
Constructor Summary
JETEmitter(String templateURI)
          Creates an instance with the specified template URI.
JETEmitter(String[] templateURIPath, String relativeTemplateURI)
          Creates an instance with the specified template URI path and relative template URI.
JETEmitter(String[] templateURIPath, String relativeTemplateURI, ClassLoader classLoader)
          Creates an instance with the specified template URI path, relative template URI, and class loader.
JETEmitter(String[] templateURIPath, String relativeTemplateURI, ClassLoader classLoader, String encoding)
          Creates an instance with the specified template URI path, relative template URI, class loader, and encoding.
JETEmitter(String templateURI, ClassLoader classLoader)
          Creates an instance with the specified template URI and class loader.
 
Method Summary
 void addVariable(String variableName, String pluginID)
          Registers the specified classpath variable in the workspace and adds a classpath entry to the classpath entry list.
 String generate(IProgressMonitor progressMonitor, Object[] arguments)
          Invokes the emitter method on the compiled template and returns the result.
 List getClasspathEntries()
          Returns a list of classpath entries that will be added to the classpath of the internal project where emitted JET templates are compiled.
 Method getMethod()
          Returns the method that will be invoked when generate called.
 Object getObject()
          Returns the object used as input to the template.
 String getProjectName()
          Returns the name of the project where JET templates will be compiled.
 void initialize(IProgressMonitor progressMonitor)
          Compiles the template to set the method will be invoked to generate template results.
 void setMethod(Method method)
          Set the method that will be invoked when generate called.
 void setObject(Object object)
          Sets the object used as input to the template.
 void setProjectName(String projectName)
          Sets the name of the project where JET templates will be compiled.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

 

Field Detail

 

 

projectName

protected String projectName


 

 

method

protected Method method


 

 

object

protected Object object


 

 

templateURIPath

protected String[] templateURIPath


 

 

templateURI

protected String templateURI


 

 

classLoader

protected ClassLoader classLoader


 

 

encoding

protected String encoding


 

 

classpathEntries

protected List classpathEntries

Constructor Detail

 

 

JETEmitter

public JETEmitter(String templateURI)

Creates an instance with the specified template URI.

Parameters:
templateURI - the URI of a JET template.


 

 

JETEmitter

public JETEmitter(String[] templateURIPath,
                  String relativeTemplateURI)

Creates an instance with the specified template URI path and relative template URI. The relative URI will be resolved against each path URI until a JET template is found.

Parameters:
templateURIPath - a sequence of URIs that will be searched.
relativeTemplateURI - the relative URI of a JET template.


 

 

JETEmitter

public JETEmitter(String templateURI,
                  ClassLoader classLoader)

Creates an instance with the specified template URI and class loader.

Parameters:
templateURI - the URI of a JET template.
classLoader - the class loader used to load classes when compiling the template.


 

 

JETEmitter

public JETEmitter(String[] templateURIPath,
                  String relativeTemplateURI,
                  ClassLoader classLoader)

Creates an instance with the specified template URI path, relative template URI, and class loader. The relative URI will be resolved against each path URI until a JET template is found.

Parameters:
templateURIPath - a sequence of URIs that will be searched.
relativeTemplateURI - the relative URI of a JET template.
classLoader - the class loader used to load classes when compiling the template.


 

 

JETEmitter

public JETEmitter(String[] templateURIPath,
                  String relativeTemplateURI,
                  ClassLoader classLoader,
                  String encoding)

Creates an instance with the specified template URI path, relative template URI, class loader, and encoding. The relative URI will be resolved against each path URI until a JET template is found.

Parameters:
templateURIPath - a sequence of URIs that will be searched.
relativeTemplateURI - the relative URI of a JET template.
classLoader - the class loader used to load classes when compiling the template.
encoding - the encoding that will be used to read the templates.
Method Detail

 

 

getProjectName

public String getProjectName()

Returns the name of the project where JET templates will be compiled.

Returns:
the name of the project where JET templates will be compiled.


 

 

setProjectName

public void setProjectName(String projectName)

Sets the name of the project where JET templates will be compiled.

Parameters:
projectName - the name of the project.


 

 

getClasspathEntries

public List getClasspathEntries()

Returns a list of classpath entries that will be added to the classpath of the internal project where emitted JET templates are compiled.

This method must be called before initialize or generate are called.

Returns:
a list of classpath entries.


 

 

getObject

public Object getObject()

Returns the object used as input to the template.

Returns:
the object used as input to the template.


 

 

setObject

public void setObject(Object object)

Sets the object used as input to the template.

Parameters:
object - the object used as input to the template.


 

 

getMethod

public Method getMethod()

Returns the method that will be invoked when generate called.

Returns:
the generator method.


 

 

setMethod

public void setMethod(Method method)

Set the method that will be invoked when generate called.

Parameters:
method - the generator method.


 

 

initialize

public void initialize(IProgressMonitor progressMonitor)
                throws JETException

Compiles the template to set the method will be invoked to generate template results.

Parameters:
progressMonitor - the progress monitor for tracking progress.
Throws:
JETException


 

 

addVariable

public void addVariable(String variableName,
                        String pluginID)
                 throws JETException

Registers the specified classpath variable in the workspace and adds a classpath entry to the classpath entry list. The variable is bound to the first runtime library JAR file in the list of runtime libraries of the specified plugin. When generate is called and it needs to generate the method to invoke, it will call initialize which will add the classpath entries to the project created to hold and compile the emitted template.

This method must be called before initialize or generate are called.

The specified plugin ID must be the ID of an existing plugin. The referenced plugin must have at least one runtime library JAR file in its plugin descriptor. If the plugin descriptor's list of runtime libraries contains more than one JAR file, the classpath variable will be bound to the first library in the list.

Parameters:
variableName - name of the classpath variable
pluginID - the ID of an existing plugin
Throws:
JETException


 

 

generate

public String generate(IProgressMonitor progressMonitor,
                       Object[] arguments)
                throws JETException

Invokes the emitter method on the compiled template and returns the result.

Returns:
the template result.
Throws:
JETException


 

Overview

 
Package  Use  Tree  Deprecated  Index  Help 
Copyright 2001-2004 IBM Corporation and others.
All Rights Reserved.
 PREV CLASS   NEXT CLASS FRAMES    NO FRAMES  
SUMMARY: NESTED | FIELD | CONSTR | METHOD DETAIL: FIELD | CONSTR | METHOD