Re: <any type> -> String



Re: <any type> -> String

From: Andreas Awenius <andreas.awenius_at_empowertec.de>
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
methods).
You could add a utility class with a static conversion method to your model
and then use this method in your OCL expressions.

Pseudocode:

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


> 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
> puml-list-request@cs.york.ac.uk
> with a message containing the word "unsubscribe".

--
http://www.empowertec.de
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