## org.eclipse.emf.codegen.ecore.genmodel.generator
Class GenBaseGeneratorAdapter

    java.lang.Object
      org.eclipse.emf.common.notify.impl.SingletonAdapterImpl
          org.eclipse.emf.codegen.ecore.generator.AbstractGeneratorAdapter
              org.eclipse.emf.codegen.ecore.genmodel.generator.GenBaseGeneratorAdapter

All Implemented Interfaces:
  GeneratorAdapter, Adapter, Adapter.Internal

Direct Known Subclasses:
  GenClassGeneratorAdapter, GenEnumGeneratorAdapter, GenModelGeneratorAdapter, GenPackageGeneratorAdapter

    public class GenBaseGeneratorAdapter

extends AbstractGeneratorAdapter

A base generator adapter implementation for GenModel elements. This base defines four project types for code generation and provides implementations of `canGenerate(Object, Object)`, `getGenerateChildren(Object, Object)`, and `doGenerate(Object, Object, Monitor)` that dispatch to project-type-specific methods, which can be overridden in subclasses.

Since:
  2.2.0

Nested Class Summary

Nested classes/interfaces inherited from class org.eclipse.emf.codegen.ecore.generator.AbstractGeneratorAdapter
`AbstractGeneratorAdapter.JETEmitterDescriptor`

Nested classes/interfaces inherited from interface org.eclipse.emf.common.notify.Adapter
`Adapter.Internal`

Field Summary
`static java.lang.String` `EDIT_PROJECT_TYPE` The project type constant representing an edit project.
`static java.lang.String` `EDITOR_PROJECT_TYPE` The project type constant representing an editor project.
`static java.lang.String` `MODEL_PROJECT_TYPE` The project type constant representing a model project.
`static java.lang.String` `TESTS_PROJECT_TYPE` The project type constant representing a tests project.

Fields inherited from class org.eclipse.emf.codegen.ecore.generator.AbstractGeneratorAdapter
`adapterFactory, generatingObject, gifEmitters, importManager, jetEmitters, lineDelimiter, MANIFEST_ENCODING, message, OBJECT_ARGUMENT, PROPERTIES_ENCODING, uriConverter`

Fields inherited from class org.eclipse.emf.common.notify.impl.SingletonAdapterImpl
`targets`

Constructor Summary
`GenBaseGeneratorAdapter()`
`GenBaseGeneratorAdapter(GeneratorAdapterFactory generatorAdapterFactory)`

Method Summary
`protected void` `addBaseTemplatePathEntries(java.util.List<java.lang.String> templatePath)` Adds the default EMF template location to the base portion of the dynamic template path.
`protected void` `addClasspathEntries(JETEmitter jetEmitter)` Adds the plug-ins required for GenModel/Ecore-based templates to the `JETEmitter`'s classpath.
`boolean` `canGenerate(java.lang.Object object, java.lang.Object projectType)` Based on the given project type, dispatches to one of `canGenerateModel(Object)`, `canGenerateEdit(Object)`, `canGenerateEditor(Object)`, or `canGenerateTests(Object)`.
`boolean` `canGenerateEdit(java.lang.Object object)` Delegates to the GenMoel element's `canGenerateEdit()` method.
`boolean` `canGenerateEditor(java.lang.Object object)` Delegates to the GenMoel element's `canGenerateEditor()` method.
`boolean` `canGenerateModel(java.lang.Object object)` Delegates to the GenMoel element's `canGenerate()` method.
`boolean` `canGenerateTests(java.lang.Object object)` Delegates to the GenMoel element's `canGenerateTests()` method.
`protected void` `clearImportManager()` Clears the import manager and removes it from the `GenModel`.
`protected void` `createImportManager(java.lang.String packageName, java.lang.String className)` Creates the import manager and stores it on the `GenModel`, for use its in computing names.
`Diagnostic` `doGenerate(java.lang.Object object, java.lang.Object projectType, Monitor monitor)` Based on the given project type, dispatches to one of `generateModel(Object, Monitor)`, `generateEdit(Object, Monitor)`, `generateEditor(Object, Monitor)`, or `generateTests(Object, Monitor)`.
`protected void` `ensureProjectExists(java.lang.String workspacePath, java.lang.Object object, java.lang.Object projectType, boolean force, Monitor monitor)` Ensures that a project exists.
`protected Diagnostic` `generateEdit(java.lang.Object object, Monitor monitor)`
`protected Diagnostic` `generateEditor(java.lang.Object object, Monitor monitor)`
`protected Diagnostic` `generateModel(java.lang.Object object, Monitor monitor)`
`protected Diagnostic` `generateTests(java.lang.Object object, Monitor monitor)`
`java.util.Collection<?>` `getGenerateChildren(java.lang.Object object, java.lang.Object projectType)` Based on the given project type, dispatches to one of `getGenerateModelChildren(Object)`, `getGenerateEditChildren(Object)`, `getGenerateEditorChildren(Object)`, or `getGenerateTestsChildren(Object)`.
`protected java.util.Collection<?>` `getGenerateEditChildren(java.lang.Object object)`
`protected java.util.Collection<?>` `getGenerateEditorChildren(java.lang.Object object)`
`protected java.util.Collection<?>` `getGenerateModelChildren(java.lang.Object object)`
`protected java.util.Collection<?>` `getGenerateTestsChildren(java.lang.Object object)`
`protected java.lang.Object` `getParent(java.lang.Object object)` Returns the container of the given object if it is a GenModel element, and null otherwise.
`protected java.util.List<java.lang.String>` `getUserTemplatePath()` Returns the user-specified portion of the dynamic template path from the GenModel.
`protected void` `setLineDelimiter(java.lang.String lineDelimiter)` Sets the current line delimiter used for generating textual results.

