[QVTO] Default initialization of * features [message #870776] |
Wed, 09 May 2012 15:32 |
Christopher Gerking Messages: 115 Registered: April 2011 |
Senior Member |
|
|
A target EClass has a *-feature, i.e. cardinality is > 1. After instantiating the EClass within QVTO, the following queries lead to the following results:
(o.ref = null) is false, which implies that the feature has been initialized automatically
(o.ref.oclIsUndefined()) is [], which shows that oclIsUndefined does not return true or false in favor of an empty sequence. I do not assume that this is the intended behaviour?
(o.ref->size()) is 0, which makes sense
On intermediate class objects, the situation is even more weird. After creation of an intermediate class object:
(o.ref = null) is false, same behaviour as for default objects
(o.ref.oclIsUndefined()) is [true], obviously the result is a seqauence containing an instance of OclVoid
(o.ref->size()) is 1, which is normally not expected behaviour and caused serious problems in my case
Why does oclIsUndefined() return a sequence at all and why does the sequence contain an instance of OclVoid in case of an intermediate class?
|
|
|
Re: [QVTO] Default initialization of * features [message #870784 is a reply to message #870776] |
Wed, 09 May 2012 16:13 |
Ed Willink Messages: 7655 Registered: July 2009 |
Senior Member |
|
|
Hi
o.ref.oclIsUndefined() is a shortform for
o.ref->collect(oclIsUndefined()) so you get a (empty) collection of the
element returns.
You don't say how you create your intermediate class object so a
response is possible. I suspect you are using the implicit ->
conversion. o.ref->size() = 1 seems very sensible to me.
With QVTo you are using the Ecore binding of Eclipse OCL. This has some
problems in null/invalid/deep collection corner cases, which only
acquired a meaningful specification in OCL 2.3, which postdates QVTo 1.1.
Regards
Ed Willink
On 09/05/2012 16:33, Christopher G. wrote:
> A target EClass has a *-feature, i.e. cardinality is > 1. After
> instantiating the EClass within QVTO, the following queries lead to
> the following results:
>
> (o.ref = null) is false, which implies that the feature has been
> initialized automatically
> (o.ref.oclIsUndefined()) is [], which shows that oclIsUndefined does
> not return true or false in favor of an empty sequence. I do not
> assume that this is the intended behaviour?
>
> (o.ref->size()) is 0, which makes sense
>
>
> On intermediate class objects, the situation is even more weird. After
> creation of an intermediate class object:
>
> (o.ref = null) is false, same behaviour as for default objects
> (o.ref.oclIsUndefined()) is [true], obviously the result is a
> seqauence containing an instance of OclVoid
>
> (o.ref->size()) is 1, which is normally not expected behaviour and
> caused serious problems in my case
>
> Why does oclIsUndefined() return a sequence at all and why does the
> sequence contain an instance of OclVoid in case of an intermediate class?
|
|
|
Re: [QVTO] Default initialization of * features [message #870990 is a reply to message #870784] |
Thu, 10 May 2012 13:35 |
Christopher Gerking Messages: 115 Registered: April 2011 |
Senior Member |
|
|
Edward Willink wrote on Wed, 09 May 2012 12:13Hi
o.ref.oclIsUndefined() is a shortform for
o.ref->collect(oclIsUndefined()) so you get a (empty) collection of the
element returns.
Okay, this makes sense.
Edward Willink wrote on Wed, 09 May 2012 12:13
You don't say how you create your intermediate class object so a
response is possible. I suspect you are using the implicit ->
conversion. o.ref->size() = 1 seems very sensible to me.
Size 1 is sensible, why? The object o is created via 'object' keyword. Without explicit initialization of the ref feature, the null check returns false. Obviously, the feature has been initialized automatically. For the automatic initialization I would assume an empty collection. Instead, there seems to be an instance of OclVoid inside the collection, which implies the size 1.
The actual problem is that the OclVoid instance remains during execution, i.e. when first adding to that collection, the size is 2 and so on...
|
|
|
Re: [QVTO] Default initialization of * features [message #871357 is a reply to message #870990] |
Sat, 12 May 2012 10:29 |
Ed Willink Messages: 7655 Registered: July 2009 |
Senior Member |
|
|
Hi
As I wrote: You don't say how you create your intermediate class object
.... seems very sensible to me.
Without a clear exposition of what you are actually doing, I cannot
explain the subtleties of null content to you.
Regards
Ed Willink
On 10/05/2012 14:35, Christopher G. wrote:
> Edward Willink wrote on Wed, 09 May 2012 12:13
>> Hi
>>
>> o.ref.oclIsUndefined() is a shortform for
>> o.ref->collect(oclIsUndefined()) so you get a (empty) collection of
>> the element returns.
>
>
> Okay, this makes sense.
>
>
> Edward Willink wrote on Wed, 09 May 2012 12:13
>> You don't say how you create your intermediate class object so a
>> response is possible. I suspect you are using the implicit ->
>> conversion. o.ref->size() = 1 seems very sensible to me.
>
>
> Size 1 is sensible, why? The object o is created via 'object' keyword.
> Without explicit initialization of the ref feature, the null check
> returns false. Obviously, the feature has been initialized
> automatically. For the automatic initialization I would assume an
> empty collection. Instead, there seems to be an instance of OclVoid
> inside the collection, which implies the size 1.
>
> The actual problem is that the OclVoid instance remains during
> execution, i.e. when first adding to that collection, the size is 2
> and so on...
>
>
>
>
|
|
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03768 seconds