Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » UML2 » LiteralUnlimitedNatural.UNLIMITED
LiteralUnlimitedNatural.UNLIMITED [message #726478] Sun, 18 September 2011 08:23 Go to next message
Eclipse UserFriend
Originally posted by: Emil Huseynli

Hi, i wonder why value of LiteralUnlimitedNatural.UNLIMITED is 1? Is it
normal? Shouldn't it be MAXINT or so?
Re: LiteralUnlimitedNatural.UNLIMITED [message #726479 is a reply to message #726478] Sun, 18 September 2011 08:40 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: Emil Huseynli

Interesting, doing System.out.println LiteralUnlimitedNatural.UNLIMITED)
gives 1, but if i do

Property p = myAssociation.getAttribute("theAttribute");

and

System.out.println (p.getUpperValue().stringValue())

then * is printed. It's pretty ok for me, but still interesting what is
the internal representation of the LiteralUnlimitedNatural.UNLIMITED.
Maybe -1?

On 18.09.2011 10:23, Emil Huseynli wrote:
> Hi, i wonder why value of LiteralUnlimitedNatural.UNLIMITED is 1? Is it
> normal? Shouldn't it be MAXINT or so?
Re: LiteralUnlimitedNatural.UNLIMITED [message #727303 is a reply to message #726479] Tue, 20 September 2011 20:32 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

LiteralUnlimitedNatural.UNLIMITED is not a number, it is an enumeration
literal, so it is distinct from all numbers.

"1" is the enumeration ordinal.

Regards

Ed Willink


On 18/09/2011 09:40, Emil Huseynli wrote:
> Interesting, doing System.out.println LiteralUnlimitedNatural.UNLIMITED)
> gives 1, but if i do
>
> Property p = myAssociation.getAttribute("theAttribute");
>
> and
>
> System.out.println (p.getUpperValue().stringValue())
>
> then * is printed. It's pretty ok for me, but still interesting what
> is the internal representation of the
> LiteralUnlimitedNatural.UNLIMITED. Maybe -1?
>
> On 18.09.2011 10:23, Emil Huseynli wrote:
>> Hi, i wonder why value of LiteralUnlimitedNatural.UNLIMITED is 1? Is it
>> normal? Shouldn't it be MAXINT or so?
>
Re: LiteralUnlimitedNatural.UNLIMITED [message #735652 is a reply to message #727303] Wed, 12 October 2011 13:31 Go to previous messageGo to next message
Kenn Hussey is currently offline Kenn HusseyFriend
Messages: 1620
Registered: July 2009
Senior Member
Uh, it's not an enumeration literal and the value is -1, not 1. Because an unlimited natural is supposed to be a natural number (i.e., 0 or higher), the value of -1 is used as a special indicator to mean the maximum possible value. The same is done for upper bounds on Ecore features in EMF.

Kenn
Re: LiteralUnlimitedNatural.UNLIMITED [message #735765 is a reply to message #735652] Wed, 12 October 2011 16:41 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

Oops. Yes. Not an Enumeration; sure I checked, but no.

The implementation of numbers is implementation-specific; MDT/UML2 opts
for Java's Integer.

The UML specification is genuinely unlimited and the equivalent Integer
implementation for MDT/OCL has attracted bug reports, so that the
traditional code now has some support for a Long range. The new Pivot
model implementation is IntegerValue which has polymorphic
Integer/Long/BigInteger realisations.

* or UNLIMITED is really a misnomer for plus infinity. It is bigger than
MAXINT. -1 is clearly not bigger than MAXINT, so all code that accesses
an UnlimitedNatural must special case the out of bounds negative value.

Regards

Ed Willink



On 12/10/2011 14:31, Kenn Hussey wrote:
> Uh, it's not an enumeration literal and the value is -1, not 1.
> Because an unlimited natural is supposed to be a natural number (i.e.,
> 0 or higher), the value of -1 is used as a special indicator to mean
> the maximum possible value. The same is done for upper bounds on Ecore
> features in EMF.
>
> Kenn
Previous Topic:createAssociation
Next Topic:How to create a method with a generic collection type
Goto Forum:
  


Current Time: Thu Mar 28 16:08:51 GMT 2024

Powered by FUDForum. Page generated in 0.02722 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top