Visual OCL

TU-Berlin | Faculty IV | Institute ISTI | Research group TFS

User Guide for the Eclipse VOCL-Plugin
group 2

small logo
section: < previous | next >
| |
chapter: << previous | next >>

2.2 Classifiers

Classifiers refer in OCL, and so in VOCL too, to Classes and in opposite to classes they are instances.

The creation of a ClassifierRole is explained by an example (see Fig. 2.2.1). This includes all possible elements that can be drawn, that are attribute with value, attribute with a variable and a method call.


Fig. 2.2.1 the ClassifierRole to be created


2.2.1 Definition of a role name and role type


In order to create a Classifier execute the following steps:

  1. Select the palette entry ClassifierRole, move the mouse cursor to a Constraint, which you have created previously and click in this Constraint. As mentioned in the previous section the Constraint is a top-level container for all other VOCL elements.
  2. Then a dialog is opened (see. Fig 2.2.2) which is divided into three parts: 
    1. section for the definition of role name and role type which references to a given class
    2. section for creating, editing and removing attributes
    3. section for the definition of a method call
  3. In the textfield for a role name we put "c" and for role type we put in "Company" (see Fig. 2.2.2). When you have done this, you can continue to define the attributes (see Fig. 2.2.1)


Fig. 2.2.2 dialog for creating a ClassifierRole


2.2.2 Definition of attributes


For defining an attribute you need a name and a type for the attribute. Furthermore you have to decide whether a value or a variable should be assigned to the attribute. In our example we present these two cases.
Follow these instructions:
  1.  The ClassifierRole dialog is still opened (see Fig. 2.2.3). Click in the attribute section on the button "add" and a dialog for defining attrbutes is opened.
  2. For attribute name we put in "name".
  3. For the type of an attribute, four predefined types are given in a combo box. There we select "String".
  4. After that you have to select the option button value and put in "General Motors". In this case we assign a constant value to the attribute "name"
  5. Then click ok. If you forget to fill in some values a dialog will be opened which ask you to put in the missing values.

Fig 2.2.3 dialog for defining attributes

After that  you return to the ClassifierRole dialog (see Fig 2.2.4). The defined attributes are displayed in the attribute section
For defining an attribute "profitPerYear" with a variable repeat the steps 1-3, but put in "profitPerYear" and "Integer".
  1. Select variable and put in a name for it. In this case "x". This variable can be used to define conditions.


Fig. 2.2.4 dialog with defined attributes

Attributes can also be edited by clicking the button "edit" on the right side of the attribute section. The attribute dialog is opened with the attribute values and you can edit them and click "ok".

 

2.2.3 Defining a method call

TODO ... allgmein: nur eine Methode, Dialog beschreiben.

To add a method call to a ClassifierRole you have to do these steps:
  1. Push the button Add method in the ClassifierRole dialog and dialog for creating a method is opened.
  2. First of all define a name for the method ("getProfitPerYear").
  3. Enable the checkbox with return type and put in "res" for name and "Integer" for type.
  4. Define Parameters.

Fig. 2.2.5 - dialog for defining a method



Fig. 2.2.6 ClassifierRole with all elements for the ClassifierRole

2.2.4 Functionality beyond creating

After you have created a ClassifierRole, you can move it at any place inside a Constraint. Moreover you can edit the ClassifierRole via the context menu. First you have to select the ClassifierRole you want to edit, click the right mouse button and select "Edit ClassifierNode" in the context menu. The same dialog is opened as for the creation with the difference that the values of the ClassifierRole appear.
A special feature for ClassifierRoles is that you can only delete them if no variable is bound at any condition. But this is explained in detail in section conditions.
©2005 TFS