How can I remove leading/trailing white space before/while marshalling in JAXB?
+2
A:
You could use CollapsedStringAdapter
:
public class MyClass {
@XmlJavaTypeAdapter(CollapsedStringAdapter.class)
private String field;
}
This adapter removes leading and trailing whitespaces, then truncate any sequnce of tab, CR, LF, and SP by a single whitespace character ' '.
skaffman
2010-05-30 13:30:00
is there any way to put this on all fields with String data type when generating classes using xjc?
mabuzer
2010-05-30 13:32:45