org.eclipse.ocl.examples.codegen.ecore
Class OCL2Java4genmodel

java.lang.Object
  extended by org.eclipse.acceleo.engine.service.AbstractAcceleoGenerator
      extended by org.eclipse.ocl.examples.codegen.ecore.OCL2Java4genmodel

public class OCL2Java4genmodel
extends org.eclipse.acceleo.engine.service.AbstractAcceleoGenerator

Entry point of the 'ocl2java4genmodel' generation module.

Generated

Field Summary
static java.lang.String MODULE_FILE_NAME
          The name of the module.
static java.lang.String PROJECT_NAME
           
static java.lang.String[] TEMPLATE_NAMES
          The name of the templates that are to be generated.
 
Fields inherited from class org.eclipse.acceleo.engine.service.AbstractAcceleoGenerator
acceleoPropertiesLoaderService, generationArguments, generationID, generationListeners, model, module, originalResources, resourceFactoryRegistry, targetFolder
 
Constructor Summary
OCL2Java4genmodel()
          Allows the public constructor to be used.
OCL2Java4genmodel(org.eclipse.emf.ecore.EObject model, java.io.File targetFolder, java.util.List<? extends java.lang.Object> arguments)
          This allows clients to instantiates a generator with all required information.
OCL2Java4genmodel(org.eclipse.emf.common.util.URI modelURI, java.io.File targetFolder, java.util.List<? extends java.lang.Object> arguments)
          This allows clients to instantiates a generator with all required information.
 
Method Summary
 void addPropertiesFile(java.lang.String propertiesFile)
          Adds a properties file in the list of properties files.
protected  org.eclipse.emf.common.util.URI createTemplateURI(java.lang.String entry)
           
 void doGenerate(org.eclipse.emf.common.util.Monitor monitor)
          Launches the generation described by this instance.
protected  java.net.URL findModuleURL(java.lang.String moduleName)
           
 java.util.Map<java.lang.String,java.lang.String> generate(org.eclipse.emf.common.util.Monitor monitor)
           
 java.util.List<org.eclipse.acceleo.engine.event.IAcceleoTextGenerationListener> getGenerationListeners()
          If this generator needs to listen to text generation events, listeners can be returned from here.
 org.eclipse.acceleo.engine.generation.strategy.IAcceleoGenerationStrategy getGenerationStrategy()
          If you need to change the way files are generated, this is your entry point.
 java.lang.String getModuleName()
          This will be called in order to find and load the module that will be launched through this launcher.
 java.util.List<java.lang.String> getProperties()
          If the module(s) called by this launcher require properties files, return their qualified path from here.Take note that the first added properties files will take precedence over subsequent ones if they contain conflicting keys.
 java.lang.String[] getTemplateNames()
          This will be used to get the list of templates that are to be launched by this launcher.
 void initialize(org.eclipse.emf.ecore.EObject element, java.io.File folder, java.util.List<? extends java.lang.Object> arguments)
           
 void initialize(org.eclipse.emf.common.util.URI modelURI, java.io.File folder, java.util.List<?> arguments)
           
static void main(java.lang.String[] args)
          This can be used to launch the generation from a standalone application.
protected  void preInitialize()
           
 void registerPackages(org.eclipse.emf.ecore.resource.ResourceSet resourceSet)
           
 void registerPackagesGen(org.eclipse.emf.ecore.resource.ResourceSet resourceSet)
          This can be used to update the resource set's package registry with all needed EPackages.
 void registerResourceFactories(org.eclipse.emf.ecore.resource.ResourceSet resourceSet)
          This can be used to update the resource set's resource factory registry with all needed factories.
 
Methods inherited from class org.eclipse.acceleo.engine.service.AbstractAcceleoGenerator
addGenerationListener, addListeners, addProperties, clearPackageRegistry, createAcceleoService, createURIConverter, getArguments, getModel, getModule, getOCLStdLibPackage, getPropertiesLoaderService, getTargetFolder, isInWorkspace, postGenerate, postInitialize, setGenerationID
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MODULE_FILE_NAME

