From the javadoc for SimpleValue - "All XmlObject implementations can be coerced to SimpleValue"
So the correct approach would be:
//to get the string value
((SimpleValue)obj).getStringValue();
//to set the string value
((SimpleValue)obj).setStringValue("n2");