Description
Given the xml of:
<project><text> </text></project>
and the Text.java of:
public class Text {
private String content;
public Text() {
}
@JacksonXmlText
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
}
The setContent method will be called with the whitespace contained in <text>
. However, if I add (with Text.java having "id" as an attribute):
<project><text id="test"> </text></project>
The setContent call will be skipped when it only contains whitespace. However, non-whitespace only text:
<project><text id="test">hello world!</text></project>
would have setContent with "hello world!" passed in
Additionally, if I were to use the xml:
<project><text> </text><text>hello world!</text></project>
...and have Project contain a List of Texts (whether wrapped or unwrapped), it will result in the same failure. The second Text object will have the contents of "hello world!", but the first will contain null rather than it's whitespace.
I'm struggling with how to work around this as the items I'm dealing with really represent text in a document and sometimes I will have empty strings (which have meaning, but I could deal with those being null) or whitespace (spaces) which have meaning.