Exemplo n.º 1
0
 /**
  * strips a subset of HTML that tends to appear in descriptions generated by Groundspeak Builder
  */
 public static String removeHtml(String s) {
   if (s == null) return "";
   StringBuffer sb = new StringBuffer(s.length());
   replace(s, "<BR>", "\n", sb);
   replace(sb.toString(), "&nbsp;", " ", sb);
   replace(sb.toString(), "&lt;", "<", sb);
   replace(sb.toString(), "&gt;", ">", sb);
   replace(sb.toString(), "&amp;", "&", sb);
   return sb.toString();
 }
Exemplo n.º 2
0
 private static void replace(String source, String pattern, String replace, StringBuffer builder) {
   int pos = 0;
   int pl = pattern.length();
   builder.delete(0, builder.length());
   while (pos < source.length()) {
     int np = source.indexOf(pattern, pos);
     if (np == -1) break;
     builder.append(source.substring(pos, np));
     builder.append(replace);
     pos = np + pl;
   }
   builder.append(source.substring(pos));
 }