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
Hello,

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: 91
Registered: December 2015
Location: Grenoble, France
Member
Hi

Your problem seems to be this OCL expression

Quote:

self.value->toString();



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

try instead

self.value.toString();
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: 7265
Registered: July 2009
Senior Member
Hi

You should find that https://git.eclipse.org/r/plugins/gitiles/ocl/org.eclipse.ocl/+/refs/heads/master/examples/org.eclipse.ocl.examples.build/model/UML2EcoreControl.ecore shows you how to use hierarchical model names. Or use oclType() to use meta=names.

Regards

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: Mon Sep 20 12:15:54 GMT 2021

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

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

Back to the top