JAXB Java to XML: How not printing primitive type members when default -
After searching for 2 hours - the first attempt is to use this web site: so I have a Java Bean that has been given (I can do) does not change annotated only) and using it using JAXB XML is required to be mapped. I would not want to print the types of preferences when their language is default, or the user-defined default
As I said that I am Java B Can not change, and therefore the primitive types should be changed into their object wrapper counterparts.
How do you do the best?
Sample bean:
square fu {name of public string; // -1 is the default user defined, the field is not set to point. Public long someIdx = -1; // ...} fu f = new fu (); F.name = "Duke";
For this urgency, I would like the following output:
& lt; Foo & gt; & Lt; Name & gt; Duke & lt; / Name & gt; & Lt; / Foo & gt;
You can use JAXB's XmlAdapters after JAXB 2.0 (JDK 6.0) Beneficial
By using the adapter, you leave bean alone and annotate / change completely different class. It should not be a problem in your case.