org.argouml.uml.generator
Class Generator

java.lang.Object
  |
  +--org.argouml.uml.generator.Generator
All Implemented Interfaces:
ArgoModule, NotationProvider, Pluggable, PluggableNotation
Direct Known Subclasses:
GeneratorDisplay, GeneratorJava

public abstract class Generator
extends java.lang.Object
implements NotationProvider, PluggableNotation

This class is the abstract super class that defines a code generation framework. It is basically a depth-first traversal of the UML model that generates strings as it goes. This framework should probably be redesigned to separate the traversal logic from the generation logic. See the Vistor design pattern in "Design Patterns", and the Demeter project.


Field Summary
private  NotationName _notationName
           
private  boolean _testModus
          Special modus for testing using the JUnit module.
static java.lang.String INDENT
          Two spaces used for indenting code in classes.
private static java.util.Map s_generators
           
static java.lang.String TEST_SUFFIX
          suffix placed behind the tag defining a testcase for an element to be generated
 
Fields inherited from interface org.argouml.application.api.Pluggable
PLUGIN_PREFIX, PLUGIN_TITLE, PLUGIN_VENDOR
 
Fields inherited from interface org.argouml.application.api.ArgoModule
cat, MODULEFILENAME, MODULEFILENAME_ALTERNATE
 
Constructor Summary
Generator(NotationName notationName)
           
 
Method Summary
 java.lang.String generate(java.lang.Object o)
          Generates code for some modelelement.
abstract  java.lang.String generateAction(java.lang.Object m)
           
abstract  java.lang.String generateAssociation(MAssociation a)
           
abstract  java.lang.String generateAssociationEnd(MAssociationEnd ae)
           
abstract  java.lang.String generateAttribute(MAttribute attr, boolean documented)
           
abstract  java.lang.String generateClassifier(MClassifier cls)
           
 java.lang.String generateClassifierRef(java.lang.Object cls)
           
 java.lang.String generateExpression(MExpression expr)
           
abstract  java.lang.String generateExtensionPoint(MExtensionPoint op)
           
abstract  java.lang.String generateGuard(MGuard m)
           
abstract  java.lang.String generateMessage(MMessage m)
           
abstract  java.lang.String generateMultiplicity(MMultiplicity m)
           
 java.lang.String generateName(java.lang.String n)
           
abstract  java.lang.String generateOperation(MOperation op, boolean documented)
           
abstract  java.lang.String generatePackage(MPackage p)
           
abstract  java.lang.String generateParameter(MParameter param)
           
abstract  java.lang.String generateState(MState m)
           
 java.lang.String generateStereotype(MStereotype st)
           
abstract  java.lang.String generateTaggedValue(MTaggedValue s)
           
abstract  java.lang.String generateTransition(MTransition m)
           
 java.lang.String generateUninterpreted(java.lang.String un)
           
abstract  java.lang.String generateVisibility(MVisibilityKind visibility)
           
static java.lang.String getCodePath(java.lang.Object me)
          Gets the path of the code base for a model element, otherwise null.
static Generator getGenerator(NotationName n)
           
 java.util.Vector getModulePopUpActions(java.util.Vector v, java.lang.Object o)
          Calls all modules to let them add to a popup menu.
 NotationName getNotation()
           
 boolean inContext(java.lang.Object[] o)
          A function which allows a plug-in to decide if it is available under a specific context.
 boolean initializeModule()
          Method called when Argo is loading a module.
 boolean isModuleEnabled()
          The default for any Generator is to be enabled.
 boolean isTestModus()
          Returns the _testModus.
 void setModuleEnabled(boolean enabled)
          Called to enable or disable a module programmatically.
 void setTestModus(boolean _testModus)
          Sets the _testModus.
 boolean shutdownModule()
          Method called when Argo is unloading a module.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.argouml.application.api.NotationProvider
canParse, canParse, generateAssociationRole, generateStateBody
 
Methods inherited from interface org.argouml.application.api.ArgoModule
getModuleAuthor, getModuleDescription, getModuleKey, getModuleName, getModuleVersion
 

Field Detail

_testModus

private boolean _testModus
Special modus for testing using the JUnit module.


_notationName

private NotationName _notationName

INDENT

public static java.lang.String INDENT
Two spaces used for indenting code in classes.


s_generators

private static java.util.Map s_generators

TEST_SUFFIX

public static final java.lang.String TEST_SUFFIX
suffix placed behind the tag defining a testcase for an element to be generated

See Also:
Constant Field Values
Constructor Detail

Generator

public Generator(NotationName notationName)
Method Detail

getGenerator

public static Generator getGenerator(NotationName n)

getNotation

public NotationName getNotation()
Specified by:
getNotation in interface NotationProvider

generate

public java.lang.String generate(java.lang.Object o)
Generates code for some modelelement. Subclasses should implement this to generate code for different notations.

Parameters:
o - the element to be generated
Returns:
String the generated code

generateExtensionPoint

public abstract java.lang.String generateExtensionPoint(MExtensionPoint op)
Specified by:
generateExtensionPoint in interface NotationProvider

generateOperation

public abstract java.lang.String generateOperation(MOperation op,
                                                   boolean documented)
