Simon Hutchinson wrote:
> A call to the getElement() property in the XJC generated class returns a
> javax.xml.bind.JAXBElement - I can subsequently call getValue() on this
> element to return the string. However I know that this element will only
> ever return a String type. Is there any way that I can force the
> compiler to allow getElement() to return a string as opposed to a
> JAXBElement?
Until recently we generated the getElement method as:
JAXBElement getElement();
But by now we should be generating:
JAXBElement<String> getElement();
Other than that, I'm afraid you have to getElement().getValue().
You might be able to use the code-injector plugin to get a helper method
injected into the class XJC generates, or you can manually modify the
generated code.
--
Kohsuke Kawaguchi
Sun Microsystems kohsuke.kawaguchi_at_sun.com