I have an annotated JAXB class saying
@XmlRootElement(namespace = "http://www.abc.com/customer")
Class Customer{
@XmlElement(namespace = "http://www.abc.com/customer")
private String Name;
@XmlElement(namespace = "http://www.abc.com/customer")
private String Address;
@XmlTransient
private HashSet set = new HashSet();
public String getName(){
return Name;
}
public void setName(String name){
this.Name = name;
set.add("Name");
}
public String getAddress(){
return Address;
}
public void setAddress(String address){
this.Address = address;
set.add("Address");
}
public void getSet(){
return set;
}
I have an XML form
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Customer xmlns="http://www.abc.com/customer" >
<Name>Ralph</Name>
<Address>Newton Street</Address>
</Customer>
I use JAXB unmarshalling to get a view of the XML input object. The values for the name and address are set correctly. However, the value of set is lost (since it is @XMLTransient, it is ignored)
Is there a way to ensure that it is still installed in an object that has been unarmalized? Any other annotation I can use?
source
share