Creating operations
Creating an operation
Operations are created on metaclass references defined in a Java profile implementation
(that is, a subset of metaclass references that can be defined in a Java MDA
component) by clicking on the
icon.
Steps:
1. Select a metaclass reference defined in a Java profile implementation.
2.
Click on the
icon. Your new operation then
appears in the explorer. Double-click on
it to open the “Operation” window.
The “Operation” dialog box

Figure 106. The “Operation” dialog box (“Properties” tab)
Key:
· "Name": This is the name of the operation.
· "create": This indicates that the operation is a constructor.
· "destroy": This indicates that the operation is a destructor.
· "Visibility": This is the visibility of the member (none, public, protected or private).
· "Abstract": This determines abstract methods.
· "Cannot be specialized": This indicates that the operation may not be specialized, that is to say made more specific. It is a leaf operation.
· "Class": This defines a "class" operation, i.e. shared by all its instances.
· "Passing mode": This is the operation's passing mode (in or out). The default is "out". This mode indicates whether the object receiving the message is modified (out), or not (in) by the operation's execution.
· "Parameters": This zone is used to define the parameters that the operation receives.
· "Return parameter: This zone is used to define the possible return parameter.
Input/output parameters
To enter input and/or output parameters, simply click on the "Add" button in the "Parameters" zone and then define the parameter in the "Parameter" dialog box that appears.
To remove input and/or output parameters, simply click on the "Remove" button and select the parameter(s) you want to remove. To remove all the parameters, click on the "Remove all" button.
The "Modify" button is used to re-open the "Parameter" dialog box, in order to modify a selected parameter.
Return parameter
The "Return parameter" zone is used to define the type returned by the operation. This type can be a basic type (int, boolean, string, …), a metaclass name (Class, Attribute, Package, …), or a stereotype name (create, access, …). To return a set of elements, add “[]” after the type.
To create a return parameter, simply click on the "Add" button in the "Return parameter" zone and then define the return parameter in the "Return parameter" dialog box that appears.
To remove a return parameter, select it and click on the "Remove" button.
Entering Java code for your operation
The Java code for your operations is entered via the "Implementation" tab of the "Operation" dialog box. When you select this tab and then click on the "Add" button, a window opens in which you can enter the code (Figure 107).

Figure 107. The “Note” dialog box used to enter Java code
Select the "JCode" note type and enter your code in the "Contents" field.
Note: Please note that the "JCode" note type can be used to enter either Java code or J code.
Toolbar
The icons appearing in the “MDA” tab of the auxiliary window can be used to run the following commands:
|
Icon |
Description |
|
|
This icon is used to check that the operation has been correctly modeled. |