public static final java.lang.String MODULE_FILE_NAME
The name of the module.

See Also:
Constant Field Values
Generated

TEMPLATE_NAMES

public static final java.lang.String[] TEMPLATE_NAMES
The name of the templates that are to be generated.

Generated

PROJECT_NAME

public static final java.lang.String PROJECT_NAME
See Also:
Constant Field Values
Constructor Detail

OCL2Java4genmodel

public OCL2Java4genmodel()
Allows the public constructor to be used. Note that a generator created this way cannot be used to launch generations before one of initialize(EObject, File, List) or initialize(URI, File, List) is called.

The main reason for this constructor is to allow clients of this generation to call it from another Java file, as it allows for the retrieval of getProperties() and getGenerationListeners().

Generated

OCL2Java4genmodel

public OCL2Java4genmodel(org.eclipse.emf.common.util.URI modelURI,
                         java.io.File targetFolder,
                         java.util.List<? extends java.lang.Object> arguments)
                  throws java.io.IOException
This allows clients to instantiates a generator with all required information.

Parameters:
modelURI - URI where the model on which this generator will be used is located.
targetFolder - This will be used as the output folder for this generation : it will be the base path against which all file block URLs will be resolved.
arguments - If the template which will be called requires more than one argument taken from the model, pass them here.
Throws:
java.io.IOException - This can be thrown in three scenarios : the module cannot be found, it cannot be loaded, or the model cannot be loaded.
Generated

OCL2Java4genmodel

public OCL2Java4genmodel(org.eclipse.emf.ecore.EObject model,
                         java.io.File targetFolder,
                         java.util.List<? extends java.lang.Object> arguments)
                  throws java.io.IOException
This allows clients to instantiates a generator with all required information.

Parameters:
model - We'll iterate over the content of this element to find Objects matching the first parameter of the template we need to call.
targetFolder - This will be used as the output folder for this generation : it will be the base path against which all file block URLs will be resolved.
arguments - If the template which will be called requires more than one argument taken from the model, pass them here.
Throws:
java.io.IOException - This can be thrown in two scenarios : the module cannot be found, or it cannot be loaded.
Generated
Method Detail

main

public static void main(java.lang.String[] args)
This can be used to launch the generation from a standalone application.

Parameters:
args - Arguments of the generation.
Generated

doGenerate

public void doGenerate(org.eclipse.emf.common.util.Monitor monitor)
                throws java.io.IOException
Launches the generation described by this instance.

Overrides:
doGenerate in class org.eclipse.acceleo.engine.service.AbstractAcceleoGenerator
Parameters:
monitor - This will be used to display progress information to the user.
Throws:
java.io.IOException - This will be thrown if any of the output files cannot be saved to disk.
Generated

generate

public java.util.Map<java.lang.String,java.lang.String> generate(org.eclipse.emf.common.util.Monitor monitor)
                                                          throws java.io.IOException
Overrides:
generate in class org.eclipse.acceleo.engine.service.AbstractAcceleoGenerator
Throws:
java.io.IOException

getGenerationListeners

public java.util.List<org.eclipse.acceleo.engine.event.IAcceleoTextGenerationListener> getGenerationListeners()
If this generator needs to listen to text generation events, listeners can be returned from here.

Overrides:
getGenerationListeners in class org.eclipse.acceleo.engine.service.AbstractAcceleoGenerator
Returns:
List of listeners that are to be notified when text is generated through this launch.
Generated

getGenerationStrategy

public org.eclipse.acceleo.engine.generation.strategy.IAcceleoGenerationStrategy getGenerationStrategy()
If you need to change the way files are generated, this is your entry point.

The default is DefaultStrategy; it generates files on the fly. If you only need to preview the results, return a new PreviewStrategy. Both of these aren't aware of the running Eclipse and can be used standalone.

