users@jaxb.java.net

Re: conditional adapter?

From: Kenny MacLeod <kennym_at_kizoom.com>
Date: Thu, 06 Sep 2007 09:02:28 +0100

well you could push the date field down into the subclasses and use a
different adaptor for each one.

I would say that java.util.Date is a poor fit for the gMonthYear type
anyway, which is more of an interval than a point in time.

I suggest that you use the JodaTime API when you want properly
structured date/times. In the case of xsd:datetime,
org.joda.time.LocalDate is a good fit, for example. gMonthYear is
trickier, but JodaTime has a pretty rich API for this sort of thing.

Dmitri Colebatch wrote:
> Hi all,
>
> I've got a model that has the following structure:
>
> abstract class AbstractOrder
> {
> @XmlJavaTypeAdapter(XSDDateAdapter.class)
> Date date;
> }
>
> class PurchaseOrder
> {
> // ...
> }
>
> class ForecastOrder
> {
> // ...
> }
>
> this maps to:
>
> <xsd:element name="PurchaseOrder">
> ...
> <xsd:element name="Date" type="xsd:date" />
> ...
> </xsd:element>
>
> <xsd:element name="ForecastOrder">
> ...
> <xsd:element name="Date" type="xsd:gYearMonth" />
> ...
> </xsd:element>
>
> Obviously the above doesn't work as I want my XSDDateAdapter to return
> a different amount of information depending on whether the order is a
> purchase order or a forecast order.
>
> Does anyone have any suggestions for how to do this?
>
> cheers,
> dim
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
> For additional commands, e-mail: users-help_at_jaxb.dev.java.net
>