[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.tools.emf] Re: Serialization: additional date formats

Jason,

Comments below.

jason henriksen wrote:

Hi guys,

In a related note, I'm not so concerned about the format of the time string in XML, but I really don't like XMLGregorianCalendar because IBM, Sun and Apache all do it slightly differently in a way that ends up giving me ClassCast exceptions.
Yes, I was ranting about the sad state of the XML world in this regard. I mean geesh, it's an abstract base class. You must do all your comparisons and other work assuming only that it implements the base class. How hard is that?

So I've had an idea for a solution that I wanted to bounce off you guys:

I'm going to use xsd:dateTime, XMLGregorianCalender (here after refered to as XGC) and so on just as it is during normal XSD/EMF generation. This is nice because Teneo expects the calendars and should continue to work. But since I want to present Joda-Time as the interface to my developers I'm going to add a step after my EMF generation.

My post processing step will use the code refactoring abilities of eclipse to find any EMF-generated method that accepts or returns XGC and then wraps that with a method that takes joda-time objects. I'll then mark the XGC methods deprecated. I'll also update the @generated tags and rename the wrapped method with "Gen" at the end of it so that EMF will still update the methods and not mess with my post-generated wrapper methods.

Does that sound reasonable to you guys? The post-processor shouldn't be too hard to set up, and it will keep my developers from class casting themselves into a tizzy.
Another possible approach, depending on how you've defined your model, is to suppress the XGC accessors from the API, but leave them in the Impl as is. Then define EOperation (you'd have to pick a different name that doesn't collide) to get and set the Joda thing and to delegate through the XGC methods in the impl; you can do this feature a body annotation that lets you specify the Java snippet right on the operation definition. This way everything you'd need could be specified right in your model and it would produce working code right out of the box...

I can give some more details if you're interested...

Jason Henriksen

Ed Merks wrote:
Jan,

The answer depends on the EMF version. Before 2.3 we could not rely on anything not in the 1.4 JDK, so we had our own interface class like XMLGregorianCalendar. To hide it, we only surfaced java.lang.Object. Now in 2.3 or greater, we surface it as XMLGegorianCalendar in the APIs. You can get at the data type in XMLTypePackage from UML right?