|
|
|
|
|
|
|
Re: convertion from string to BigDecimal [message #1053173 is a reply to message #1053115] |
Thu, 02 May 2013 19:58 |
|
Op 02-05-13 16:06, samar sousou schreef:
> I tried the solution with toReal() but the error shows "The value of type
> 'class java.lang.Double' must be of type 'class java.math.BigDecimal'"
> I need your help,
> thank you.
BigDecimals are not supported by regular ATL, AFAIK. String::toReal() gives
you a Double.
In EMFTVM, you can try the following:
"#native"!"java::math::BigDecimal".refNewInstance(Sequence{'42.42'})
....or pick any other BigDecimal constructor you like from
http://docs.oracle.com/javase/1.5.0/docs/api/java/math/BigDecimal.html
Unfortunately the conversion to BigDecimal still isn't automatic, so explicit
conversion remains necessary.
Regards,
Dennis
Cheers,
Dennis
|
|
|
|
|
|
Re: convertion from string to BigDecimal [message #1053436 is a reply to message #1053340] |
Sun, 05 May 2013 17:45 |
|
Op 04-05-13 08:22, samar sousou schreef:
> But How can i do the conversation from String to BigDecimal.
> because right now i have the same problem "The value of type 'class
> java.lang.String' must be of type 'class java.math.BigDecimal'"
>
> thanks
> Samar.
Ok, let's try this:
-- @atlcompiler emftvm
module ...;
create ...;
helper context String def : toBigDecimal() : "#native"!"java::math::BigDecimal" =
"#native"!"java::math::BigDecimal".refNewInstance(Sequence{self});
rule ... {
from s : ...
to t : ... (
bigDecimalAttribute <- s.stringAttribute.toBigDecimal()
)
}
Regards,
Dennis
Cheers,
Dennis
|
|
|
|
Powered by
FUDForum. Page generated in 0.02333 seconds