static public void appendEscapingCDATA(final StringBuffer buf,final String str){
  if (str != null) {
    int end=str.indexOf(CDATA_END);
    if (end < 0) {
      buf.append(str);
    }
 else {
      int start=0;
      while (end > -1) {
        buf.append(str.substring(start,end));
        buf.append(CDATA_EMBEDED_END);
        start=end + CDATA_END_LEN;
        if (start < str.length()) {
          end=str.indexOf(CDATA_END,start);
        }
 else {
          return;
        }
      }
      buf.append(str.substring(start));
    }
  }
}

static public void appendEscapingCDATA ( final StringBuffer buf , final String str ) { if ( str != null ) { int end = str . indexOf ( CDATA_END ) ; if ( end < 0 ) { buf . append ( str ) ; } else { int start = 0 ; while ( end > - 1 ) { buf . append ( str . substring ( start , end ) ) ; buf . append ( CDATA_EMBEDED_END ) ; start = end + CDATA_END_LEN ; if ( start < str . length ( ) ) { end = str . indexOf ( CDATA_END , start ) ; } else { return ; } } buf . append ( str . substring ( start ) ) ; } } }
ensures that embeded cdend strings ( ] ] > ) are handled properly within message , ndc and throwable tag text .
