Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » UML2 » Adding a Double value to a Slot
Adding a Double value to a Slot [message #699910] Fri, 22 July 2011 15:01 Go to next message
Eclipse UserFriend
Originally posted by: Philipp Kalb

Hi

To put it in a nutshell:
I am desperately trying to add a double/float value to an instance
specifications Slot (programmatically). I know how its done for UML
Literals such as String, Integer...

For example Boolean values:
------------------------
//defProp, Ispec, value etc are defined earlier in the code...
Slot slot = Ispec.createSlot();
slot.setDefiningFeature(defProp);
LiteralBoolean valspec = (LiteralBoolean) slot.createValue("",
(PrimitiveType) ((Model) metamodel).getMember("Boolean"),
UMLFactory.eINSTANCE.getUMLPackage().getLiteralBoolean());
valspec.setValue(value);
-------------------------
This works fine!
So how can I change this code for a value which is a floating point
number such as Double, Float...? Can someone please give me a hint? :-)
How to get the "Type" and the "Eclass" for the "createValue" method? The
documentation is not very clear (at least to me)

cheers
Philipp
Re: Adding a Double value to a Slot [message #700006 is a reply to message #699910] Fri, 22 July 2011 17:11 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

Real was first introduced in UML 2.4 to remove the clumsiness whereby
different UML-based languages such as OCL, QVT, MOFM2T etc needed to
have different PrimitiveTypes.

The Indigo MDT/UML2 is UML 2.2 so no Real.

Your options:

encode reals as strings
add a LiteralReal class
adjust the UML 2.4 meta-model from the OMG spec
wait for UML 2.4 support

Regards

Ed Willink

On 22/07/2011 16:01, Philipp Kalb wrote:
> Hi
>
> To put it in a nutshell:
> I am desperately trying to add a double/float value to an instance
> specifications Slot (programmatically). I know how its done for UML
> Literals such as String, Integer...
>
> For example Boolean values:
> ------------------------
> //defProp, Ispec, value etc are defined earlier in the code...
> Slot slot = Ispec.createSlot();
> slot.setDefiningFeature(defProp);
> LiteralBoolean valspec = (LiteralBoolean) slot.createValue("",
> (PrimitiveType) ((Model) metamodel).getMember("Boolean"),
> UMLFactory.eINSTANCE.getUMLPackage().getLiteralBoolean());
> valspec.setValue(value);
> -------------------------
> This works fine!
> So how can I change this code for a value which is a floating point
> number such as Double, Float...? Can someone please give me a hint? :-)
> How to get the "Type" and the "Eclass" for the "createValue" method?
> The documentation is not very clear (at least to me)
>
> cheers
> Philipp
Re: Adding a Double value to a Slot [message #700008 is a reply to message #699910] Fri, 22 July 2011 17:11 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

Real was first introduced in UML 2.4 to remove the clumsiness whereby
different UML-based languages such as OCL, QVT, MOFM2T etc needed to
have different PrimitiveTypes.

The Indigo MDT/UML2 is UML 2.2 so no Real.

Your options:

encode reals as strings
add a LiteralReal class
adjust the UML 2.4 meta-model from the OMG spec
wait for UML 2.4 support

Regards

Ed Willink

On 22/07/2011 16:01, Philipp Kalb wrote:
> Hi
>
> To put it in a nutshell:
> I am desperately trying to add a double/float value to an instance
> specifications Slot (programmatically). I know how its done for UML
> Literals such as String, Integer...
>
> For example Boolean values:
> ------------------------
> //defProp, Ispec, value etc are defined earlier in the code...
> Slot slot = Ispec.createSlot();
> slot.setDefiningFeature(defProp);
> LiteralBoolean valspec = (LiteralBoolean) slot.createValue("",
> (PrimitiveType) ((Model) metamodel).getMember("Boolean"),
> UMLFactory.eINSTANCE.getUMLPackage().getLiteralBoolean());
> valspec.setValue(value);
> -------------------------
> This works fine!
> So how can I change this code for a value which is a floating point
> number such as Double, Float...? Can someone please give me a hint? :-)
> How to get the "Type" and the "Eclass" for the "createValue" method?
> The documentation is not very clear (at least to me)
>
> cheers
> Philipp
Re: Adding a Double value to a Slot [message #700043 is a reply to message #700006] Fri, 22 July 2011 18:44 Go to previous message
Eclipse UserFriend
Originally posted by: Philipp Kalb

Hi,

Thanks a lot for the answer! It explains why I could not find anything
in the UML specs....

I have already implemented the "encoding solution" which is a nice
workaround for my problem.

best regards
Philipp

Am 22.07.2011 19:11, schrieb Ed Willink:
> Hi
>
> Real was first introduced in UML 2.4 to remove the clumsiness whereby
> different UML-based languages such as OCL, QVT, MOFM2T etc needed to
> have different PrimitiveTypes.
>
> The Indigo MDT/UML2 is UML 2.2 so no Real.
>
> Your options:
>
> encode reals as strings
> add a LiteralReal class
> adjust the UML 2.4 meta-model from the OMG spec
> wait for UML 2.4 support
>
> Regards
>
> Ed Willink
>
> On 22/07/2011 16:01, Philipp Kalb wrote:
>> Hi
>>
>> To put it in a nutshell:
>> I am desperately trying to add a double/float value to an instance
>> specifications Slot (programmatically). I know how its done for UML
>> Literals such as String, Integer...
>>
>> For example Boolean values:
>> ------------------------
>> //defProp, Ispec, value etc are defined earlier in the code...
>> Slot slot = Ispec.createSlot();
>> slot.setDefiningFeature(defProp);
>> LiteralBoolean valspec = (LiteralBoolean) slot.createValue("",
>> (PrimitiveType) ((Model) metamodel).getMember("Boolean"),
>> UMLFactory.eINSTANCE.getUMLPackage().getLiteralBoolean());
>> valspec.setValue(value);
>> -------------------------
>> This works fine!
>> So how can I change this code for a value which is a floating point
>> number such as Double, Float...? Can someone please give me a hint? :-)
>> How to get the "Type" and the "Eclass" for the "createValue" method?
>> The documentation is not very clear (at least to me)
>>
>> cheers
>> Philipp
>
Previous Topic:How to read UML elements from a loaded file
Next Topic:Metamodel in Superstructure.uml
Goto Forum:
  


Current Time: Sat Apr 20 03:28:00 GMT 2024

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

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

Back to the top