Methods inherited from class org.eclipse.emf.codegen.ecore.generator.AbstractGeneratorAdapter

`createCodeFormatter, createGIFEmitter, createInputStream, createJETEmitter, createMonitor, createOutputStream, doPostGenerate, doPreGenerate, ensureContainerExists, exists, formatCode, generate, generateGIF, generateJava, generateProperties, generateText, getAdapterFactory, getCanGenerateChildren, getCanGenerateParent, getContents, getEncoding, getGenerateParent, getGenerator, getGIFEmitter, getImportManager, getJETEmitter, getLineDelimiter, getLineDelimiter, getURIConverter, isAdapterForType, isReadOnly, postGenerate, preGenerate, setAdapterFactory, setStaticTemplateClass, setWriteable, toDiagnostic, toPlatformResourceURI, toURI, validateEdit`

Methods inherited from class org.eclipse.emf.common.notify.impl.SingletonAdapterImpl
`dispose, getTarget, notifyChanged, setTarget, unsetTarget`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Methods inherited from interface org.eclipse.emf.codegen.ecore.generator.GeneratorAdapter
`dispose`

Field Detail

### MODEL_PROJECT_TYPE

    public static final java.lang.String MODEL_PROJECT_TYPE

  The project type constant representing a model project. This is the string "org.eclipse.emf.codegen.ecore.genmodel.generator.ModelProject".

  See Also:
    Constant Field Values

### EDIT_PROJECT_TYPE

    public static final java.lang.String EDIT_PROJECT_TYPE

  The project type constant representing an edit project. This is the string "org.eclipse.emf.codegen.ecore.genmodel.generator.EditProject".

  See Also:
    Constant Field Values

### EDITOR_PROJECT_TYPE

    public static final java.lang.String EDITOR_PROJECT_TYPE

  The project type constant representing an editor project. This is the string "org.eclipse.emf.codegen.ecore.genmodel.generator.EditorProject".

  See Also:
    Constant Field Values

### TESTS_PROJECT_TYPE

    public static final java.lang.String TESTS_PROJECT_TYPE

  The project type constant representing a tests project. This is the string "org.eclipse.emf.codegen.ecore.genmodel.generator.TestsProject".

  See Also:
    Constant Field Values

Constructor Detail

### GenBaseGeneratorAdapter

    public GenBaseGeneratorAdapter()

### GenBaseGeneratorAdapter

    public GenBaseGeneratorAdapter(GeneratorAdapterFactory generatorAdapterFactory)

Method Detail

### canGenerate

    public boolean canGenerate(java.lang.Object object,
                               java.lang.Object projectType)

  Based on the given project type, dispatches to one of `canGenerateModel(Object)`, `canGenerateEdit(Object)`, `canGenerateEditor(Object)`, or `canGenerateTests(Object)`.

  Specified by:
    `canGenerate` in interface `GeneratorAdapter`
  Specified by:
    `canGenerate` in class `AbstractGeneratorAdapter`

### canGenerateModel

    public boolean canGenerateModel(java.lang.Object object)

  Delegates to the GenMoel element's `canGenerate()` method.

### canGenerateEdit

    public boolean canGenerateEdit(java.lang.Object object)

  Delegates to the GenMoel element's `canGenerateEdit()` method.

### canGenerateEditor

    public boolean canGenerateEditor(java.lang.Object object)

  Delegates to the GenMoel element's `canGenerateEditor()` method.

### canGenerateTests

    public boolean canGenerateTests(java.lang.Object object)

  Delegates to the GenMoel element's `canGenerateTests()` method.

