I want to make sure that an xml element-content is unmarshalled in upper case on my object.
public class SZM {
String field01;
@XmlElement(name="field01")
public void setField01(String value) {this.field01 = value.toUpperCase();}
public String getField01() {return field01;}
but how to do the same thing for every item in a collection? I want that any value read from the xml is capitalized.
@XmlElement
ArrayList<String>collection01;
Thanks in advance,
Agostino
all the class, just in case:
package test.jaxb;
import java.util.ArrayList;
import javax.xml.bind.annotation.*;
@XmlRootElement
public class SZM {
String field01;
@XmlElement(name="field01")
public void setField01(String value) {this.field01 = value.toUpperCase();}
public String getField01() {return field01;}
@XmlElement
ArrayList<String>collection01;
}
You can use an XmlAdapter to manipulate the String values:
StringCaseAdapter
SZM
You reference the XmlAdapter as:
input.xml
Demo
Output