org.argouml.uml.generator
Class GeneratorDisplay

java.lang.Object
  extended byorg.argouml.uml.generator.Generator2
      extended byorg.argouml.uml.generator.GeneratorDisplay
All Implemented Interfaces:
ArgoModule, NotationProvider2, Pluggable, PluggableNotation

public class GeneratorDisplay
extends Generator2

Generator2 subclass to generate code for display in diagrams in text fields in the ArgoUML user interface. The generated code looks a lot like (invalid) Java. The idea is that other generators could be written for other languages. This code is just a placeholder for future development, I expect it to be totally replaced.

TODO: always check for null!!!


Nested Class Summary
(package private)  class GeneratorDisplay.MsgPtr
           
 
Field Summary
static String ANY_RANGE
          ANY_RANGE stands for "0..*".
private static GeneratorDisplay singleton
           
 
Fields inherited from class org.argouml.uml.generator.Generator2
INDENT
 
Fields inherited from interface org.argouml.application.api.Pluggable
PLUGIN_PREFIX, PLUGIN_TITLE, PLUGIN_VENDOR
 
Fields inherited from interface org.argouml.application.api.ArgoModule
MODULEFILENAME, MODULEFILENAME_ALTERNATE
 
Constructor Summary
private GeneratorDisplay()
          The constructor.
 
Method Summary
(package private)  int countSuccessors(Object m)
           
 String generateAction(Object m)
          Generate the String representation for an Action.
 String generateActionState(Object actionState)
          Generate the String representation for an Action State.
 String generateAssociation(Object a)
          Generate the String representation for an Association.
 String generateAssociationEnd(Object ae)
          Generate the String representation for an AssociationEnd.
 String generateAssociationFrom(Object a, Object ae)
           
 String generateAssociationRole(Object assocRole)
          generate the name of an association role of the form: / name : name of the base association.
 String generateAttribute(Object attr, boolean documented)
          Generates a string representation for the provided attribute.
 String generateChangability(Object sf)
           
 String generateClassifier(Object cls)
          Generate the String representation for a Classifier.
 String generateClassList(Collection classifiers)
           
 String generateConstraint(Object c)
           
 String generateConstraints(Object me)
           
 String generateEvent(Object m)
          Generates the text for a (trigger) event.
 String generateExtensionPoint(Object ep)
          Generate the display for an extension point.
private  String generateGeneralization(Collection generalizations, boolean impl)
           
 String generateGuard(Object m)
          Generate the String representation for a Guard.
private  String generateKind(Object kind)
           
 String generateMessage(Object m)
          Generates a textual description for a MMessage m.
 String generateMessageNumber(Object m)
          Generates the textual number of MMessage m.
private  String generateMessageNumber(Object m, Object pre, int position)
           
 String generateMultiplicity(Object m)
          Generate the String representation for an Multiplicity.
protected  String generateMultiplicityRange(Object mr)
          Generates a multiplicity range.
 String generateObjectFlowState(Object m)
          Generate the String representation for a ObjectFlowState.
 String generateOperation(Object op, boolean documented)
          Generates an operation according to the UML 1.3 notation: stereotype visibility name (parameter-list) : return-type-expression {property-string} For the return-type-expression: only the types of the return parameters are shown.
 String generatePackage(Object p)
          Generate the String representation for a Package.
 String generateParameter(Object parameter)
          Generates the representation of a parameter on the display (diagram).
private  String generateParameterList(Object parameterListOwner)
          Generates a list of parameters.
 String generateRecurrence(Object expr)
          Generates a textual description of a MIterationExpression.
 String generateScope(Object f)
           
 String generateState(Object m)
          Generate the String representation for a State.
 String generateStateBody(Object m)
          Generate the String representation for a StateBody.
 String generateSubmachine(Object m)
          Generate the String representation for a Submachine.
 String generateTaggedValue(Object tv)
          Generate the String representation for a TaggedValue.
 String generateTransition(Object m)
          Generate the String representation for a Transition.
 String generateVisibility(Object o)
          Returns a visibility String eihter for a MVisibilityKind (according to the definition in NotationProvider2), but also for a model element.