### getGenerateChildren

    public java.util.Collection<?> getGenerateChildren(java.lang.Object object,
                                                       java.lang.Object projectType)

  Based on the given project type, dispatches to one of `getGenerateModelChildren(Object)`, `getGenerateEditChildren(Object)`, `getGenerateEditorChildren(Object)`, or `getGenerateTestsChildren(Object)`.

  Specified by:
    `getGenerateChildren` in interface `GeneratorAdapter`
  Overrides:
    `getGenerateChildren` in class `AbstractGeneratorAdapter`

### getGenerateModelChildren

    protected java.util.Collection<?> getGenerateModelChildren(java.lang.Object object)

### getGenerateEditChildren

    protected java.util.Collection<?> getGenerateEditChildren(java.lang.Object object)

### getGenerateEditorChildren

    protected java.util.Collection<?> getGenerateEditorChildren(java.lang.Object object)

### getGenerateTestsChildren

    protected java.util.Collection<?> getGenerateTestsChildren(java.lang.Object object)

### getParent

    protected java.lang.Object getParent(java.lang.Object object)

  Returns the container of the given object if it is a GenModel element, and null otherwise.

### doGenerate

    public Diagnostic doGenerate(java.lang.Object object,
                                 java.lang.Object projectType,
                                 Monitor monitor)

  Based on the given project type, dispatches to one of `generateModel(Object, Monitor)`, `generateEdit(Object, Monitor)`, `generateEditor(Object, Monitor)`, or `generateTests(Object, Monitor)`.

  Specified by:
    `doGenerate` in class `AbstractGeneratorAdapter`

### generateModel

    protected Diagnostic generateModel(java.lang.Object object,
                                       Monitor monitor)

### generateEdit

    protected Diagnostic generateEdit(java.lang.Object object,
                                      Monitor monitor)

### generateEditor

    protected Diagnostic generateEditor(java.lang.Object object,
                                        Monitor monitor)

### generateTests

    protected Diagnostic generateTests(java.lang.Object object,
                                       Monitor monitor)

### getUserTemplatePath

    protected java.util.List<java.lang.String> getUserTemplatePath()

  Returns the user-specified portion of the dynamic template path from the GenModel.

  Overrides:
    `getUserTemplatePath` in class `AbstractGeneratorAdapter`
  Since:
    org.eclipse.emf.codegen.ecore 2.2.2
  See Also:
    `Generator.Options.templatePath`, `JETEmitter.JETEmitter(String[], String)`, `JETCompiler.find(String[], String)`

### addBaseTemplatePathEntries

    protected void addBaseTemplatePathEntries(java.util.List<java.lang.String> templatePath)

  Adds the default EMF template location to the base portion of the dynamic template path. Subclasses may override this to add to the front of the path, and then invoke this implementation.

  Overrides:
    `addBaseTemplatePathEntries` in class `AbstractGeneratorAdapter`
  Since:
    org.eclipse.emf.codegen.ecore 2.2.2
  See Also:
    `Generator.Options.templatePath`, `JETEmitter.JETEmitter(String[], String)`, `JETCompiler.find(String[], String)`

### addClasspathEntries

    protected void addClasspathEntries(JETEmitter jetEmitter)
                                throws JETException

  Adds the plug-ins required for GenModel/Ecore-based templates to the `JETEmitter`'s classpath.

  Overrides:
    `addClasspathEntries` in class `AbstractGeneratorAdapter`
  Throws:
    `JETException`
  See Also:
    `JETEmitter.addVariable(String, String)`

### createImportManager

    protected void createImportManager(java.lang.String packageName,
                                       java.lang.String className)

  Creates the import manager and stores it on the `GenModel`, for use its in computing names.

  Overrides:
    `createImportManager` in class `AbstractGeneratorAdapter`

### clearImportManager

    protected void clearImportManager()

  Clears the import manager and removes it from the `GenModel`.

  Overrides:
    `clearImportManager` in class `AbstractGeneratorAdapter`

### setLineDelimiter

    protected void setLineDelimiter(java.lang.String lineDelimiter)

  Description copied from class: `AbstractGeneratorAdapter`
  Sets the current line delimiter used for generating textual results.

  Overrides:
    `setLineDelimiter` in class `AbstractGeneratorAdapter`

### ensureProjectExists

    protected void ensureProjectExists(java.lang.String workspacePath,
                                       java.lang.Object object,
                                       java.lang.Object projectType,
                                       boolean force,
                                       Monitor monitor)

  Ensures that a project exists. If not, a properly configured EMF project will be created. Similarly, if the project does exist and `force` is true, it will be reconfigured to match the default EMF configuration.

  Overrides:
    `ensureProjectExists` in class `AbstractGeneratorAdapter`

Copyright 2001-2006 IBM Corporation and others. All Rights Reserved.