Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » ATL » convertion from string to BigDecimal
convertion from string to BigDecimal [message #1023967] Mon, 25 March 2013 15:03 Go to next message
samar sousou is currently offline samar sousouFriend
Messages: 63
Registered: March 2013
Member
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 16:33 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
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 17:59 Go to previous messageGo to next message
samar sousou is currently offline samar sousouFriend
Messages: 63
Registered: March 2013
Member
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 10:30 Go to previous messageGo to next message
samar sousou is currently offline samar sousouFriend
Messages: 63
Registered: March 2013
Member
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 12:05 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
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 15:35 Go to previous messageGo to next message
Hugo Bruneliere is currently offline Hugo BruneliereFriend
Messages: 674
Registered: July 2009
Senior Member
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


--------------------------------------------------------
Hugo Bruneliere, PhD
NaoMod team (IMT Atlantique & LS2N-CNRS)
Nantes - France
--------------------------------------------------------
Re: convertion from string to BigDecimal [message #1053115 is a reply to message #1027129] Thu, 02 May 2013 14:06 Go to previous messageGo to next message
samar sousou is currently offline samar sousouFriend
Messages: 63
Registered: March 2013
Member
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 19:58 Go to previous messageGo to next message
Dennis Wagelaar is currently offline Dennis WagelaarFriend
Messages: 589
Registered: September 2012
Location: Belgium
Senior Member

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 #1053228 is a reply to message #1027129] Fri, 03 May 2013 09:17 Go to previous messageGo to next message
samar sousou is currently offline samar sousouFriend
Messages: 63
Registered: March 2013
Member
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 15:39 Go to previous messageGo to next message
Dennis Wagelaar is currently offline Dennis WagelaarFriend
Messages: 589
Registered: September 2012
Location: Belgium
Senior Member

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


Cheers,
Dennis
Re: convertion from string to BigDecimal [message #1053340 is a reply to message #1053291] Sat, 04 May 2013 06:22 Go to previous messageGo to next message
samar sousou is currently offline samar sousouFriend
Messages: 63
Registered: March 2013
Member
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 17:45 Go to previous messageGo to next message
Dennis Wagelaar is currently offline Dennis WagelaarFriend
Messages: 589
Registered: September 2012
Location: Belgium
Senior Member

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
Re: convertion from string to BigDecimal [message #1053468 is a reply to message #1023967] Mon, 06 May 2013 07:26 Go to previous message
samar sousou is currently offline samar sousouFriend
Messages: 63
Registered: March 2013
Member
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: Thu Apr 18 02:44:33 GMT 2024

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

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

Back to the top