If you need the file generation to be aware of the workspace (A typical example is when you wanna override files that are under clear case or any other VCS that could forbid the overriding), then return a new WorkspaceAwareStrategy. Note, however, that this cannot be used standalone.

All three of these default strategies support merging through JMerge.

Overrides:
getGenerationStrategy in class org.eclipse.acceleo.engine.service.AbstractAcceleoGenerator
Returns:
The generation strategy that is to be used for generations launched through this launcher.
Generated

getModuleName

public java.lang.String getModuleName()
This will be called in order to find and load the module that will be launched through this launcher. We expect this name not to contain file extension, and the module to be located beside the launcher.

Specified by:
getModuleName in class org.eclipse.acceleo.engine.service.AbstractAcceleoGenerator
Returns:
The name of the module that is to be launched.
Generated

getProperties

public java.util.List<java.lang.String> getProperties()
If the module(s) called by this launcher require properties files, return their qualified path from here.Take note that the first added properties files will take precedence over subsequent ones if they contain conflicting keys.

Overrides:
getProperties in class org.eclipse.acceleo.engine.service.AbstractAcceleoGenerator
Returns:
The list of properties file we need to add to the generation context.
See Also:
ResourceBundle.getBundle(String)
Generated

addPropertiesFile

public void addPropertiesFile(java.lang.String propertiesFile)
Adds a properties file in the list of properties files.

Overrides:
addPropertiesFile in class org.eclipse.acceleo.engine.service.AbstractAcceleoGenerator
Parameters:
propertiesFile - The properties file to add.
Since:
3.1
Generated

getTemplateNames

public java.lang.String[] getTemplateNames()
This will be used to get the list of templates that are to be launched by this launcher.

Specified by:
getTemplateNames in class org.eclipse.acceleo.engine.service.AbstractAcceleoGenerator
Returns:
The list of templates to call on the module getModuleName().
Generated

registerPackagesGen

public void registerPackagesGen(org.eclipse.emf.ecore.resource.ResourceSet resourceSet)
This can be used to update the resource set's package registry with all needed EPackages.

Parameters:
resourceSet - The resource set which registry has to be updated.
Generated

registerPackages

public void registerPackages(org.eclipse.emf.ecore.resource.ResourceSet resourceSet)
Overrides:
registerPackages in class org.eclipse.acceleo.engine.service.AbstractAcceleoGenerator

registerResourceFactories

public void registerResourceFactories(org.eclipse.emf.ecore.resource.ResourceSet resourceSet)
This can be used to update the resource set's resource factory registry with all needed factories.

Overrides:
registerResourceFactories in class org.eclipse.acceleo.engine.service.AbstractAcceleoGenerator
Parameters:
resourceSet - The resource set which registry has to be updated.
Generated
NOT

initialize

public void initialize(org.eclipse.emf.ecore.EObject element,
                       java.io.File folder,
                       java.util.List<? extends java.lang.Object> arguments)
                throws java.io.IOException
Overrides:
initialize in class org.eclipse.acceleo.engine.service.AbstractAcceleoGenerator
Throws:
java.io.IOException

initialize

public void initialize(org.eclipse.emf.common.util.URI modelURI,
                       java.io.File folder,
                       java.util.List<?> arguments)
                throws java.io.IOException
Overrides:
initialize in class org.eclipse.acceleo.engine.service.AbstractAcceleoGenerator
Throws:
java.io.IOException

preInitialize

protected void preInitialize()

findModuleURL

protected java.net.URL findModuleURL(java.lang.String moduleName)
Overrides:
findModuleURL in class org.eclipse.acceleo.engine.service.AbstractAcceleoGenerator

createTemplateURI

protected org.eclipse.emf.common.util.URI createTemplateURI(java.lang.String entry)
Overrides:
createTemplateURI in class org.eclipse.acceleo.engine.service.AbstractAcceleoGenerator