Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Data Types for complex types such as Currency and Time
Data Types for complex types such as Currency and Time [message #673675] Tue, 24 May 2011 13:00 Go to next message
Nidhi  is currently offline Nidhi Friend
Messages: 92
Registered: December 2009
Member

Hi,

I wanted to know what is the best way to represent a complex type such as Currency or Time is EMF.

These data type not only have a value but also units, that are important. For eg. currency could be "100 $" and Time could be "120 milliseconds".

Within my domain ECore model, many model entities (EClasses) need to define attributes with Currency or Time as their type. I don't want to create an EClassifier for Currency and Time and later reference them from other model entities as they cannot be persisted under one container and need to be persisted in all the model elements that use them.

Any help would be really appreciated.

Thanks,
Nidhi

[Updated on: Wed, 25 May 2011 13:39]

Report message to a moderator

Re: Data Types for complex types such as Currency and Time [message #674546 is a reply to message #673675] Fri, 27 May 2011 10:30 Go to previous message
Martin  odloucký is currently offline Martin odlouckýFriend
Messages: 49
Registered: July 2010
Member
Hi,

why don't you just create Currency and Time as plain java classes and then create EDataTypes for them? Only thing you then need is to implement conversion between String and your types in the model factory and you have serialization and everything.

Martin
Re: Data Types for complex types such as Currency and Time [message #687040 is a reply to message #673675] Tue, 24 May 2011 13:45 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 30452
Registered: July 2009
Senior Member
Nidhi,

Comments below.

Nidhi wrote:
> Hi,
>
> I wanted to know what is the best way to represent a complex type such
> as Currency or Time is EMF.
>
> These data type not only have a value but also units, that are
> important. For eg. currency could be "100 $" and Time could be "120
> milliseconds".
In the end, if you think about it, most values represent values in some
type of unit, but the unit is implicit.
> Within my domain ECore model, many model entities (EClasses) need to
> define attributes with Currency or Time as their type. I don't want to
> create an EClassifier for Currency and Time and later reference them
> from other model entities as they cannot be persisted under one
> container and need to be persisted in all the model elements that use
> them.
Yes, these types of things should be EDataTypes. Look at XML Schema as
an example of how various units of time are represented, and then look
at how they're represented in Java.
>
> Any help would be really appreciated.
In the end, I'm not sure your question is so much an EMF one but a Java
one. I think it's best to come up with a good Java representation and
that wrap that with an EDataType...
>
> Thanks,
> Nidhi
Re: Data Types for complex types such as Currency and Time [message #687053 is a reply to message #687040] Wed, 25 May 2011 21:09 Go to previous message
Eclipse UserFriend
Originally posted by:

I recommend using JScience (http://jscience.org/) and as Ed suggests,
implement EDataTypes for their classes.

Hallvard

On 24.05.11 15.45, Ed Merks wrote:
> Nidhi,
>
> Comments below.
>
> Nidhi wrote:
>> Hi,
>>
>> I wanted to know what is the best way to represent a complex type such
>> as Currency or Time is EMF.
>>
>> These data type not only have a value but also units, that are
>> important. For eg. currency could be "100 $" and Time could be "120
>> milliseconds".
> In the end, if you think about it, most values represent values in some
> type of unit, but the unit is implicit.
>> Within my domain ECore model, many model entities (EClasses) need to
>> define attributes with Currency or Time as their type. I don't want to
>> create an EClassifier for Currency and Time and later reference them
>> from other model entities as they cannot be persisted under one
>> container and need to be persisted in all the model elements that use
>> them.
> Yes, these types of things should be EDataTypes. Look at XML Schema as
> an example of how various units of time are represented, and then look
> at how they're represented in Java.
>>
>> Any help would be really appreciated.
> In the end, I'm not sure your question is so much an EMF one but a Java
> one. I think it's best to come up with a good Java representation and
> that wrap that with an EDataType...
>>
>> Thanks,
>> Nidhi
Re: Data Types for complex types such as Currency and Time [message #687241 is a reply to message #673675] Tue, 24 May 2011 13:45 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 30452
Registered: July 2009
Senior Member
Nidhi,

Comments below.

Nidhi wrote:
> Hi,
>
> I wanted to know what is the best way to represent a complex type such
> as Currency or Time is EMF.
>
> These data type not only have a value but also units, that are
> important. For eg. currency could be "100 $" and Time could be "120
> milliseconds".
In the end, if you think about it, most values represent values in some
type of unit, but the unit is implicit.
> Within my domain ECore model, many model entities (EClasses) need to
> define attributes with Currency or Time as their type. I don't want to
> create an EClassifier for Currency and Time and later reference them
> from other model entities as they cannot be persisted under one
> container and need to be persisted in all the model elements that use
> them.
Yes, these types of things should be EDataTypes. Look at XML Schema as
an example of how various units of time are represented, and then look
at how they're represented in Java.
>
> Any help would be really appreciated.
In the end, I'm not sure your question is so much an EMF one but a Java
one. I think it's best to come up with a good Java representation and
that wrap that with an EDataType...
>
> Thanks,
> Nidhi
Re: Data Types for complex types such as Currency and Time [message #687257 is a reply to message #687040] Wed, 25 May 2011 21:09 Go to previous message
Eclipse UserFriend
Originally posted by:

I recommend using JScience (http://jscience.org/) and as Ed suggests,
implement EDataTypes for their classes.

Hallvard

On 24.05.11 15.45, Ed Merks wrote:
> Nidhi,
>
> Comments below.
>
> Nidhi wrote:
>> Hi,
>>
>> I wanted to know what is the best way to represent a complex type such
>> as Currency or Time is EMF.
>>
>> These data type not only have a value but also units, that are
>> important. For eg. currency could be "100 $" and Time could be "120
>> milliseconds".
> In the end, if you think about it, most values represent values in some
> type of unit, but the unit is implicit.
>> Within my domain ECore model, many model entities (EClasses) need to
>> define attributes with Currency or Time as their type. I don't want to
>> create an EClassifier for Currency and Time and later reference them
>> from other model entities as they cannot be persisted under one
>> container and need to be persisted in all the model elements that use
>> them.
> Yes, these types of things should be EDataTypes. Look at XML Schema as
> an example of how various units of time are represented, and then look
> at how they're represented in Java.
>>
>> Any help would be really appreciated.
> In the end, I'm not sure your question is so much an EMF one but a Java
> one. I think it's best to come up with a good Java representation and
> that wrap that with an EDataType...
>>
>> Thanks,
>> Nidhi
Previous Topic:(no subject)
Next Topic:(no subject)
Goto Forum:
  


Current Time: Fri Sep 20 09:31:29 GMT 2019

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

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

Back to the top