Hi guys,
First attempt to use this cool site - after searching for 2 hours: So I have a Java Bean that is given (I can only annotate not change) and need to map it to XML using JAXB. I would like primitives types not to be printed when they contain their language default, or a user-defined default.
As said I cannot change the java bean, and therefore change the primitive types into their Object Wrappers counterparts.
How do you do that best?
Sample bean:
class Foo {
public String name;
// -1 is user defined default, to indicate field is not set.
public long someIdx=-1;
// ...
}
Foo f = new Foo();
f.name = "Duke";
for this instantiation, what I would like is the following output:
<foo><name>Duke</name></foo>