Friday, May 18, 2012

JAXB: XSD datatypes mapping to Java DataTypes

Below is the list of mappings from XSD data types to Java data types
XSD types Java DataTypes
bytebyte
intint
integerjava.math.BigInteger
decimaljava.math.BigDecimal
longlong
floatfloat
doubledouble
durationjavax.xml.datatype.Duration
datejavax.xml.datatype.XMLGregorianCalendar
dateTimejavax.xml.datatype.XMLGregorianCalendar
stringjava.lang.String
nonNegativeIntegerjava.math.BigInteger
nonPositiveIntegerjava.math.BigInteger
unsignedByteshort
unsignedIntlong
unsignedLongjava.math.BigInteger
unsignedShortint
anyURIjava.lang.String
base64Binarybyte [] (byte array)
booleanboolean
ENTITIESList
ENTITYjava.lang.String
timejavax.xml.datatype.XMLGregorianCalendar
gDayjavax.xml.datatype.XMLGregorianCalendar
gMonthjavax.xml.datatype.XMLGregorianCalendar
gYearjavax.xml.datatype.XMLGregorianCalendar
gMonthDay javax.xml.datatype.XMLGregorianCalendar
gYearMonthjavax.xml.datatype.XMLGregorianCalendar
Whatever data types are not there in Java JAXB has created appropriate datatypes in their API, for example, XMLGregorainCalendar. Now the question is how to convert it our facourite dataypes like java.util.Date or java.sql.Date or java.util.Calendar etc. You can probably write an Adaptor class which has static methods to do all these conversion.

No comments:

Post a Comment