|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.eclipse.mtl.engine.service.MTLService
public final class MTLService
This class provides utility methods to launch the generation of an MTL template.
| Method Summary | |
|---|---|
static void |
addListener(MTLTextGenerationListener listener)
Registers a listener to be notified for any text generation that will take place in this engine evaluation process. |
static java.util.Map<java.lang.String,java.io.StringWriter> |
doGenerate(java.util.Map<Module,java.util.Set<java.lang.String>> templates,
org.eclipse.emf.ecore.EObject model,
java.io.File generationRoot,
boolean preview)
This can be used to launch the generation of multiple MTL templates given their names and their containing modules. |
static java.util.Map<java.lang.String,java.io.StringWriter> |
doGenerate(Module module,
java.lang.String templateName,
org.eclipse.emf.ecore.EObject model,
java.io.File generationRoot,
boolean preview)
Launches the generation of an MTL template given its name and containing module. |
static java.util.Map<java.lang.String,java.io.StringWriter> |
doGenerate(Module module,
java.lang.String templateName,
org.eclipse.emf.ecore.EObject model,
java.util.List<? extends java.lang.Object> arguments,
java.io.File generationRoot,
boolean preview)
Launches the generation of an MTL template given its name and containing module. |
static java.util.Map<java.lang.String,java.io.StringWriter> |
doGenerate(Template template,
org.eclipse.emf.ecore.EObject model,
java.io.File generationRoot,
boolean preview)
Launches the generation of a single-argument MTL template for all matching EObjects in the given model. |
static java.util.Map<java.lang.String,java.io.StringWriter> |
doGenerateTemplate(Module module,
java.lang.String templateName,
java.util.List<? extends java.lang.Object> arguments,
java.io.File generationRoot,
boolean preview)
Launches the generation of an MTL template with the given arguments. |
static java.util.Map<java.lang.String,java.io.StringWriter> |
doGenerateTemplate(Template template,
java.util.List<? extends java.lang.Object> arguments,
java.io.File generationRoot,
boolean preview)
Launches the generation of an MTL template with the given arguments. |
static void |
removeListener(MTLTextGenerationListener listener)
Removes a listener from the notification loops. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static void addListener(MTLTextGenerationListener listener)
removeListener(MTLTextGenerationListener).
listener - The new listener that is to be registered for notification.
public static java.util.Map<java.lang.String,java.io.StringWriter> doGenerate(java.util.Map<Module,java.util.Set<java.lang.String>> templates,
org.eclipse.emf.ecore.EObject model,
java.io.File generationRoot,
boolean preview)
Keep in mind that this can only be used with single-argument templates. Any attempt to call to a
template with more than one argument through this method will throw MTLEvaluationExceptions.
The input model will be iterated over for objects matching the templates' parameter types.
generationRoot will be used as the root of all generated files. For example, a template such as
[template generate(c:EClass)] [file(log.log, true)]processing class [c.name/][/file] [/template]evaluated with file:\\c:\ as generationRoot would create the file c:\log.log and generate a line "processing class <className>" for each class of the input model.
templates - This map will be used to locate templates of the given names in the associated module.model - Input model for this generation.generationRoot - This will be used as the root for the generated files. Cannot be null except if
preview is true in which case no files will be generated.preview - If true, no files will be generated and a Map mapping file pathes to their
generated content will be returned.
preview is set to true, no files will be generated. Instead, a Map
mapping all file pathes to the potential content will be returned. This returned map will be
empty otherwise.
public static java.util.Map<java.lang.String,java.io.StringWriter> doGenerate(Module module,
java.lang.String templateName,
org.eclipse.emf.ecore.EObject model,
java.io.File generationRoot,
boolean preview)
This is a convenience method that can only be used with single argument templates. The input model will be iterated over for objects matching the template's parameter type.
generationRoot will be used as the root of all generated files. For example, a template such as
[template generate(c:EClass)] [file(log.log, true)]processing class [c.name/][/file] [/template]evaluated with file:\\c:\ as generationRoot would create the file c:\log.log and generate a line "processing class <className>" for each class of the input model.
module - The module in which we seek a template templateName.templateName - Name of the template that is to be generated.model - Input model for this MTL template.generationRoot - This will be used as the root for the generated files. This can be null, in
which case the user home directory will be used as root.preview - If true, no files will be generated and a Map mapping file pathes to their
generated content will be returned.
preview is set to true, no files will be generated. Instead, a Map
mapping all file pathes to the potential content will be returned. This returned map will be
empty otherwise.
public static java.util.Map<java.lang.String,java.io.StringWriter> doGenerate(Module module,
java.lang.String templateName,
org.eclipse.emf.ecore.EObject model,
java.util.List<? extends java.lang.Object> arguments,
java.io.File generationRoot,
boolean preview)
This is a convenience method that can be used with multiple argument templates. The input model will be
iterated over for objects matching the template's first parameter type. The template will then
be called with these objects as first arguments, and the given list of arguments for the
remaining template parameters.
generationRoot will be used as the root of all generated files. For example, a template such as
[template generate(c:EClass)] [file(log.log, true)]processing class [c.name/][/file] [/template]evaluated with file:\\c:\ as generationRoot would create the file c:\log.log and generate a line "processing class <className>" for each class of the input model.
module - The module in which we seek a template templateName.templateName - Name of the template that is to be generated.model - Input model for this MTL template.arguments - Arguments of the template call, excluding the very first one (model object).generationRoot - This will be used as the root for the generated files. This can be null, in
which case the user home directory will be used as root.preview - If true, no files will be generated and a Map mapping file pathes to their
generated content will be returned.
preview is set to true, no files will be generated. Instead, a Map
mapping all file pathes to the potential content will be returned. This returned map will be
empty otherwise.
public static java.util.Map<java.lang.String,java.io.StringWriter> doGenerate(Template template,
org.eclipse.emf.ecore.EObject model,
java.io.File generationRoot,
boolean preview)
This is a convenience method that can only be used with single argument templates. Any attempt at
calling other templates through this method will throw MTLEvaluationExceptions. The input model
will be iterated over for objects matching the template's parameter type.
generationRoot will be used as the root of all generated files. For example, a template such as
[template generate(c:EClass)] [file(log.log, true)]processing class [c.name/][/file] [/template]evaluated with file:\\c:\ as generationRoot would create the file c:\log.log and generate a line "processing class <className>" for each class of the input model.
template - The template that is to be generatedmodel - Input model for this MTL template.generationRoot - This will be used as the root for the generated files. This can be null, in
which case the user home directory will be used as root.preview - If true, no files will be generated and a Map mapping file pathes to their
generated content will be returned.
preview is set to true, no files will be generated. Instead, a Map
mapping all file pathes to the potential content will be returned. This returned map will be
empty otherwise.
public static java.util.Map<java.lang.String,java.io.StringWriter> doGenerateTemplate(Module module,
java.lang.String templateName,
java.util.List<? extends java.lang.Object> arguments,
java.io.File generationRoot,
boolean preview)
generationRoot will be used as the root of all generated files. For example, a template such as
[template generate(c:EClass)] [file(log.log, true)]processing class [c.name/][/file] [/template]evaluated with file:\\c:\ as generationRoot would create the file c:\log.log and generate a line "processing class <className>" for each class of the input model.
module - The module in which we seek a template templateName.templateName - Name of the template that is to be generated.arguments - Arguments that must be passed on to the template for evaluation.generationRoot - This will be used as the root for the generated files. This can be null, in
which case the user home directory will be used as root.preview - If true, no files will be generated and a Map mapping file pathes to their
generated content will be returned.
preview is set to true, no files will be generated. Instead, a Map
mapping all file pathes to the potential content will be returned. This returned map will be
empty otherwise.
public static java.util.Map<java.lang.String,java.io.StringWriter> doGenerateTemplate(Template template,
java.util.List<? extends java.lang.Object> arguments,
java.io.File generationRoot,
boolean preview)
generationRoot will be used as the root of all generated files. For example, a template such as
[template generate(c:EClass)] [file(log.log, true)]processing class [c.name/][/file] [/template]evaluated with file:\\c:\ as generationRoot would create the file c:\log.log and generate a line "processing class <className>" for each class of the input model.
template - The template that is to be generatedarguments - Arguments that must be passed on to the template for evaluation.generationRoot - This will be used as the root for the generated files. This can be null, in
which case the user home directory will be used as root.preview - If true, no files will be generated and a Map mapping file pathes to their
generated content will be returned.
preview is set to true, no files will be generated. Instead, a Map
mapping all file pathes to the potential content will be returned. This returned map will be
empty otherwise.public static void removeListener(MTLTextGenerationListener listener)
listener - The listener that is to be removed from this engine's notification loops.
|
Copyright 2008 Obeo All Rights Reserved. |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||