UML:实数和无限自然文字

UML: Real and UnlimitedNatural literals

我不确定我对 Real 和 UnlimitedNatural 文字的标记是否正确,所以我做了这个例子。请说说这个符号是对还是错。

-----------------------------
|       MyClass             |
-----------------------------
| var1:Real=0.87            |
| var2:Real=1.6E-2          |
| var3:UnlimitedNumber=5..* |
-----------------------------

默认值由 ValueSpecification 描述(如 UML 规范第 9.5 章所述,或此处 How to specifiy enumeration literal as default value in UML Attribute?)。

就您而言,您对 Reals 和 UnlimitedNaturals 感兴趣。

8.4.2 Notation

  • A LiteralUnlimitedNatural is shown either as a sequence of digits or as an asterisk (*), where an asterisk denotes unlimited. Note that “unlimited” denotes the lack of a limit on the value of some element (such as a multiplicity upper bound), not a value of “infinity.”
  • A LiteralReal is shown in decimal notation or scientific notation. Decimal notation consists of an optional sign character (+/-) followed by zero or more digits followed optionally by a dot (.) followed by one or more digits. Scientific notation consists of decimal notation followed by either the letter “e” or “E” and an exponent consisting of an optional sign character followed by one or more digits. The scientific notation expresses a real number equal to that given by the decimal notation before the exponent, times 10 raised to the power of the exponent.

因此 var1var2 是正确的,但是 var3 不是。

5..* 是表示“至少 5 个值”的多重性,将其作为默认值并没有多大意义。

至于LiteralUnlimitedNatural,这主要是对重数有意义,你可以用它来表示没有上界。 对于默认值,它与具有约束 >=0LiteralInteger 没有什么不同 --- 任何非负数。

Integer 是任意整数:-2, 0, 27, ...

Natural 是任何非负数 (>=0):0、120、...

UnlmitedNatural是一个Natural数字或者一个星号*,表示没有限制; 然而 * 本身并不是一个值(它并不意味着如上所述的无穷大),而是在特定(多重性范围)上下文中缺乏价值。