|
Re: [QVTo] Switch-statement with OclIsTypeOf()-function [message #527285 is a reply to message #527224] |
Wed, 14 April 2010 16:28 |
PBarendrecht Messages: 36 Registered: November 2009 Location: Eindhoven, Netherlands |
Member |
|
|
Hi Chris,
Hmm, I'm not sure whether you can use the switch statement in this way. When I use it, I don't prefix it with a set or something, just the switch statement on itself.
Tip, when you press "Ctrl + Space" in Eclipse, a pop-up window with code with possibilities appears (use this combination again for the so-called "Template Proposals").
Furthermore, oclIsTypeOf() needs an argument and returns a Boolean value. Maybe you can use the function metaClassName() which returns a string. However, I think it doesn't work when you work with basic types like Integer.
Maybe the _localId() and _globalId() functions are useful, but they are not yet implemented . There must be a function which can return the type of all types, because the oclIstypeOf() function compares this result with the argument.
Maybe there is some other OCL function available? I don't see it in the mentioned pop-up, but who knows
Oh by the way, I finished my Bachelor Thesis, you can download it at my site. It discusses QVTo in a bit more detail than the tutorial on my site.
|
|
|
Re: [QVTo] Switch-statement with OclIsTypeOf()-function [message #527491 is a reply to message #527285] |
Thu, 15 April 2010 12:55 |
C. Kopf Messages: 37 Registered: November 2009 |
Member |
|
|
Hi P.,
first of all congratulations to your BSc! I hope it was as good as you expected it to be - well I am somewhat sure it was, right?
Quote: | Hmm, I'm not sure whether you can use the switch statement in this way.
|
me neither.
Quote: | When I use it, I don't prefix it with a set or something, just the switch statement on itself.
|
I also tested this, but anyway good that you mentioned it again, see below!
Quote: | Furthermore, oclIsTypeOf() needs an argument and returns a Boolean value.
|
Yes, just as I expected.
Quote: | Maybe you can use the function metaClassName() which returns a string. However, I think it doesn't work when you work with basic types like Integer.
|
Well, QVTo/OCL basic types are not of interest in my purpose, but anyway: the way I used the switch statement does not work with metaClassName() as well.
Quote: | Maybe the _localId() and _globalId() functions are useful, but they are not yet implemented . There must be a function which can return the type of all types, because the oclIstypeOf() function compares this result with the argument. (...) Maybe there is some other OCL function available
|
This is just what I am looking for. Well I am still searching, if I find it I shall post it here.
Anyway, by now I found a solution which helps me along. Although it is not as nice as the one mentioned, it is easy read- and understandable:
query getNameOfPrimitiveType(in type:Datatype) : String {
var resultString:String;
var className:String := type.metaClassName();
switch {
case (type.oclIsTypeOf(OpaqueType)) resultString := "Bitstring";
case (type.oclIsTypeOf(BooleanType)) resultString := "Boolean";
case (type.oclIsTypeOf(IntegerType)) resultString := "Integer";
case (type.oclIsTypeOf(RealType)) resultString := "Float";
case (type.oclIsTypeOf(StringType)) resultString := "Charstring";
else resultString := "not found";
};
return resultString;
}
I got the idea, as I combined the options from "Ctrl + Space" and your word saying "I don't prefix it" and "oclIsTypeOf() needs an argument and returns a Boolean value".
Thanks!
btw: I am curious about having a look upon your bachelor thesis. So I got something to read at the weekend.
Cheers,
Chris
|
|
|
Powered by
FUDForum. Page generated in 0.02720 seconds