Specified by:
generateOperation in interface NotationProvider

generateAttribute

public abstract java.lang.String generateAttribute(MAttribute attr,
                                                   boolean documented)
Specified by:
generateAttribute in interface NotationProvider

generateParameter

public abstract java.lang.String generateParameter(MParameter param)
Specified by:
generateParameter in interface NotationProvider

generatePackage

public abstract java.lang.String generatePackage(MPackage p)
Specified by:
generatePackage in interface NotationProvider

generateClassifier

public abstract java.lang.String generateClassifier(MClassifier cls)
Specified by:
generateClassifier in interface NotationProvider

generateTaggedValue

public abstract java.lang.String generateTaggedValue(MTaggedValue s)
Specified by:
generateTaggedValue in interface NotationProvider

generateAssociation

public abstract java.lang.String generateAssociation(MAssociation a)
Specified by:
generateAssociation in interface NotationProvider

generateAssociationEnd

public abstract java.lang.String generateAssociationEnd(MAssociationEnd ae)
Specified by:
generateAssociationEnd in interface NotationProvider

generateMultiplicity

public abstract java.lang.String generateMultiplicity(MMultiplicity m)
Specified by:
generateMultiplicity in interface NotationProvider

generateState

public abstract java.lang.String generateState(MState m)
Specified by:
generateState in interface NotationProvider

generateTransition

public abstract java.lang.String generateTransition(MTransition m)
Specified by:
generateTransition in interface NotationProvider

generateAction

public abstract java.lang.String generateAction(java.lang.Object m)
Specified by:
generateAction in interface NotationProvider

generateGuard

public abstract java.lang.String generateGuard(MGuard m)
Specified by:
generateGuard in interface NotationProvider

generateMessage

public abstract java.lang.String generateMessage(MMessage m)
Specified by:
generateMessage in interface NotationProvider

generateVisibility

public abstract java.lang.String generateVisibility(MVisibilityKind visibility)
Specified by:
generateVisibility in interface NotationProvider

generateExpression

public java.lang.String generateExpression(MExpression expr)
Specified by:
generateExpression in interface NotationProvider

generateName

public java.lang.String generateName(java.lang.String n)
Specified by:
generateName in interface NotationProvider

generateUninterpreted

public java.lang.String generateUninterpreted(java.lang.String un)

generateClassifierRef

public java.lang.String generateClassifierRef(java.lang.Object cls)
Specified by:
generateClassifierRef in interface NotationProvider

generateStereotype

public java.lang.String generateStereotype(MStereotype st)
Specified by:
generateStereotype in interface NotationProvider

getModulePopUpActions

public java.util.Vector getModulePopUpActions(java.util.Vector v,
                                              java.lang.Object o)
Description copied from interface: ArgoModule
Calls all modules to let them add to a popup menu.

Specified by:
getModulePopUpActions in interface ArgoModule
Parameters:
v - Vector of actions
o - which the actions are valid for

shutdownModule

public boolean shutdownModule()
Description copied from interface: ArgoModule
Method called when Argo is unloading a module.

Specified by:
shutdownModule in interface ArgoModule
Returns:
true if the module terminated properly.

initializeModule

public boolean initializeModule()
Description copied from interface: ArgoModule
Method called when Argo is loading a module.

Specified by:
initializeModule in interface ArgoModule
Returns:
true if the module initialized properly.

setModuleEnabled

public void setModuleEnabled(boolean enabled)
Description copied from interface: ArgoModule
Called to enable or disable a module programmatically.

Specified by:
setModuleEnabled in interface ArgoModule
Parameters:
enabled - true to enable module, false to disable

inContext

public boolean inContext(java.lang.Object[] o)
Description copied from interface: Pluggable
A function which allows a plug-in to decide if it is available under a specific context. One example of a plugin with multiple criteria is the PluggableMenu. PluggableMenu requires the first context to be a JMenuItem which wants the PluggableMenu attached to as the context, so that it can determine that it would attach to a menu. The second context is an internal (non-localized) description of the menu such as "File" or "View" so that the plugin can further decide.

Specified by:
inContext in interface Pluggable
Parameters:
o - An identification of the context. The interpretation of criteria is specific to the plug-in type, but must be consistent across that type. The plug-in must want to be exposed to all contexts.
Returns:
True if the plug-in wants to make itself available for this context, otherwise false.

isTestModus

public boolean isTestModus()
Returns the _testModus.

Returns:
boolean

setTestModus

public void setTestModus(boolean _testModus)
Sets the _testModus.

Parameters:
_testModus - The _testModus to set

getCodePath

public static java.lang.String getCodePath(java.lang.Object me)
Gets the path of the code base for a model element, otherwise null.

Parameters:
me - The model element
Returns:
String representation of "src_path" tagged value or null if empty or not existing

isModuleEnabled

public boolean isModuleEnabled()
The default for any Generator is to be enabled.

Specified by:
isModuleEnabled in interface ArgoModule
Returns:
that this module is enabled.
See Also:
ArgoModule.isModuleEnabled()


ArgoUML © 1996-2004 (20040306)ArgoUML HomepageArgoUML Developers' pageArgoUML Cookbook