Rule Execution Server API

ilog.rules.studio.res.generator
Class IlrVelocityGenerator

java.lang.Object
  extended by ilog.rules.studio.res.generator.IlrFileGenerator
      extended by ilog.rules.studio.res.generator.IlrVelocityGenerator
All Implemented Interfaces:
IWizardNode
Direct Known Subclasses:
IlrTraceFileGenerator

public abstract class IlrVelocityGenerator
extends IlrFileGenerator

Adds a generator to the generator list in the New Client Project for RuleApps wizard. Contrary to the IlrFileGenerator, when you extend this class you will use velocity as the template generator.

Since:
JRules 6.0

Nested Class Summary
 
Nested classes/interfaces inherited from class ilog.rules.studio.res.generator.IlrFileGenerator
IlrFileGenerator.Parameter, IlrFileGenerator.RuleApp, IlrFileGenerator.RulesetArchive
 
Field Summary
 
Fields inherited from class ilog.rules.studio.res.generator.IlrFileGenerator
contentCreated
 
Constructor Summary
IlrVelocityGenerator()
          Constructs a new generator.
 
Method Summary
 void generateProjectContent(org.eclipse.jdt.core.IJavaProject javaProject)
          Generates the content of the Java project.
protected  void generateVelocityFile(String path, String filePrefix, String templatePath, String newFilename, String extension, Object userData)
          Manages the velocity generator in the generateProjectContent(IJavaProject) method.
protected  void generateVelocityFile(String path, String filePrefix, String templateDirectory, String templatePath, String newFilename, String extension, Object userData)
          Manages the velocity generator in the generateProjectContent(IJavaProject) method.
protected  void generateVelocityFileInSrc(String packagePrefix, String filePrefix, String templatePath, String newFilename, String extension, Object userData)
          Manages the velocity generator in the generateProjectContent(IJavaProject) method.
protected  void generateVelocityFileInSrc(String packagePrefix, String filePrefix, String templateDirectory, String templatePath, String newFilename, String extension, Object userData)
          Manages the velocity generator in the generateProjectContent(IJavaProject) method.
protected  String getGeneratedExtension()
          Gets the name (name and extension) of the file that will be created by the generateVelocityFile(String,String,String,String,String,Object) method.
protected  String getGeneratedFileName()
          Gets the name (without extension) of the file that will be created by the generateVelocityFile(String,String,String,String,String,Object) method.
protected  String getGeneratedName()
          Gets the extension of the file that will be created by the generateVelocityFile(String,String,String,String,String,Object) method.
protected abstract  String getTemplateDirectory()
          Gets the location (an absolute path) the template paths will be relative to.
protected abstract  org.apache.velocity.VelocityContext initializeContext(Object userData, org.apache.velocity.VelocityContext context)
          Initializes a velocity context.
 
Methods inherited from class ilog.rules.studio.res.generator.IlrFileGenerator
addContainerEntryInClasspath, addLibraryEntryInClasspath, addProjectEntryInClasspath, addVariableEntryInClasspath, changeInClassName, changeInMethodName, completeProjectFromTemplate, copyFile, createPackage, createProjectFromTemplate, generateLaunchConfigurationFile, generateProjectContent, generateProjectContent, generateProjectContent, getCompletionWizard, getCreationWizard, getExecutionServerHome, getInParameters, getInParameters, getInParameters, getInParametersImports, getInParametersImports, getJavaProject, getJavaProjectNameAsClassName, getLaunchConfigurationName, getNewParameter, getNewRulesetArchive, getNotAllowedDescription, getOutParameters, getOutParametersImports, getParameters, getParametersImports, getProject, getRuleAppProject, getRulesetArchives, getRulesetArchives, getRuleStudioHome, getSignatures, getUTF8CharsetAsString, getWizard, getXOMPath, initialize, isAllowed, isJavaProject, setJavaNature, setSignatures
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.eclipse.jface.wizard.IWizardNode
dispose, getExtent, isContentCreated
 

Constructor Detail

IlrVelocityGenerator

public IlrVelocityGenerator()
Constructs a new generator. The class that extends this one must declare a public default constructor, which calls this constructor. The default constructor is the only one called to create a generator.

Since:
JRules 6.6
Method Detail

getTemplateDirectory

protected abstract String getTemplateDirectory()
Gets the location (an absolute path) the template paths will be relative to.

Returns:
The location where the templates are stored.

generateProjectContent

public void generateProjectContent(org.eclipse.jdt.core.IJavaProject javaProject)
Generates the content of the Java project.

The default implementation creates a src directory in the Java project.

Overrides:
generateProjectContent in class IlrFileGenerator
Parameters:
javaProject - The destination of the Java project files.
See Also:
IlrFileGenerator.generateProjectContent(IJavaProject)

generateVelocityFileInSrc

protected void generateVelocityFileInSrc(String packagePrefix,
                                         String filePrefix,
                                         String templatePath,
                                         String newFilename,
                                         String extension,
                                         Object userData)
Manages the velocity generator in the generateProjectContent(IJavaProject) method. This method uses the getTemplateDirectory() method to know where to look for the template files specified by templatePath parameter. The initializeContext(Object,VelocityContext) method is called to get the parameter values to put in the template file.

