| From: | Jim Tivy |
| Sent on: | Wednesday, December 3, 2008 10:58 AM |
We are finding things like URI and String[] do not
automatically
Incidently, I think the annotations stuff is brilliant and
the interweaving of JaxB. But the implementation is catching up...
Looks like there is user defineable primitive type
mechanism. But I am not sure why they don't ship with these done for URI.
See this post from seajug
Although I haven't verified this completely, I think you should be able
to go either way. For instance, this mapping that I had in my XML schema:
<xs:annotation>
<xs:appinfo>
<jaxb:globalBindings>
<jaxb:serializable/>
<xjc:javaType name="java.sql.
</jaxb:globalBinding
</xs:appinfo>
</xs:annotation>
<xs:simpleType name="TimestampStri
<xs:annotation>
<xs:documentation>W3C Schema date-time
constrained to Zulu.</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:dateTime">
<xs:pattern value=".+Z"/>
</xs:restriction>
</xs:simpleType>
mapped to this in the generated JAXB object:
...
@XmlElement(
@XmlJavaTypeAdapter
protected Timestamp timestamp;
...
where TimeConverter is:
package com.ticomgeo.
import java.sql.Timestamp;
import java.util.TimeZone;
import javax.xml.bind.
public class TimeConverter extends XmlAdapter<String, Timestamp> {
static {
TimeZone.setDefault
}
@Override
public Timestamp unmarshal(String value) {
if (value == null) {
return null;
}
value = value.replace(
Timestamp t = Timestamp.valueOf(
return t;
}
@Override
public String marshal(Timestamp value) {
if (value == null) {
return null;
}
String datetime = value.toString(
return datetime;
}
public static void main(String args[]) {
Timestamp t = new Timestamp(System.
System.out.println(
TimeConverter tc = new TimeConverter(
System.out.println(
Timestamp t1 = tc.unmarshal(
System.out.println(
if (t1.equals(t)
System.out.println(
}
}
}
Jim Tivy
[masked] x116