Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Ecore EDouble toString returns "Set{1.0}" instead of "1.0"
Ecore EDouble toString returns "Set{1.0}" instead of "1.0" [message #1841072] Mon, 03 May 2021 06:35 Go to next message
Christoph Parg is currently offline Christoph PargFriend
Messages: 1
Registered: May 2021
Junior Member

I have the following situation:

I want to model an inheritance hierachy for some action types in the OCLinEcore editor whereby each class should should override a "getLabel" operation. This operation should then return a string representation of its value:

Base type:

abstract class Action
operation getLabel() : String[?];

A concrete type:

class DoubleAction extends Action
operation getLabel() : String[?]
body: self.value->toString();
attribute type : DoubleActionType[1];
attribute value : ecore::EDouble;

I want to design my own graphical modelling in the odesign file and this operation is then invoked here (in an expression field). For the value->toString() I expected "1.0" for a value of 1.0. However, I always get "Set{1.0}" as a result.

Does someone know how to correctly convert this into the expected form? I also would like to convert then the enum type to string (finally I want a result like "<type> = <value>")
Re: Ecore EDouble toString returns "Set{1.0}" instead of "1.0" [message #1841096 is a reply to message #1841072] Mon, 03 May 2021 19:07 Go to previous messageGo to next message
German Vega is currently offline German VegaFriend
Messages: 104
Registered: December 2015
Location: Grenoble, France
Senior Member

Your problem seems to be this OCL expression



You are using the arrow (->) operator, this automatically casts your attribute value to a singleton set.

try instead

Re: Ecore EDouble toString returns "Set{1.0}" instead of "1.0" [message #1841106 is a reply to message #1841096] Tue, 04 May 2021 04:41 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7487
Registered: July 2009
Senior Member

You should find that shows you how to use hierarchical model names. Or use oclType() to use meta=names.


Ed Willink
Previous Topic:[CDO] NPE in SecurityManager$PermissionManager which leads to TimeoutRuntimeException on next commit
Next Topic:ChangeRecorder cannot be found by org.eclipse.emf.edit
Goto Forum:

Current Time: Wed Jun 29 14:00:42 GMT 2022

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

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

Back to the top