org.argouml.uml.generator
Class GeneratorManager

java.lang.Object
  extended byorg.argouml.uml.generator.GeneratorManager

public final class GeneratorManager
extends Object

Keeps an instance of each CodeGenerator implementation module registered, associated with a language name. Also remembers the currently selected language. GeneratorManager is a singleton.


Method Summary
 void addGenerator(Language lang, CodeGenerator gen)
          Registers a new generator.
 Language findLanguage(String name)
          Find a language by name from the available ones.
static String getCodePath(Object me)
          Gets the path of the code base for a model element.
 CodeGenerator getCurrGenerator()
           
 Language getCurrLanguage()
           
 CodeGenerator getGenerator(Language lang)
          Access method that finds the correct generator based on a name.
 CodeGenerator getGenerator(String name)
           
 Map getGenerators()
           
static GeneratorManager getInstance()
           
 Set getLanguages()
           
 CodeGenerator removeGenerator(Language lang)
          Removes a generator.
 CodeGenerator removeGenerator(String name)
          Removes the generator associated with the specified language.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static GeneratorManager getInstance()
Returns:
The singleton instance of the generator manager.

addGenerator

public void addGenerator(Language lang,
                         CodeGenerator gen)
Registers a new generator. If a generator with the same language is already registered, it's replaced by the new one.

Parameters:
lang - The language.
gen - The CodeGenerator object to register.

removeGenerator

public CodeGenerator removeGenerator(Language lang)
Removes a generator. If no generator with that name is registered, nothing is done.

Parameters:
lang - The language. Shall not be null.
Returns:
The old generator being removed or null.

removeGenerator

public CodeGenerator removeGenerator(String name)
Removes the generator associated with the specified language.

Parameters:
name - The language name.
Returns:
The old generator, or null if there wasn't any.

getGenerator

public CodeGenerator getGenerator(Language lang)
Access method that finds the correct generator based on a name.

Parameters:
lang - The language.
Returns:
a CodeGenerator (or null if not found).

getGenerator

public CodeGenerator getGenerator(String name)
Parameters:
name - The name of the language,
Returns:
a CodeGenerator (or null if not found).

getCurrLanguage

public Language getCurrLanguage()
Returns:
the current language name, or null if there are no generator registered at all.

getCurrGenerator

public CodeGenerator getCurrGenerator()
Returns:
the current generator, or null if there are no generator registered at all.

getGenerators

public Map getGenerators()
Returns:
A copy of the map of the generators. The map keys Language objects, and values are CodeGenerator objects.

getLanguages

public Set getLanguages()
Returns:
A copy of the Set of the languages.

findLanguage

public Language findLanguage(String name)
Find a language by name from the available ones.

Parameters:
name - The name of the language
Returns:
The language with the specified name, or null if it doesn't exist.

getCodePath

public static String getCodePath(Object me)
Gets the path of the code base for a model element.

If empty or not existing return null.

Parameters:
me - The model element
Returns:
String representation of "src_path" tagged value.


ArgoUML © 1996-2006ArgoUML HomepageArgoUML Developers' pageArgoUML Cookbook