So,
I’m trying to convert a Representation to a String or a StringWriter either using the getText() or write() method. It seems I can only call this method once successfully on a Representation… If I call the method again, it returns null or empty string on the second call. Why is this? I’d expect it to return the same thing every time:
public void SomeMethod(Representation rep)
{
String repAsString = rep.getText(); // returns valid text for example: <someXml>Hello WOrld</someXml>
String repAsString2 = rep.getText(); // returns null... wtf?
}
If I’m “doing it wrong” then I’d be open to any suggestions as to how I can get to that data.
The javadocs explain this:
So presumably it’s being read directly from the network or something similar.
You can check this by calling
isTransient(). If you need to be able to read it multiple times, presumably you should convert it to a string and then create a newRepresentationfrom that string.