static GeneratorDisplay getInstance()
           
 String getModuleAuthor()
          The module author.
 String getModuleDescription()
          Textual description of the module.
 String getModuleKey()
          The module identifying key.
 String getModuleName()
          Display name of the module.
 String getModuleVersion()
          The module version.
 boolean inContext(Object[] o)
          A function which allows a plug-in to decide if it is available under a specific context.
 boolean isModuleEnabled()
          The default for any Generator is to be enabled.
(package private)  int recCountPredecessors(Object message, GeneratorDisplay.MsgPtr ptr)
           
 
Methods inherited from class org.argouml.uml.generator.Generator2
generate, generateClassifierRef, generateExpression, generateName, generateStereotype, generateUninterpreted, getCodePath, getGenerator, getModulePopUpActions, getNotation, initializeModule, setModuleEnabled, shutdownModule
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

singleton

private static GeneratorDisplay singleton

ANY_RANGE

public static final String ANY_RANGE
ANY_RANGE stands for "0..*".

See Also:
Constant Field Values
Constructor Detail

GeneratorDisplay

private GeneratorDisplay()
The constructor.

Method Detail

getInstance

public static GeneratorDisplay getInstance()
Returns:
get the singleton

generateExtensionPoint

public String generateExtensionPoint(Object ep)
Generate the display for an extension point.

The representation is "name: location". "name: " is omitted if there is no name given.

Specified by:
generateExtensionPoint in interface NotationProvider2
Specified by:
generateExtensionPoint in class Generator2
Parameters:
ep - The extension point.
Returns:
The string representing the extension point.
See Also:
NotationProvider2.generateExtensionPoint(Object)

generateOperation

public String generateOperation(Object op,
                                boolean documented)
Generates an operation according to the UML 1.3 notation: stereotype visibility name (parameter-list) : return-type-expression {property-string} For the return-type-expression: only the types of the return parameters are shown. Depending on settings in Notation, visibility and properties are shown/not shown.

Specified by:
generateOperation in interface NotationProvider2
Specified by:
generateOperation in class Generator2
See Also:
NotationProvider2.generateOperation( Object, boolean)

generateAttribute

public String generateAttribute(Object attr,
                                boolean documented)
Generates a string representation for the provided attribute. The string representation will be of the form: visibility name [multiplicity] : type-expression = initial-value {property-string} Depending on settings in Notation, visibility, multiplicity, initial value and properties are shown/not shown.

Specified by:
generateAttribute in interface NotationProvider2
Specified by:
generateAttribute in class Generator2
See Also:
NotationProvider2.generateAttribute( Object, boolean)

generateParameter

public String generateParameter(Object parameter)
Generates the representation of a parameter on the display (diagram). The string to be returned will have the following syntax:

kind name : type-expression = default-value

Specified by:
generateParameter in interface NotationProvider2
Specified by:
generateParameter in class Generator2
See Also:
NotationProvider2.generateParameter(java.lang.Object)

generatePackage

public String generatePackage(Object p)
Description copied from interface: NotationProvider2
Generate the String representation for a Package.

Specified by:
generatePackage in interface NotationProvider2
Specified by:
generatePackage in class Generator2
See Also:
NotationProvider2.generatePackage(java.lang.Object)

generateClassifier

public String generateClassifier(Object cls)
Description copied from interface: NotationProvider2
Generate the String representation for a Classifier.

Specified by:
generateClassifier in interface NotationProvider2
Specified by:
generateClassifier in class Generator2
See Also:
NotationProvider2.generateClassifier(java.lang.Object)

generateTaggedValue

public String generateTaggedValue(Object tv)
Description copied from interface: NotationProvider2
Generate the String representation for a TaggedValue.

Specified by:
generateTaggedValue in interface NotationProvider2
Specified by:
generateTaggedValue in class Generator2
See Also:
NotationProvider2.generateTaggedValue(java.lang.Object)

generateMessageNumber

public String generateMessageNumber(Object m)
Generates the textual number of MMessage m. The number is a string of numbers separated by points which describes the message's order and level in a collaboration.

