section: < previous | next > | | | |
chapter: << previous | next >> |
2. Navigation expressions
Navigating from one instance to an other or to a collection of instances is realized by a link between these two objects and a label, naming the association end of the corresponding association in the class diagram. |
This representation corresponds to the UML collaboration diagrams and produces the main advantage of VOCL in comparison to OCL - the gain of an overview over the whole expression. |
2.1 NavigationThe role names of the association ends indicate the direction of the navigation. The cardinality defines whether the end is a classifier role or a collection classifier role, which may be a set, bag or sequence. At this point there is the possibility to ether make an assertion about this navigation end or to navigate further. Each navigation starts either at the classifier role self or the one, defined in the context, or, if nothing of both exists, the only classifier role of the context type. |
The example in figure 2.1 describes, that the manager of a company have to be employed - at least by the company itself. The corresponding OCL text is: |
||
2.2 Navigation to a collectionIf the cardinality of an association end is higher than 1 the result of a navigation to this association end will be a collection. In particular this collection may be a set, but can also be a bag or a sequence.
|
The example in figure 2.2 is part of a VOCL constraint and delivers a collection of the employees, who belong to a company. The corresponding OCL text is: |
section: < previous | next > | | | |
chapter: << previous | next >> |