Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    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 10:24 Go to next message
Supra  is currently offline Supra Friend
Messages: 3
Registered: August 2011
Junior Member
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 10:31 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
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 10:43 Go to previous messageGo to next message
Supra  is currently offline Supra Friend
Messages: 3
Registered: August 2011
Junior Member
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 10:47]

Report message to a moderator

Re: [QVTo] Cast EObject to Meta-Model Type [message #756359 is a reply to message #756352] Sat, 12 November 2011 11:16 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
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 14:19 Go to previous message
Supra  is currently offline Supra Friend
Messages: 3
Registered: August 2011
Junior Member
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: Fri Mar 29 14:08:52 GMT 2024

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

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

Back to the top