Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » OCLinEcore. How the set a attribute of type java.lang.Locale
OCLinEcore. How the set a attribute of type java.lang.Locale [message #1853236] Thu, 23 June 2022 17:27 Go to next message
Steve Peters is currently offline Steve PetersFriend
Messages: 12
Registered: September 2020
Junior Member
I have an EMF Model like this:

class Text
{
attribute text : String[1];
attribute local : Locale[1];
}
datatype Locale : 'java.lang.Locale' { serializable };

It is possible to insert a string and convert it into java Locale Object in the dynamic instance(XMI)?
Re: OCLinEcore. How the set a attribute of type java.lang.Locale [message #1853255 is a reply to message #1853236] Fri, 24 June 2022 09:51 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

Yes and No.

Part of the OCL test suite comprises:

		ocl.assertQueryTrue(null, "ecore::EDate{'2000-01-24'} <= ecore::EDate{value='2000-01-24'}");


so yes, string constructed data types are supported.

However the above uses Ecore's EDate mapping to java.util.Date and the custom implementation in EcoreFactoryImpl.createEDateFromString.

Locale has a single argument String constructor, so you may be lucky and find that Ecore's fallback to String works without any effort by you. More likely you will need to genmodel and manually implement createLocaleFromString to avoid the IllegalArgumentException at the end of EcoreFactoryImpl.createFromString.

That said, I must question the wisdom of using the non-String when the String would avoid problems.

Regards

Ed Willink
Re: OCLinEcore. How the set a attribute of type java.lang.Locale [message #1853267 is a reply to message #1853255] Fri, 24 June 2022 14:36 Go to previous message
Steve Peters is currently offline Steve PetersFriend
Messages: 12
Registered: September 2020
Junior Member
Thanks for that hint. In the diagram there're two sections for custom code for an own DataType.
https://i.ibb.co/YX88Z0t/locale-ecore.png

[Updated on: Fri, 24 June 2022 14:37]

Report message to a moderator

Previous Topic:Check stereotype applications via static profile
Next Topic:Validation Delegate noy found
Goto Forum:
  


Current Time: Fri Apr 26 19:30:06 GMT 2024

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

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

Back to the top