Parameters:
packagePrefix - The relative path to the src directory to create the file. If the package does not exist, it is created. If the path is null, the file will be generated in the project root directory.
filePrefix - The prefix that will be added to the template file to compute the generated file name.
templatePath - The relative path of the .vm file. The path is relative to the path specified by the getTemplateDirectory() method. The path separator is '/' even on Windows.
newFilename - The generated file name. If the value is null, the generated file name will be computed replacing the ".vm" extension in the template file name by the extension specified in the extension parameter.
extension - The extension to use to compute the generated file name using the template file name. It is used only if the newFilename parameter is null.
userData - An object that will be transmitted to the initializeContext(Object,VelocityContext) method.

generateVelocityFileInSrc

protected void generateVelocityFileInSrc(String packagePrefix,
                                         String filePrefix,
                                         String templateDirectory,
                                         String templatePath,
                                         String newFilename,
                                         String extension,
                                         Object userData)
Manages the velocity generator in the generateProjectContent(IJavaProject) method. The template file specified by templatePath parameter is relative to the templateDirectory parameter. The initializeContext(Object,VelocityContext) method is called to get the parameter values to put in the template file.

Since:
JRules 6.5
Parameters:
packagePrefix - The relative path to the src directory to create the file. If the package does not exist, it is created. If the path is null, the file will be generated in the project root directory.
filePrefix - The prefix that will be added to the template file to compute the generated file name.
templateDirectory - The location (an absolute path) where the template path will be relative to.
templatePath - The relative path of the .vm file. The path is relative to the path specified by the templateDirectory parameter. The path separator is '/' even on Windows.
newFilename - The generated file name. If the value is null, the generated file name will be computed replacing the ".vm" extension in the template file name by the extension specified in the extension parameter.
extension - The extension to use to compute the generated file name using the template file name. It is used only if the newFilename parameter is null.
userData - An object that will be transmitted to the initializeContext(Object,VelocityContext) method.

generateVelocityFile

protected void generateVelocityFile(String path,
                                    String filePrefix,
                                    String templatePath,
                                    String newFilename,
                                    String extension,
                                    Object userData)
Manages the velocity generator in the generateProjectContent(IJavaProject) method. This method uses the getTemplateDirectory() method to know where to look for the template files specified by templatePath parameter. The initializeContext(Object,VelocityContext) method is called to get the parameter values to put in the template file.

Parameters:
path - The relative path to the project directory to create the file. If the path does not exist, it is created. If the path is null, the file will be generated in the project root directory (it is equivalent to set the path to "").
filePrefix - The prefix that will be added to the template file to compute the generated file name.
templatePath - The relative path of the .vm file. The path is relative to the path specified by the getTemplateDirectory() method. The path separator is '/' even on Windows.
newFilename - The generated file name. If the value is null, the generated file name will be computed replacing the ".vm" extension in the template file name by the extension specified in the extension parameter.
extension - The extension to use to compute the generated file name using the template file name. It is used only if the newFilename parameter is null.
userData - An object that will be transmitted to the initializeContext(Object,VelocityContext) method.

generateVelocityFile

protected void generateVelocityFile(String path,
                                    String filePrefix,
                                    String templateDirectory,
                                    String templatePath,
                                    String newFilename,
                                    String extension,
                                    Object userData)
Manages the velocity generator in the generateProjectContent(IJavaProject) method. The template file specified by templatePath parameter is relative to the templateDirectory parameter. The initializeContext(Object,VelocityContext) method is called to get the parameter values to put in the template file.

Since:
JRules 6.5
Parameters:
path - The relative path to the project directory to create the file. If the path does not exist, it is created. If the path is null, the file will be generated in the project root directory (it is equivalent to set the path to "").
filePrefix - The prefix that will be added to the template file to compute the generated file name.
templateDirectory - The location (an absolute path) where the template path will be relative to.
templatePath - The relative path of the .vm file. The path is relative to the path specified by the templateDirectory parameter. The path separator is '/' even on Windows.
newFilename - The generated file name. If the value is null, the generated file name will be computed replacing the ".vm" extension in the template file name by the extension specified in the extension parameter.
extension - The extension to use to compute the generated file name using the template file name. It is used only if the newFilename parameter is null.
userData - An object that will be transmitted to the initializeContext(Object,VelocityContext) method.

initializeContext

protected abstract org.apache.velocity.VelocityContext initializeContext(Object userData,
                                                                         org.apache.velocity.VelocityContext context)
Initializes a velocity context. This method is called when the velocity context is initialized in the generateVelocityFile(String,String,String,String,String,Object) method. It gets the parameters to put in the velocity template.

Parameters:
userData - The object specified in the generateVelocityFile(String,String,String,String,String,Object) method.
context - The velocity context to fill.
Returns:
The filled velocity context.

getGeneratedExtension

protected String getGeneratedExtension()
Gets the name (name and extension) of the file that will be created by the generateVelocityFile(String,String,String,String,String,Object) method.

Since:
JRules 6.0.1
Returns:
The name of the file that will be created.

getGeneratedFileName

protected String getGeneratedFileName()
Gets the name (without extension) of the file that will be created by the generateVelocityFile(String,String,String,String,String,Object) method.

Since:
JRules 6.0.1
Returns:
The name of the file that will be created.

getGeneratedName

protected String getGeneratedName()
Gets the extension of the file that will be created by the generateVelocityFile(String,String,String,String,String,Object) method.

Since:
JRules 6.0.1
Returns:
The name of the file that will be created.

Rule Execution Server API

© Copyright IBM Corp. 1987, 2012