Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » Re: OCL-Expression Error
Re: OCL-Expression Error [message #11499] Wed, 14 March 2007 17:53 Go to next message
Eclipse User
Originally posted by: merks.ca.ibm.com

Irina,

OCL has its own specific newsgroup, so the question is best asked
there. I've added it to the "to" list.


Irina wrote:
> Hi all,
> what's wrong on my OCL-Expression?
>
> self.allStateFigures->select(oclIsTypeOf(PseudoState)).kind
> Error in (variableExpCS): (Unrecognized variable: (kind))
>
> This OCL-Expression works!
> self.allStateFigures->select(oclIsTypeOf(PseudoState)).name
>
> Name is an Attribute of PseudoState Class of Type String and Kind is an
> Attribute of PseudoState Class of Type PseudoStateKind.
>
> i cann't understand it ;-((
> Help me please.
>
>
>
Re: OCL-Expression Error [message #11536 is a reply to message #11499] Wed, 14 March 2007 22:22 Go to previous message
Eclipse User
Originally posted by: cdamus.ca.ibm.com

Hi, Irina,

The type of the self.allStateFigures property is, I assume, Set(Vertex).
(correct me if I'm wrong)

Thus, the type of any select expression on this collection will likewise be
Set(Vertex), not Set(PseudoState). The select expression always returns a
collection of the same element type as the source collection. Your second
example

self.allStateFigures->select(oclIsTypeOf(PseudoState)).name

works because Vertex is a kind of NamedElement, thus has a "name" property.

In the case of

self.allStateFigures->select(oclIsTypeOf(PseudoState)).kind

Vertex does not have a "kind" property; this is defined by the PseudoState
metaclass. You need to do the following:

self.allStateFigures->iterate(s; ps : Set(PseudoState) = Set{} |
if s.oclIsTypeOf(PseudoState) then
ps->including(s.oclAsType(PseudoState))
else
ps
endif).kind

Unfortunately, OCL 2.0 does not allow the use of oclAsType() to cast a
collection to another collection type. i.e., you can't just do:

self.allStateFigures->select(
oclIsTypeOf(PseudoState)).oclAsType(Set(PseudoState)).kind

HTH,

Christian


Ed Merks wrote:

> Irina,
>
> OCL has its own specific newsgroup, so the question is best asked
> there. I've added it to the "to" list.
>
>
> Irina wrote:
>> Hi all,
>> what's wrong on my OCL-Expression?
>>
>> self.allStateFigures->select(oclIsTypeOf(PseudoState)).kind
>> Error in (variableExpCS): (Unrecognized variable: (kind))
>>
>> This OCL-Expression works!
>> self.allStateFigures->select(oclIsTypeOf(PseudoState)).name
>>
>> Name is an Attribute of PseudoState Class of Type String and Kind is an
>> Attribute of PseudoState Class of Type PseudoStateKind.
>>
>> i cann't understand it ;-((
>> Help me please.
>>
>>
>>
Previous Topic:LoopExp abstractness
Next Topic:How to write constraint for not requiring self transition
Goto Forum:
  


Current Time: Sat Oct 25 12:17:21 GMT 2014

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

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