public class JETEmitter
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
protected static class |
JETEmitter.MyBaseJETCompiler |
protected class |
JETEmitter.MyJETCompiler |
Modifier and Type | Field and Description |
---|---|
protected java.lang.ClassLoader |
classLoader |
protected java.util.List<IClasspathEntry> |
classpathEntries |
protected java.lang.String |
encoding |
protected java.util.Map<java.lang.String,java.lang.String> |
javaOptions |
protected java.lang.reflect.Method |
method |
protected java.lang.Object |
object |
protected java.lang.String |
projectName |
protected java.lang.String |
templateURI |
protected java.lang.String[] |
templateURIPath |
Constructor and Description |
---|
JETEmitter(java.lang.String templateURI)
Creates an instance with the specified template URI.
|
JETEmitter(java.lang.String[] templateURIPath,
java.lang.String relativeTemplateURI)
Creates an instance with the specified template URI path and relative template URI.
|
JETEmitter(java.lang.String[] templateURIPath,
java.lang.String relativeTemplateURI,
java.lang.ClassLoader classLoader)
Creates an instance with the specified template URI path, relative template URI, and class loader.
|
JETEmitter(java.lang.String[] templateURIPath,
java.lang.String relativeTemplateURI,
java.lang.ClassLoader classLoader,
java.lang.String encoding)
Creates an instance with the specified template URI path, relative template URI, class loader, and encoding.
|
JETEmitter(java.lang.String templateURI,
java.lang.ClassLoader classLoader)
Creates an instance with the specified template URI and class loader.
|
Modifier and Type | Method and Description |
---|---|
void |
addVariable(java.lang.String variableName,
java.lang.String pluginID)
Registers the specified classpath variable in the workspace
and adds a classpath entry to the
classpath entry list . |
java.lang.String |
generate(IProgressMonitor progressMonitor,
java.lang.Object[] arguments)
Invokes the emitter method on the compiled template and returns the result.
|
java.lang.String |
generate(Monitor progressMonitor,
java.lang.Object[] arguments,
java.lang.String lineDelimiter)
Invokes the emitter method on the compiled template and returns the result.
|
java.util.List<IClasspathEntry> |
getClasspathEntries()
Returns a list of classpath entries that will be added to the classpath of the internal
project
where emitted JET templates are compiled. |
java.util.Map<java.lang.String,java.lang.String> |
getJavaOptions()
Returns options that will be
applied to the Java project the first time it's created. |
java.lang.reflect.Method |
getMethod()
Returns the method that will be invoked when
generate called. |
java.lang.Object |
getObject()
Returns the object used as the target for the template.
|
java.lang.Object |
getObject(java.lang.String lineDelimiter)
Returns the object used as the target for the template;
it ensures that the returned object is using the given lineDelimiter
and creates a new one if necessary.
|
java.lang.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(java.lang.reflect.Method method)
Set the method that will be invoked when
generate called. |
void |
setObject(java.lang.Object object)
Sets the object used as the target of the template.
|
void |
setProjectName(java.lang.String projectName)
Sets the name of the project where JET templates will be compiled.
|
protected java.lang.String projectName
protected java.lang.reflect.Method method
protected java.lang.Object object
protected java.lang.String[] templateURIPath
protected java.lang.String templateURI
protected java.lang.ClassLoader classLoader
protected java.lang.String encoding
protected java.util.List<IClasspathEntry> classpathEntries
protected java.util.Map<java.lang.String,java.lang.String> javaOptions
public JETEmitter(java.lang.String templateURI)
templateURI
- the URI of a JET template.public JETEmitter(java.lang.String[] templateURIPath, java.lang.String relativeTemplateURI)
templateURIPath
- a sequence of URIs that will be searched.relativeTemplateURI
- the relative URI of a JET template.public JETEmitter(java.lang.String templateURI, java.lang.ClassLoader classLoader)
templateURI
- the URI of a JET template.classLoader
- the class loader used to load classes when compiling the template.public JETEmitter(java.lang.String[] templateURIPath, java.lang.String relativeTemplateURI, java.lang.ClassLoader classLoader)
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.public JETEmitter(java.lang.String[] templateURIPath, java.lang.String relativeTemplateURI, java.lang.ClassLoader classLoader, java.lang.String encoding)
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.public java.lang.String getProjectName()
public void setProjectName(java.lang.String projectName)
projectName
- the name of the project.public java.util.List<IClasspathEntry> getClasspathEntries()
project
where emitted JET templates are compiled.
This method must be called before
initialize
or generate
are called.
public java.util.Map<java.lang.String,java.lang.String> getJavaOptions()
applied
to the Java project the first time it's created.public java.lang.Object getObject()
public java.lang.Object getObject(java.lang.String lineDelimiter)
public void setObject(java.lang.Object object)
object
- the object used as target of the template.public java.lang.reflect.Method getMethod()
generate
called.public void setMethod(java.lang.reflect.Method method)
generate
called.method
- the generator method.public void initialize(IProgressMonitor progressMonitor) throws JETException
set
the method will be invoked to generate template results.progressMonitor
- the progress monitor for tracking progress.JETException
public void addVariable(java.lang.String variableName, java.lang.String pluginID) throws JETException
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.
variableName
- name of the classpath variablepluginID
- the ID of an existing pluginJETException
public java.lang.String generate(IProgressMonitor progressMonitor, java.lang.Object[] arguments) throws JETException
JETException
public java.lang.String generate(Monitor progressMonitor, java.lang.Object[] arguments, java.lang.String lineDelimiter) throws JETException
JETException