OCL expression [message #29340] |
Thu, 21 June 2007 22:02  |
Eclipse User |
|
|
|
Originally posted by: asma.charfi.com
Hi,
I have a string property named with value (0,1,2) and I want to write an ocl
expression that returns 3 (number of integer in this string)
I don't know if I need to use regular expression string literals in OCL?
(for , and ()) or I can convert (0,1,2) to a sequence of integer so I can
get the size (3)
to begin, I write
let s: Sequence (Integer) = self..defaultValue.stringValue() in s->at(0)
to get 0 (the first integer in my sequence)
but of couse it did not work ;-)
"Type mismatch; No supertype: (String), (Sequence (Integer))"
I know that I am so far from doing it but I will do it with your help of
course ;-)
thank you!
|
|
|
Re: OCL expression [message #30150 is a reply to message #29340] |
Mon, 25 June 2007 15:55  |
Eclipse User |
|
|
|
Originally posted by: cdamus.ca.ibm.com
Hi, Asma,
Given OCL's very limited facilities for working with strings, I doubt that
this would even be feasible (I don't think I could write an expression that
would do it).
Have a look at the "Customizing the Environment" topic in the "Advanced
Topics" in the OCL Programmer's Guide. It has an example of defining
custom operations (for regex matching on strings, as it happens) using
Java. You could use Java's wonderful string APIs to create, for example,
an asIntegerSequence() operation for Strings.
Cheers,
Christian
charfi asma wrote:
> Hi,
> I have a string property named with value (0,1,2) and I want to write an
> ocl expression that returns 3 (number of integer in this string)
> I don't know if I need to use regular expression string literals in OCL?
> (for , and ()) or I can convert (0,1,2) to a sequence of integer so I can
> get the size (3)
> to begin, I write
> let s: Sequence (Integer) = self..defaultValue.stringValue() in s->at(0)
> to get 0 (the first integer in my sequence)
> but of couse it did not work ;-)
> "Type mismatch; No supertype: (String), (Sequence (Integer))"
>
> I know that I am so far from doing it but I will do it with your help of
> course ;-)
>
> thank you!
|
|
|
Powered by
FUDForum. Page generated in 0.05391 seconds