Given a class like this:
public class Person {
private String firstname;
private String lastname;
private PhoneNumber phone;
private PhoneNumber fax;
// ... constructors and methods
private void calculate()
{
}
}
And an Xstream object like this:
XStream xstream = new XStream(new DomDriver());
Person joe = new Person("Joe", "Walnes");
joe.setPhone(new PhoneNumber(123, "1234-456"));
joe.setFax(new PhoneNumber(123, "9999-999"));
String xml = xstream.toXML(joe);
The resulting XML looks like this:
<person>
<firstname>Joe</firstname>
<lastname>Walnes</lastname>
<phone>
<code>123</code>
<number>1234-456</number>
</phone>
<fax>
<code>123</code>
<number>9999-999</number>
</fax>
</person>
Deserializing an object back from XML looks like this:
Person newJoe = (Person)xstream.fromXML(xml);
After the Person is deserialized is it possible to execute newJoe.calculate() method?
Can the value of the number present in person class be changed to another one like newJoe.number = 4545;