|Prev - Next - Down||SDMetrics - the UML design measurement tool|
1. The "dot" operator
In an expression term, it is sometimes useful to refer to attribute or metric values of related elements. This can be accomplished with the dot operator.
For example, to access the name of an operation's owner, we simply write "context.name". The left hand side expression "context" refers to the owner of the operation, which has to be some model element (e.g., a class). For that model element, the right hand side expression "name" is evaluated, which yields the value of its attribute "name".
In general, evaluating expression a.b for a model element e works as follows:
If we want to determine the package in which a class resides, we usually access it via its "context" attribute. However, the owner of a class need not be a package. For an inner class, for example, the "context" attribute yields its containing outer class.
The "upto" operator in the expression "context upto (typeof(self)='package')" follows the "context" attribute, across several model elements if necessary, until it encounters a model element of type package.
In general, evaluation of the expression a upto b for a model element e works as follows:
Similar to the "upto" operator, the "topmost" operator successively evaluates a condition expression for a chain of model elements. Whereas the "upto" operator returns the first element that fulfills the condition expression, the "topmost" operator returns the last element in the chain that fulfills the condition expression.
The "topmost" operator in the expression "context topmost (typeof(self)='package')" yields the top-level package that contains the element.
In general, evaluation of the expression a topmost b for a model element e works as follows:
|Section 220.127.116.11 "Mathematical Operators and Functions"||Contents||Section 8.5.3 "Set Expressions"|