String (@NotNull String str) { StringBuilder sb = new StringBuilder(); int cur = 0; int len = str.length(); while (cur < len) { int next = Strings.indexOf(str, CDATA_END, cur); sb.append(CDATA_START).append(str.subSequence(cur, next = next < 0 ? len : next + 1)).append(CDATA_END); cur = next; } return sb.toString(); }