Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » oclIsUndefined and empty String
oclIsUndefined and empty String [message #498536] Tue, 17 November 2009 11:49 Go to next message
Eclipse UserFriend
Originally posted by: formatzeh.gmx.de

I have some ocl constraints in my EMF meta-model which should evaluated
at runtime. One of my classes has two attributes (category and url) of
type String where only one of both must be set (xor). Therefor I defined
the following constraint:

(self.url.oclIsUndefined() and (not
self.classificationCategory.oclIsUndefined())) or ((not
self.url.oclIsUndefined()) and self.classificationCategory.oclIsUndefined())

The first time I create a model with the EMF-generated editor I only set
url and the constraint wasn't violated. Then I set the category as well
and the violation was indicated correctly. After that I removed the
category again by deleting the String in the properties view. But
surprisingly the message popped up that the constraint still is
violated. Then I saw in the source of the model that category had the
empty string category="" after deleting it. After removing it by hand
from the source the evaluation was successful again. So if category has
the empty string oclIsUndefined doesn't return true - well that's ok but
not in my case. So can you help me with the correct XOR expression
respecting the empty string as well?
Re: oclIsUndefined and empty String [message #498548 is a reply to message #498536] Tue, 17 November 2009 12:50 Go to previous messageGo to next message
Laurent Goubet is currently offline Laurent GoubetFriend
Messages: 1902
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------000806060301050200070905
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

Hi Gilbert,

note that "xor" exists in ocl :

(self.url.oclIsUndefined() or self.url = '') xor
(self.classificationCategory.oclIsUndefined() or
self.classificationCategory = '')

should do the trick

Laurent

Gilbert Mirenque wrote:
> I have some ocl constraints in my EMF meta-model which should evaluated
> at runtime. One of my classes has two attributes (category and url) of
> type String where only one of both must be set (xor). Therefor I defined
> the following constraint:
>
> (self.url.oclIsUndefined() and (not
> self.classificationCategory.oclIsUndefined())) or ((not
> self.url.oclIsUndefined()) and self.classificationCategory.oclIsUndefined())
>
> The first time I create a model with the EMF-generated editor I only set
> url and the constraint wasn't violated. Then I set the category as well
> and the violation was indicated correctly. After that I removed the
> category again by deleting the String in the properties view. But
> surprisingly the message popped up that the constraint still is
> violated. Then I saw in the source of the model that category had the
> empty string category="" after deleting it. After removing it by hand
> from the source the evaluation was successful again. So if category has
> the empty string oclIsUndefined doesn't return true - well that's ok but
> not in my case. So can you help me with the correct XOR expression
> respecting the empty string as well?


--------------000806060301050200070905
Content-Type: text/x-vcard; charset=utf-8;
name="laurent_goubet.vcf"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="laurent_goubet.vcf"

YmVnaW46dmNhcmQNCmZuOkxhdXJlbnQgR291YmV0DQpuOkdvdWJldDtMYXVy ZW50DQpvcmc6
PGEgaHJlZj0iaHR0cDovL3d3dy5vYmVvLmZyIj5PYmVvPC9hPg0KZW1haWw7 aW50ZXJuZXQ6
bGF1cmVudC5nb3ViZXRAb2Jlby5mcg0KdXJsOmh0dHA6Ly93d3cub2Jlby5m cg0KdmVyc2lv
bjoyLjENCmVuZDp2Y2FyZA0KDQo=
--------------000806060301050200070905--
Re: oclIsUndefined and empty String [message #498557 is a reply to message #498548] Tue, 17 November 2009 13:45 Go to previous message
Eclipse UserFriend
Originally posted by: formatzeh.gmx.de

Oh...thanks Laurent
Previous Topic:Identical model elements
Next Topic:query for class and interface check
Goto Forum:
  


Current Time: Fri Apr 19 03:24:09 GMT 2024

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

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

Back to the top