if (contents instanceof TCompoundString) {
((TCompoundString) contents).addString(string);
} else if (contents instanceof TSimpleString
&& string instanceof TSimpleString) {
TSimpleString simpleContents = (TSimpleString) contents;
String s1 = simpleContents.getContents();
String s2 = ((TSimpleString) string).getContents();
simpleContents.setContents(s1 + s2);
} else {
TCompoundString compound = new TCompoundString();
compound.addString(contents);
compound.addString(string);
contents = compound;