Is there a way to force JAXB to generate methods that do NOT take or return primitive values as parameters. For example, how do I force JAXB to ALWAYS map "boolean" xml type to java.lang.Boolean java type?
Also, does anybody have any ideas on the following?
Thanks.
Alec Swan <aukcioner_at_yahoo.com> wrote: I am using JAXB to generate POJO classes from my XML schema. I then send generated POJOs via XmlRpc by marshalling and unmarshalling them. I use Introspector API to marshall and unmarshall POJOs and it often fails because of the way JAXB generates getter and setter methods for optional attributes.
The problem I am facing is that I have an XML complexType TMachine, which has an optional attribute Remote, which default value is FALSE. For this XML type, JAXB generates a Java class with the following methods:
public boolean isRemote() {
if (remote == null) {
return false;
} else {
return remote;
}
}
public void setRemote(Boolean value) {
this.remote = value;
}
Note that the getter isRemote() method returns a primitive boolean type and the setter setRemote(..) take an object of class Boolean as a parameter. Therefore, when I use Introspector API it fails to map these two methods to the bean descriptor of the remote field. I guess Introspector doesn't account for autoboxing .
My question is how to force JAXB to generate getter and setter methods that return and take obejcts of the same class. So, in the example above I would like to have getRemote() method to return Boolean.
Thanks.