Reputation: 186
I'm working with JavaTypes and I want to transform a JavaType to XsdType. I did not found a simple way to do this, and finally created an method that given a JavaType returns the associated XsdType.
Example:
toXsdType(String.class.getName()); --> "xsd:string"
In order to achieve this, I'm doing an UGLY switch statement.
Is there a clean way to do it, using JAXB or another library?
Upvotes: 2
Views: 43
Reputation: 43671
You might be interested in TypeInfoSet.getTypeInfo(T type)
which gives you an XML type for the given Java type.
As for the TypeInfoSet
, you can obtain it via JAXBContextImpl.getTypeInfoSet()
.
So basically the whole process would look like:
JAXBContext
with RI, cast it to JAXBContextImpl
.TypeInfoSet
.NonElement
for your Java type.QName
using NonElement.getTypeName()
.Upvotes: 4