org.argouml.uml.generator
Class Generator

java.lang.Object
  extended byorg.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
static java.lang.String INDENT
          Two spaces used for indenting code in classes.
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(ru.novosoft.uml.foundation.core.MAssociation a)
           
abstract  java.lang.String generateAssociationEnd(ru.novosoft.uml.foundation.core.MAssociationEnd ae)
           
abstract  java.lang.String generateAttribute(ru.novosoft.uml.foundation.core.MAttribute attr, boolean documented)
           
abstract  java.lang.String generateClassifier(ru.novosoft.uml.foundation.core.MClassifier cls)
           
 java.lang.String generateClassifierRef(ru.novosoft.uml.foundation.core.MClassifier cls)
           
 java.lang.String generateExpression(ru.novosoft.uml.foundation.core.MConstraint expr)
           
 java.lang.String generateExpression(ru.novosoft.uml.foundation.data_types.MExpression expr)
           
abstract  java.lang.String generateExtensionPoint(ru.novosoft.uml.behavior.use_cases.MExtensionPoint op)
           
abstract  java.lang.String generateGuard(ru.novosoft.uml.behavior.state_machines.MGuard m)
           
abstract  java.lang.String generateMessage(ru.novosoft.uml.behavior.collaborations.MMessage m)
           
abstract  java.lang.String generateMultiplicity(ru.novosoft.uml.foundation.data_types.MMultiplicity m)
           
 java.lang.String generateName(java.lang.String n)
           
abstract  java.lang.String generateOperation(ru.novosoft.uml.foundation.core.MOperation op, boolean documented)
           
abstract  java.lang.String generatePackage(ru.novosoft.uml.model_management.MPackage p)
           
abstract  java.lang.String generateParameter(ru.novosoft.uml.foundation.core.MParameter param)
           
abstract  java.lang.String generateState(ru.novosoft.uml.behavior.state_machines.MState m)
           
 java.lang.String generateStereotype(ru.novosoft.uml.foundation.extension_mechanisms.MStereotype st)
           
abstract  java.lang.String generateTaggedValue(ru.novosoft.uml.foundation.extension_mechanisms.MTaggedValue s)
           
abstract  java.lang.String generateTransition(ru.novosoft.uml.behavior.state_machines.MTransition m)
           
 java.lang.String generateUninterpreted(java.lang.String un)
           
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)
           
 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()
           
 boolean isModuleEnabled()
          Deprecated. must be added to all leaf classes from this class, these are the modules not this abstract class
 boolean isTestModus()
          Returns the _testModus.
 void setModuleEnabled(boolean enabled)
           
 void setTestModus(boolean _testModus)
          Sets the _testModus.
 boolean shutdownModule()
           
 
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

INDENT

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


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(ru.novosoft.uml.behavior.use_cases.MExtensionPoint op)
Specified by:
generateExtensionPoint in interface NotationProvider

generateOperation

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

generateAttribute

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

generateParameter

public abstract java.lang.String generateParameter(ru.novosoft.uml.foundation.core.MParameter param)
Specified by:
generateParameter in interface NotationProvider

generatePackage

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

generateClassifier

public abstract java.lang.String generateClassifier(ru.novosoft.uml.foundation.core.MClassifier cls)
Specified by:
generateClassifier in interface NotationProvider

generateTaggedValue

public abstract java.lang.String generateTaggedValue(ru.novosoft.uml.foundation.extension_mechanisms.MTaggedValue s)
Specified by:
generateTaggedValue in interface NotationProvider

generateAssociation

public abstract java.lang.String generateAssociation(ru.novosoft.uml.foundation.core.MAssociation a)
Specified by:
generateAssociation in interface NotationProvider

generateAssociationEnd

public abstract java.lang.String generateAssociationEnd(ru.novosoft.uml.foundation.core.MAssociationEnd ae)
Specified by:
generateAssociationEnd in interface NotationProvider

generateMultiplicity

public abstract java.lang.String generateMultiplicity(ru.novosoft.uml.foundation.data_types.MMultiplicity m)
Specified by:
generateMultiplicity in interface NotationProvider

generateState

public abstract java.lang.String generateState(ru.novosoft.uml.behavior.state_machines.MState m)
Specified by:
generateState in interface NotationProvider

generateTransition

public abstract java.lang.String generateTransition(ru.novosoft.uml.behavior.state_machines.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(ru.novosoft.uml.behavior.state_machines.MGuard m)
Specified by:
generateGuard in interface NotationProvider

generateMessage

public abstract java.lang.String generateMessage(ru.novosoft.uml.behavior.collaborations.MMessage m)
Specified by:
generateMessage in interface NotationProvider

generateExpression

public java.lang.String generateExpression(ru.novosoft.uml.foundation.data_types.MExpression expr)
Specified by:
generateExpression in interface NotationProvider

generateExpression

public java.lang.String generateExpression(ru.novosoft.uml.foundation.core.MConstraint expr)

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(ru.novosoft.uml.foundation.core.MClassifier cls)
Specified by:
generateClassifierRef in interface NotationProvider

generateStereotype

public java.lang.String generateStereotype(ru.novosoft.uml.foundation.extension_mechanisms.MStereotype st)
Specified by:
generateStereotype in interface NotationProvider

getModulePopUpActions

public java.util.Vector getModulePopUpActions(java.util.Vector v,
                                              java.lang.Object o)
Specified by:
getModulePopUpActions in interface ArgoModule

shutdownModule

public boolean shutdownModule()
Specified by:
shutdownModule in interface ArgoModule

initializeModule

public boolean initializeModule()
Specified by:
initializeModule in interface ArgoModule

setModuleEnabled

public void setModuleEnabled(boolean enabled)
Specified by:
setModuleEnabled in interface ArgoModule

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

isModuleEnabled

public boolean isModuleEnabled()
Deprecated. must be added to all leaf classes from this class, these are the modules not this abstract class

Specified by:
isModuleEnabled in interface ArgoModule
See Also:
ArgoModule.isModuleEnabled()


ArgoUML © 1996-2003 (20030829)ArgoUML Project HomeArgoUML Cookbook