Skip to main content



      Home
Home » Archived » M2M (model-to-model transformation) » [QVTo] Cast EObject to Meta-Model Type
[QVTo] Cast EObject to Meta-Model Type [message #756348] Sat, 12 November 2011 05:24 Go to next message
Eclipse UserFriend
Hi,

I have a Meta-model type "T" and an EObject "eObj" containing an object of type T.
Unfortunately the code below returns: "OclInvalid":

 eObj.oclAsType(T); 


Could someone help me to convert the type of the object?
Why does the cast not work implicitly?

Thanks a lot!
Re: [QVTo] Cast EObject to Meta-Model Type [message #756350 is a reply to message #756348] Sat, 12 November 2011 05:31 Go to previous messageGo to next message
Eclipse UserFriend
Hi

"T", "T1" and "T2" are under-specified and so magical declarations in
the OCL 2.0/2/3 specifications that OCL compilers need to treat as
template parameters even though there is no template declaration. As a
result practical implementations make them reserved words.

The OCL 2.4 specification should provide a coherent model of the OCL
Standard Library in which template parameters are declared rather than
empathized. (The pivot implementation in Eclipse OCL prototypes this.)

For now, do not use "T", "T1" and "T2" in your own code.

Regards

Ed Willink

On 12/11/2011 10:24, Supra wrote:
> Hi,
>
> I have a Meta-model type "T" and an EObject "eObj" containing an
> object of type T.
> Unfortunately the code below returns: "OclInvalid":
>
> eObj.oclAsType(T);
> Could someone help me to convert the type of the object? Why does the
> cast not work implicitly?
>
> Thanks a lot!
>
Re: [QVTo] Cast EObject to Meta-Model Type [message #756352 is a reply to message #756350] Sat, 12 November 2011 05:43 Go to previous messageGo to next message
Eclipse UserFriend
Thanks for the quick reply.

Actually the type is called "Control". I only simplified it for the post.

So your suggestion does not solve my problem. Do you have any further ideas?

Thank you!

[Updated on: Sat, 12 November 2011 05:47] by Moderator

Re: [QVTo] Cast EObject to Meta-Model Type [message #756359 is a reply to message #756352] Sat, 12 November 2011 06:16 Go to previous messageGo to next message
Eclipse UserFriend
On 12/11/2011 10:43, Supra wrote:
> Thanks for the quick reply. Actually the type is called "Control". I
> only simplified it for the post.
Then I suspect that oclAsType is correctly reporting the OCL equivalent
of a Java Class Cast Exception for an illegal type conversion.

Regards

Ed Willink
Re: [QVTo] Cast EObject to Meta-Model Type [message #756385 is a reply to message #756359] Sat, 12 November 2011 09:19 Go to previous message
Eclipse UserFriend
Thanks again for your quick reply.
I solved it.
The problem was that I passed a model that was not compatible with the model that I defined in the transformation. Unfortunately both meta-models used similar types so I didn't recognize the type miss-match. Type-safe transformation parameters would have helped to identify the problem earlier.
Anyways thanks for your help!
Previous Topic:[ATL] Same emf resource as input & output
Next Topic:[ATL] Launch UML2OWL on Helios
Goto Forum:
  


Current Time: Sun Apr 20 07:04:09 EDT 2025

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

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

Back to the top