Re: <any type> -> String

Re: <any type> -> String

From: Andreas Awenius <>
Date: Sun, 4 Mar 2007 14:42:52 +0100
Message-ID: <hU1GGfN44A1DDO3rquMrbzbjgRgiX00i1fScRjVlnEL@akmail>
Hello Rafael,

you can't do this within the OCL standard library (it does not define these
You could add a utility class with a static conversion method to your model
and then use this method in your OCL expressions.


class Converter
	static toString(in Real): String

Then you can use it like this, for example:

context ...
inv: Converter::toString(3.1415) = '3.1415'

(This code was checked with Oclarity, our OCL AddIn for Rational Rose).

Hope this helps,

> How to convert an integer to a string in OCL? I was surprised to see the
> toInteger and toReal operations in String, but missed a toString
> operation in all other types. For instance, how would I go about
> concatenating a string to an integer, if concat takes a string?

> Thanks,

> Rafael

> To remove yourself from this list please mail
> with a message containing the word "unsubscribe".

EmPowerTec AG
Taubenweg 20
85238 Petershausen, Germany
Fon: +49 8137 80 98 81
Fax: +49 8137 80 98 82
Incorporation (Registereintragung):  Amtsgericht München, HRB 138557
CEO (Vorstandsvorsitzender):  Andreas Awenius
Aufsichtsratsvorsitzender: Thomas Meidinger
Received on Sun 04 Mar 2007 - 13:38:16 GMT