Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » OCL expression
OCL expression [message #29340] Fri, 22 June 2007 02:02 Go to next message
Eclipse UserFriend
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 19:55 Go to previous message
Eclipse UserFriend
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!
Previous Topic:constraint's severity
Next Topic:OCL Query with Stereotype as context
Goto Forum:
  


Current Time: Fri Apr 26 12:20:49 GMT 2024

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

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

Back to the top