org.eclipse.emf.codegen.ecore.genmodel.generator
Class GenModelGeneratorAdapterFactory

java.lang.Object
  extended byorg.eclipse.emf.common.notify.impl.AdapterFactoryImpl
      extended byorg.eclipse.emf.codegen.ecore.genmodel.util.GenModelAdapterFactory
          extended byorg.eclipse.emf.codegen.ecore.genmodel.generator.GenModelGeneratorAdapterFactory
All Implemented Interfaces:
AdapterFactory, GeneratorAdapterFactory

public class GenModelGeneratorAdapterFactory
extends GenModelAdapterFactory
implements GeneratorAdapterFactory

A generator adapter factory for the GenModel package. This implementation creates the adapters that perform default EMF code generation. It can also be subclassed to create derived adapters that remove from or change the default code generation, or to create separate adapters that augment the default code generation.

The factory implements a singleton adapter pattern, where one adapter is cached and reused for all objects of a given type.

This implementation also initializes its generator's options based on the GenModel.

Since:
2.2.0

Nested Class Summary
 
Nested classes inherited from class org.eclipse.emf.codegen.ecore.generator.GeneratorAdapterFactory
GeneratorAdapterFactory.Descriptor
 
Field Summary
static GeneratorAdapterFactory.Descriptor DESCRIPTOR
          A descriptor for this adapter factory, which can be used to programatically register it.
protected  GenBaseGeneratorAdapter genClassGeneratorAdapter
           
protected  GenBaseGeneratorAdapter genEnumGeneratorAdapter
           
protected  Generator generator
           
protected  GenBaseGeneratorAdapter genModelGeneratorAdapter
           
protected  GenBaseGeneratorAdapter genPackageGeneratorAdapter
           
protected static String MERGE_RULES_PATH_NAME
          The default JMerge rules file for EMF.
 
Fields inherited from class org.eclipse.emf.codegen.ecore.genmodel.util.GenModelAdapterFactory
modelPackage, modelSwitch
 
Constructor Summary
GenModelGeneratorAdapterFactory()
           
 
Method Summary
 Adapter adapt(Notifier target, Object type)
          Does an adapt(Notifier, Object), substituting this for the given type.
 Adapter createGenClassAdapter()
          Returns a singleton GenClassGeneratorAdapter.
 Adapter createGenEnumAdapter()
          Returns a singleton GenEnumGeneratorAdapter.
 Adapter createGenModelAdapter()
          Returns a singleton GenModelGeneratorAdapter.
 Adapter createGenPackageAdapter()
          Returns a singleton GenPackageGeneratorAdapter.
 void dispose()
          Disposes this adapter factory and all of the adapters it has created.
 Generator getGenerator()
          Returns the Generator associated with this adapter factory.
protected  String getMergeRulesURI(GenModel genModel)
          Returns the URI of the merge rules file for the given GenModel.
protected  String[] getTemplatePath(GenModel genModel)
          Deprecated. org.eclipse.emf.codegen.ecore 2.2.2 Override AbstractGeneratorAdapter.addBaseTemplatePathEntries(java.util.List) and, if needed, getMergeRulesURI(GenModel), instead.
 void initialize(Object input)
          Performs initialization for the given input GenModel.
 boolean isFactoryForType(Object type)
          Returns true when the type is GeneratorAdapter.class.
 void setGenerator(Generator generator)
          Sets the Generator associated with this adapter factory.
 
Methods inherited from class org.eclipse.emf.codegen.ecore.genmodel.util.GenModelAdapterFactory
createAdapter, createEObjectAdapter, createGenAnnotationAdapter, createGenBaseAdapter, createGenClassifierAdapter, createGenDataTypeAdapter, createGenEnumLiteralAdapter, createGenFeatureAdapter, createGenOperationAdapter, createGenParameterAdapter, createGenTypedElementAdapter
 
Methods inherited from class org.eclipse.emf.common.notify.impl.AdapterFactoryImpl
adapt, adaptAllNew, adaptNew, associate, createAdapter, resolve
 
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.common.notify.AdapterFactory
adapt, adaptAllNew, adaptNew
 

Field Detail

DESCRIPTOR

public static final GeneratorAdapterFactory.Descriptor DESCRIPTOR
A descriptor for this adapter factory, which can be used to programatically register it.

See Also:
GeneratorAdapterFactory.Descriptor.Registry

MERGE_RULES_PATH_NAME

protected static final String MERGE_RULES_PATH_NAME
The default JMerge rules file for EMF.

See Also:
Constant Field Values

generator

protected Generator generator

genModelGeneratorAdapter

protected GenBaseGeneratorAdapter genModelGeneratorAdapter

genPackageGeneratorAdapter

