org.eclipse.emf.codegen.ecore.generator
Interface GeneratorAdapter

All Known Implementing Classes:
AbstractGeneratorAdapter, GenBaseGeneratorAdapter, GenClassGeneratorAdapter, GenEnumGeneratorAdapter, GenModelGeneratorAdapter, GenPackageGeneratorAdapter

public interface GeneratorAdapter

An adapter that performs code generation for a Generator.

A GeneratorAdapter implementation performs code generation for a single type of model object. It is created by a GeneratorAdapterFactory and used by its containing Generator. Several different generator adapters can be associated with a single object, with each one contributing functionality to the code generation for that object. A singleton pattern is usually used for generator adapters, where a single instance of an adapter type is shared by all instances of the same object type.

A generator adapter is primarily responsible for two aspects of two tasks. The tasks are:

The two aspects of these tasks are:

In all cases, a project type can be used to identify a subset of the code generation for the given object. This is an arbitrary object that should be meaningful to the particular generator adapter.

See Generator.canGenerate(Object, Object) and Generator.generate(Object, Object, String, Monitor) for detailed descriptions of the protocol by which generator adapters are actually used to complete the two tasks.

Since:
2.2.0
See Also:
Generator.canGenerate(Object, Object), Generator.generate(Object, Object, String, Monitor)

Method Summary
 boolean canGenerate(java.lang.Object object, java.lang.Object projectType)
          Returns whether code of the given object type can be generated for the specified object.
 void dispose()
          Removes the adapter from its Notifiers and performs any other needed disposal.
 Diagnostic generate(java.lang.Object object, java.lang.Object projectType, Monitor monitor)
          Generates code for the given object and project type.
 GeneratorAdapterFactory getAdapterFactory()
          Returns the adapter factory that created this adapter.
 java.util.Collection<?> getCanGenerateChildren(java.lang.Object object, java.lang.Object projectType)
          Returns any children of the specified object that are relevant to determining whether code, of the given project type, can be generated for the specified object.
 java.lang.Object getCanGenerateParent(java.lang.Object object, java.lang.Object projectType)
          Returns the parent of the specified object if it is relevant to determining whether code, of the given project type, can be generated for the specified object.
 java.util.Collection<?> getGenerateChildren(java.lang.Object object, java.lang.Object projectType)
          Returns any children of the specified object for which code of the given project type may be generated.
 java.lang.Object getGenerateParent(java.lang.Object object, java.lang.Object projectType)
          Returns the parent of the specified object if code of the given project type may be generated for it.
 Diagnostic postGenerate(java.lang.Object object, java.lang.Object projectType)
          Called after all code is generated for the object and/or any of its parents and/or children, in order to give the adapter a chance to perform cleanup from the code generation.
 Diagnostic preGenerate(java.lang.Object object, java.lang.Object projectType)
          Called before any code is generated for the object and/or any of its parents and/or children, in order to give the adapter a chance to perform setup for the code generation.
 void setAdapterFactory(GeneratorAdapterFactory adapterFactory)
          Sets the adapter factory that created this adapter.
 

Method Detail

getAdapterFactory

GeneratorAdapterFactory getAdapterFactory()
Returns the adapter factory that created this adapter.

See Also:
setAdapterFactory(GeneratorAdapterFactory)

setAdapterFactory

void setAdapterFactory(GeneratorAdapterFactory adapterFactory)
Sets the adapter factory that created this adapter. If the constructor for the adapter does not set the adapter factory, this method can be called immediately after the adapter is created.

See Also:
getAdapterFactory()

getCanGenerateChildren

java.util.Collection<?> getCanGenerateChildren(java.lang.Object object,
                                               java.lang.Object projectType)
Returns any children of the specified object that are relevant to determining whether code, of the given project type, can be generated for the specified object.


getCanGenerateParent

java.lang.Object getCanGenerateParent(java.lang.Object object,
                                      java.lang.Object projectType)
Returns the parent of the specified object if it is relevant to determining whether code, of the given project type, can be generated for the specified object.


canGenerate

boolean canGenerate(java.lang.Object object,
                    java.lang.Object projectType)
Returns whether code of the given object type can be generated for the specified object.


getGenerateChildren

java.util.Collection<?> getGenerateChildren(java.lang.Object object,
                                            java.lang.Object projectType)
Returns any children of the specified object for which code of the given project type may be generated.


getGenerateParent

java.lang.Object getGenerateParent(java.lang.Object object,
                                   java.lang.Object projectType)
Returns the parent of the specified object if code of the given project type may be generated for it.


preGenerate

Diagnostic preGenerate(java.lang.Object object,
                       java.lang.Object projectType)
Called before any code is generated for the object and/or any of its parents and/or children, in order to give the adapter a chance to perform setup for the code generation.


generate

Diagnostic generate(java.lang.Object object,
                    java.lang.Object projectType,
                    Monitor monitor)
Generates code for the given object and project type. Because this is a long-running operation, the monitor is used to report progress.


postGenerate

Diagnostic postGenerate(java.lang.Object object,
                        java.lang.Object projectType)
Called after all code is generated for the object and/or any of its parents and/or children, in order to give the adapter a chance to perform cleanup from the code generation.


dispose

void dispose()
Removes the adapter from its Notifiers and performs any other needed disposal.


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