MCPcopy Create free account
hub / github.com/beanshell/beanshell / escape

Method escape

src/bsh/servlet/BshServlet.java:285–303  ·  view source on GitHub ↗

Convert special characters to entities for XML output

(String value)

Source from the content-addressed store, hash-verified

283 * Convert special characters to entities for XML output
284 */
285 public static String escape(String value)
286 {
287 String search = "&<>";
288 String[] replace = {"&amp;", "&lt;", "&gt;"};
289
290 StringBuffer buf = new StringBuffer();
291
292 for (int i = 0; i < value.length(); i++)
293 {
294 char c = value.charAt(i);
295 int pos = search.indexOf(c);
296 if (pos < 0)
297 buf.append(c);
298 else
299 buf.append(replace[pos]);
300 }
301
302 return buf.toString();
303 }
304
305}
306

Callers 1

Calls 2

appendMethod · 0.80
toStringMethod · 0.45

Tested by

no test coverage detected