protected GenBaseGeneratorAdapter genPackageGeneratorAdapter

genClassGeneratorAdapter

protected GenBaseGeneratorAdapter genClassGeneratorAdapter

genEnumGeneratorAdapter

protected GenBaseGeneratorAdapter genEnumGeneratorAdapter
Constructor Detail

GenModelGeneratorAdapterFactory

public GenModelGeneratorAdapterFactory()
Method Detail

isFactoryForType

public boolean isFactoryForType(Object type)
Returns true when the type is GeneratorAdapter.class.

Specified by:
isFactoryForType in interface AdapterFactory
Overrides:
isFactoryForType in class GenModelAdapterFactory
Returns:
whether this factory is applicable for the type of the object.

adapt

public Adapter adapt(Notifier target,
                     Object type)
Does an adapt(Notifier, Object), substituting this for the given type. This substitution is necessary because each of many generator adapter factories can have its own generator adapter on a single object.

Specified by:
adapt in interface AdapterFactory
Overrides:
adapt in class AdapterFactoryImpl

createGenModelAdapter

public Adapter createGenModelAdapter()
Returns a singleton GenModelGeneratorAdapter.

Overrides:
createGenModelAdapter in class GenModelAdapterFactory
Returns:
the new adapter.
See Also:
GenModel

createGenPackageAdapter

public Adapter createGenPackageAdapter()
Returns a singleton GenPackageGeneratorAdapter.

Overrides:
createGenPackageAdapter in class GenModelAdapterFactory
Returns:
the new adapter.
See Also:
GenPackage

createGenClassAdapter

public Adapter createGenClassAdapter()
Returns a singleton GenClassGeneratorAdapter.

Overrides:
createGenClassAdapter in class GenModelAdapterFactory
Returns:
the new adapter.
See Also:
GenClass

createGenEnumAdapter

public Adapter createGenEnumAdapter()
Returns a singleton GenEnumGeneratorAdapter.

Overrides:
createGenEnumAdapter in class GenModelAdapterFactory
Returns:
the new adapter.
See Also:
GenEnum

getGenerator

public Generator getGenerator()
Description copied from interface: GeneratorAdapterFactory
Returns the Generator associated with this adapter factory.

Specified by:
getGenerator in interface GeneratorAdapterFactory
See Also:
GeneratorAdapterFactory.setGenerator(Generator)

setGenerator

public void setGenerator(Generator generator)
Description copied from interface: GeneratorAdapterFactory
Sets the Generator associated with this adapter factory.

Specified by:
setGenerator in interface GeneratorAdapterFactory
See Also:
GeneratorAdapterFactory.getGenerator()

initialize

public void initialize(Object input)
Performs initialization for the given input GenModel. It is used as the basis for setting options on the associated Generator.

Specified by:
initialize in interface GeneratorAdapterFactory

getTemplatePath

protected String[] getTemplatePath(GenModel genModel)
Deprecated. org.eclipse.emf.codegen.ecore 2.2.2 Override AbstractGeneratorAdapter.addBaseTemplatePathEntries(java.util.List) and, if needed, getMergeRulesURI(GenModel), instead.

Computes the template path for the given GenModel. The result of this method was intended to be used in setting the generator's templatePath option. However, a single path for all code generation is actually insufficient. The path needs to be specified and extended on a per-adapter basis.

If this implementation is not overridden, the generator's templatePath will no longer be set to the default value. Instead, it will be left null, and template paths will be computed on a per-adapter basis using AbstractGeneratorAdapter.addBaseTemplatePathEntries(java.util.List).

In order to preserve backwards compatibility, if this implementation is overridden to return something other than the default, the generator's templatePath will be set to this result.

Previously, this path was also searched to obtain the value to set as the generator's mergeRulesURI option. Now, if this method is not overridden, the new getMergeRulesURI(GenModel) method will be invoked to compute that value.


getMergeRulesURI

protected String getMergeRulesURI(GenModel genModel)
Returns the URI of the merge rules file for the given GenModel.

The default implementation of this method is to search the default path that would be returned by getTemplatePath(GenModel), if not overridden, for a file called "emf-merge.xml", and return the URI of the first such file encontered. Since that method has been deprecated, this method can now be overridden to search a different path, or indeed, obtain the merge rules URI in some other way.

This method is only invoked if getTemplatePath(GenModel) has not been overridden. To maintain compatibility with 2.2.1, it should not be invoked by subclasses, except from its own overrides. Nor should such overrides be invoked.

Since:
org.eclipse.emf.codegen.ecore 2.2.2

dispose

public void dispose()
Description copied from interface: GeneratorAdapterFactory
Disposes this adapter factory and all of the adapters it has created.

Specified by:
dispose in interface GeneratorAdapterFactory

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