Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » Converting Integer to String
Converting Integer to String [message #489564] Sun, 04 October 2009 23:51 Go to next message
Derek Palma is currently offline Derek PalmaFriend
Messages: 141
Registered: July 2009
Senior Member
Hi,

Is there a way to convert an Integer to a String? I am trying to get a
statement like 'Some Prefix: '.concat(someNumber) where some number is an
Integer. I could not find anything in the OCL spec that made me think this
was possible (looking at Integer, Real and OclAny). However, I am assuming I
missed it since most languages seem to have such a feature.

Thanks in advance.
Derek
Re: Converting Integer to String [message #489571 is a reply to message #489564] Mon, 05 October 2009 04:55 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi Derek

The feature isa indeed missing OCL 2.0.

It is added in OCL 2.1, which should be supported in the next release of
MDT-OCL. String::+ is added as well.

For now you may need to write a helper function to recursively
concatenate digit by digit.

Regards

Ed Willink


Derek Palma wrote:
> Hi,
>
> Is there a way to convert an Integer to a String? I am trying to get a
> statement like 'Some Prefix: '.concat(someNumber) where some number is
> an Integer. I could not find anything in the OCL spec that made me think
> this was possible (looking at Integer, Real and OclAny). However, I am
> assuming I missed it since most languages seem to have such a feature.
>
> Thanks in advance.
> Derek
Re: Converting Integer to String [message #489598 is a reply to message #489564] Mon, 05 October 2009 08:34 Go to previous message
Eclipse UserFriend
Originally posted by: dvorak.radek.gmail.com

Hi Derek,

The QVTO Stdlib defines Integer::toString() operation. The OMG spec does
define only
8.3.3.1 repr
Object::repr() : String
Prints a textual representation of the object.

Very informative about what to expect ;-)

We have included it to address backward compatibility issues and also
because the 09-05-02 OCL OMG spec draft adds this to the OCL Stdlib.

You can write your snippet like
var someNumber := 15;
var somePrefix := "pre_";
var concat := somePrefix + someNumber.toString();

Regards,
/Radek


On Mon, 05 Oct 2009 01:51:52 +0200, Derek Palma <derek.palma@gmail.com>
wrote:

> Hi,
>
> Is there a way to convert an Integer to a String? I am trying to get a
> statement like 'Some Prefix: '.concat(someNumber) where some number is
> an Integer. I could not find anything in the OCL spec that made me think
> this was possible (looking at Integer, Real and OclAny). However, I am
> assuming I missed it since most languages seem to have such a feature.
>
> Thanks in advance.
> Derek
Previous Topic:Overriding oclIsUndefined method?
Next Topic:OCL Parser
Goto Forum:
  


Current Time: Thu Apr 25 03:31:41 GMT 2024

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

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

Back to the top