Skip to main content



      Home
Home » Modeling » ATL » convertion from string to BigDecimal
convertion from string to BigDecimal [message #1023967] Mon, 25 March 2013 11:03 Go to next message
Eclipse UserFriend
Hi,
I can't convert my data type from String to BigDecimal anad i don't know how!!!
please help me
Re: convertion from string to BigDecimal [message #1024014 is a reply to message #1023967] Mon, 25 March 2013 12:33 Go to previous messageGo to next message
Eclipse UserFriend
Hi

EMF does it for you.

Since you have given us no clue at all as to what you tried, we can't
see what you did wrong.

Regards

Ed Willink



On 25/03/2013 15:03, samar sousou wrote:
> Hi,
> I can't convert my data type from String to BigDecimal anad i don't
> know how!!!
> please help me
Re: convertion from string to BigDecimal [message #1024046 is a reply to message #1024014] Mon, 25 March 2013 13:59 Go to previous messageGo to next message
Eclipse UserFriend
Hi,
But the conversation is on the atl transformation not for the code java.
Re: convertion from string to BigDecimal [message #1025290 is a reply to message #1024046] Tue, 26 March 2013 06:30 Go to previous messageGo to next message
Eclipse UserFriend
Please help me,
I have an attribute value in xml.ecore which is String and i have an attribute coord in the sas.ecore my target .ecore which is an EBigDecimal!!
so how to do this transformation with atl!!

thank you.
Re: convertion from string to BigDecimal [message #1026606 is a reply to message #1025290] Tue, 26 March 2013 08:05 Go to previous messageGo to next message
Eclipse UserFriend
HI

Have you tried String.toReal() ?

Regards

Ed Willink


On 26/03/2013 10:30, samar sousou wrote:
> Please help me,
> I have an attribute value in xml.ecore which is String and i have an
> attribute coord in the sas.ecore my target .ecore which is an
> EBigDecimal!!
> so how to do this transformation with atl!!
>
> thank you.
Re: convertion from string to BigDecimal [message #1027129 is a reply to message #1027053] Tue, 26 March 2013 11:35 Go to previous messageGo to next message
Eclipse UserFriend
As said by Ed, ATL provides the "toReal" operation on Strings (cf. the corresponding entry in the ATL manual).
However the string has to be "convertible", i.e.; correctly formatted.

Hhugo
Re: convertion from string to BigDecimal [message #1053115 is a reply to message #1027129] Thu, 02 May 2013 10:06 Go to previous messageGo to next message
Eclipse UserFriend
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.
Re: convertion from string to BigDecimal [message #1053173 is a reply to message #1053115] Thu, 02 May 2013 15:58 Go to previous messageGo to next message
Eclipse UserFriend
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
Re: convertion from string to BigDecimal [message #1053228 is a reply to message #1027129] Fri, 03 May 2013 05:17 Go to previous messageGo to next message
Eclipse UserFriend
Hi Mr Dennis,
thank you for your response.
Have you a tutorial about the EMFTVM or an exemple because I couldn't understand.

thanks.
Samar.
Re: convertion from string to BigDecimal [message #1053291 is a reply to message #1053228] Fri, 03 May 2013 11:39 Go to previous messageGo to next message
Eclipse UserFriend
Op 03-05-13 11:17, samar sousou schreef:
> Hi Mr Dennis,
> thank you for your response.
> Have you a tutorial about the EMFTVM or an exemple because I couldn't understand.
>
> thanks.
> Samar.

http://wiki.eclipse.org/ATL/EMFTVM#Installation
Re: convertion from string to BigDecimal [message #1053340 is a reply to message #1053291] Sat, 04 May 2013 02:22 Go to previous messageGo to next message
Eclipse UserFriend
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.
Re: convertion from string to BigDecimal [message #1053436 is a reply to message #1053340] Sun, 05 May 2013 13:45 Go to previous messageGo to next message
Eclipse UserFriend
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
Re: convertion from string to BigDecimal [message #1053468 is a reply to message #1023967] Mon, 06 May 2013 03:26 Go to previous message
Eclipse UserFriend
Hi Mr Dennis,
thank you very much. it works.
I have an other question:
for the enumerate type how to do the conversation from the String!

thanks,
Samar.
Previous Topic:Problem MyRules.asm does not exist
Next Topic:the error of runing ATL transformations in Java
Goto Forum:
  


Current Time: Wed Jul 23 15:18:48 EDT 2025

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

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

Back to the top