public static void escape(StrBuilder toAppend,String text,boolean escapeQuote,boolean escapeApos){
  if (text == null) {
    return;
  }
  for (int i=0; i < text.length(); i++) {
    char ch=text.charAt(i);
switch (ch) {
case '<':
      toAppend.append("&lt;");
    break;
case '>':
  toAppend.append("&gt;");
break;
case '&':
toAppend.append("&amp;");
break;
case '"':
toAppend.append(escapeQuote ? "&quot;" : ch);
break;
case '\'':
toAppend.append(escapeApos ? "&apos;" : ch);
break;
default :
toAppend.append(ch);
break;
}
}
}

public static void escape ( StrBuilder toAppend , String text , boolean escapeQuote , boolean escapeApos ) { if ( text == null ) { return ; } for ( int i = 0 ; i < text . length ( ) ; i ++ ) { char ch = text . charAt ( i ) ; switch ( ch ) { case '<' : toAppend . append ( "&lt;" ) ; break ; case '>' : toAppend . append ( "&gt;" ) ; break ; case '&' : toAppend . append ( "&amp;" ) ; break ; case '"' : toAppend . append ( escapeQuote ? "&quot;" : ch ) ; break ; case '\'' : toAppend . append ( escapeApos ? "&apos;" : ch ) ; break ; default : toAppend . append ( ch ) ; break ; } } }
escapes any xml entities in the text , appending the result to the strbuilder .