If you plan to modify this number, make sure that ParserDisplay.parseMessage is adapted to the change.

Parameters:
m - A Message to generate the number for.
Returns:
A String with the message number of m.

generateKind

private String generateKind(Object kind)

generateMessageNumber

private String generateMessageNumber(Object m,
                                     Object pre,
                                     int position)

recCountPredecessors

int recCountPredecessors(Object message,
                         GeneratorDisplay.MsgPtr ptr)

countSuccessors

int countSuccessors(Object m)

generateRecurrence

public String generateRecurrence(Object expr)
Generates a textual description of a MIterationExpression.

Parameters:
expr - the given expression
Returns:
the string

generateMessage

public String generateMessage(Object m)
Generates a textual description for a MMessage m.

Specified by:
generateMessage in interface NotationProvider2
Specified by:
generateMessage in class Generator2
Parameters:
m - A MMessage to generate a description for.
Returns:
A String suitable to show in a collaboration diagram.
See Also:
NotationProvider2.generateMessage(Object)

generateAssociationFrom

public String generateAssociationFrom(Object a,
                                      Object ae)
Parameters:
a - the association
ae - the associationend
Returns:
a string representing the association-end

generateAssociation

public String generateAssociation(Object a)
Description copied from interface: NotationProvider2
Generate the String representation for an Association.

Specified by:
generateAssociation in interface NotationProvider2
Specified by:
generateAssociation in class Generator2
See Also:
NotationProvider2.generateAssociation(java.lang.Object)

generateAssociationEnd

public String generateAssociationEnd(Object ae)
Description copied from interface: NotationProvider2
Generate the String representation for an AssociationEnd.

Specified by:
generateAssociationEnd in interface NotationProvider2
Specified by:
generateAssociationEnd in class Generator2
See Also:
NotationProvider2.generateAssociationEnd(java.lang.Object)

generateConstraints

public String generateConstraints(Object me)
Parameters:
me - the given ModelElement
Returns:
a string representing the constraints for the given modelelements

generateConstraint

public String generateConstraint(Object c)
Parameters:
c - the given constraint
Returns:
a string representing the given constraint

generateAssociationRole

public String generateAssociationRole(Object assocRole)
generate the name of an association role of the form: / name : name of the base association.

Parameters:
assocRole - the given associationrole
Returns:
the generated name
See Also:
NotationProvider2.generateAssociationRole(java.lang.Object)

generateGeneralization

private String generateGeneralization(Collection generalizations,
                                      boolean impl)
Parameters:
generalizations - the given collection of generalizations
impl -
Returns:
a string representing the g.

generateClassList

public String generateClassList(Collection classifiers)
Parameters:
classifiers - the given collection of classifiers
Returns:
the names, separated by commas

generateVisibility

public String generateVisibility(Object o)
Returns a visibility String eihter for a MVisibilityKind (according to the definition in NotationProvider2), but also for a model element.

Specified by:
generateVisibility in interface NotationProvider2
Specified by:
generateVisibility in class Generator2
See Also:
NotationProvider2.generateVisibility(java.lang.Object)

generateScope

public String generateScope(Object f)
Parameters:
f - the given feature
Returns:
a string representing the scope of the feature or ""

generateChangability

public String generateChangability(Object sf)
Parameters:
sf - the given structural feature
Returns:
a string representing the scope of the structural feature or ""

generateMultiplicity

public String generateMultiplicity(Object m)
Description copied from interface: NotationProvider2
Generate the String representation for an Multiplicity.

Specified by:
generateMultiplicity in interface NotationProvider2
Specified by:
generateMultiplicity in class Generator2
See Also:
NotationProvider2.generateMultiplicity( Object)

generateMultiplicityRange

protected String generateMultiplicityRange(Object mr)
Generates a multiplicity range. The standard getLower and getUpper defined on MMultiplicityRange give a -1 if the multiplicity is n or *. This method circumvents that behaviour.

Parameters:
mr - the given MultiplicityRange object
Returns:
String

generateState

public String generateState(Object m)
Description copied from interface: NotationProvider2
Generate the String representation for a State.

Specified by:
generateState in interface NotationProvider2
Specified by:
generateState in class Generator2
See Also:
NotationProvider2.generateState(java.lang.Object)

generateSubmachine

public String generateSubmachine(Object m)
Description copied from interface: NotationProvider2
Generate the String representation for a Submachine.

Specified by:
generateSubmachine in interface NotationProvider2
Specified by:
generateSubmachine in class Generator2
See Also:
NotationProvider2.generateSubmachine(java.lang.Object)

generateObjectFlowState

public String generateObjectFlowState(Object m)
Description copied from interface: NotationProvider2
Generate the String representation for a ObjectFlowState.

Specified by:
generateObjectFlowState in interface NotationProvider2
Specified by:
generateObjectFlowState in class Generator2
See Also:
NotationProvider2.generateObjectFlowState(java.lang.Object)

generateStateBody

public String generateStateBody(Object m)
Description copied from interface: NotationProvider2
Generate the String representation for a StateBody.

Parameters:
m - Object to generate representation for.
Returns:
The String representation of the object.
See Also:
NotationProvider2.generateStateBody(java.lang.Object)

generateTransition

public String generateTransition(Object m)
Description copied from interface: NotationProvider2
Generate the String representation for a Transition.

Specified by:
generateTransition in interface NotationProvider2
Specified by:
generateTransition in class Generator2
See Also:
NotationProvider2.generateTransition(java.lang.Object)

generateAction

public String generateAction(Object m)
Description copied from interface: NotationProvider2
Generate the String representation for an Action.

Specified by:
generateAction in interface NotationProvider2
Specified by:
generateAction in class Generator2
See Also:
NotationProvider2.generateAction(java.lang.Object)

generateGuard

public String generateGuard(Object m)
Description copied from interface: NotationProvider2
Generate the String representation for a Guard.

Specified by:
generateGuard in interface NotationProvider2
Specified by:
generateGuard in class Generator2
See Also:
NotationProvider2.generateGuard(java.lang.Object)

generateEvent

public String generateEvent(Object m)
Generates the text for a (trigger) event.

Specified by:
generateEvent in interface NotationProvider2
Specified by:
generateEvent in class Generator2
Parameters:
m - Object of any MEvent kind
Returns:
the string representing the event
See Also:
NotationProvider2.generateEvent(java.lang.Object)

generateParameterList

private String generateParameterList(Object parameterListOwner)
Generates a list of parameters. The parameters belong to the given object. The returned string will have the following syntax:

(param1, param2, param3, ..., paramN)

If there are no parameters, then "()" is returned.

Parameters:
parameterListOwner - the 'owner' of the parameters
Returns:
the generated parameter list

generateActionState

public String generateActionState(Object actionState)
Description copied from interface: NotationProvider2
Generate the String representation for an Action State.

Parameters:
actionState - Object to generate representation for.
Returns:
The String representation of the object.
See Also:
NotationProvider2.generateActionState(java.lang.Object)

getModuleName

public String getModuleName()
Description copied from interface: ArgoModule
Display name of the module.

Returns:
the module name
See Also:
ArgoModule.getModuleName()

getModuleDescription

public String getModuleDescription()
Description copied from interface: ArgoModule
Textual description of the module.

Returns:
the module description
See Also:
ArgoModule.getModuleDescription()

getModuleAuthor

public String getModuleAuthor()
Description copied from interface: ArgoModule
The module author.

Returns:
a string containing the module author
See Also:
ArgoModule.getModuleAuthor()

getModuleVersion

public String getModuleVersion()
Description copied from interface: ArgoModule
The module version. There is no specified format.

Returns:
a string containing the module version
See Also:
ArgoModule.getModuleVersion()

getModuleKey

public String getModuleKey()
Description copied from interface: ArgoModule
The module identifying key.

Returns:
the string key the module uses to identify itself
See Also:
ArgoModule.getModuleKey()

inContext

public boolean inContext(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
Overrides:
inContext in class Generator2
See Also:
Pluggable.inContext(java.lang.Object[])

isModuleEnabled

public boolean isModuleEnabled()
Description copied from class: Generator2
The default for any Generator is to be enabled.

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


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