@Test public void testReplaceIllegalCharsAttribute() { assertSame(EMPTY_STRING, replaceIllegalCharsAttribute(EMPTY_STRING)); assertEquals(null, replaceIllegalCharsAttribute(null)); assertEquals("&lt; Valid &quot;&amp;&quot; Symbols &gt;", replaceIllegalCharsAttribute(DECODED_VALUE)); }
public static String replaceIllegalCharsAttribute(final String value) { if (isEmpty(value)) { return value; } final StringBuilder sb = new StringBuilder(); for (int i = 0; i < value.length(); i++) { final char c = value.charAt(i); switch (c) { case '<': sb.append("&lt;"); break; case '>': sb.append("&gt;"); break; case '&': sb.append("&amp;"); break; case '"': sb.append("&quot;"); break; default: sb.append(c); break; } } return sb.toString(); }
StringUtils { public static String replaceIllegalCharsAttribute(final String value) { if (isEmpty(value)) { return value; } final StringBuilder sb = new StringBuilder(); for (int i = 0; i < value.length(); i++) { final char c = value.charAt(i); switch (c) { case '<': sb.append("&lt;"); break; case '>': sb.append("&gt;"); break; case '&': sb.append("&amp;"); break; case '"': sb.append("&quot;"); break; default: sb.append(c); break; } } return sb.toString(); } }
StringUtils { public static String replaceIllegalCharsAttribute(final String value) { if (isEmpty(value)) { return value; } final StringBuilder sb = new StringBuilder(); for (int i = 0; i < value.length(); i++) { final char c = value.charAt(i); switch (c) { case '<': sb.append("&lt;"); break; case '>': sb.append("&gt;"); break; case '&': sb.append("&amp;"); break; case '"': sb.append("&quot;"); break; default: sb.append(c); break; } } return sb.toString(); } private  StringUtils(); }
StringUtils { public static String replaceIllegalCharsAttribute(final String value) { if (isEmpty(value)) { return value; } final StringBuilder sb = new StringBuilder(); for (int i = 0; i < value.length(); i++) { final char c = value.charAt(i); switch (c) { case '<': sb.append("&lt;"); break; case '>': sb.append("&gt;"); break; case '&': sb.append("&amp;"); break; case '"': sb.append("&quot;"); break; default: sb.append(c); break; } } return sb.toString(); } private  StringUtils(); static boolean isEmpty(final String s); static boolean nonEmpty(final String s); static boolean hasNonEmpty(final String... values); static boolean isQuoted(String str); static String createQuotedString(final String str); static String createQuotedStringIfNotNumeric(String str); static String replaceIllegalCharsAttribute(final String value); static String replaceIllegalCharsForDataObjects(final String value); static String revertIllegalCharsAttribute(final String value); static String createUnquotedString(String str); }
StringUtils { public static String replaceIllegalCharsAttribute(final String value) { if (isEmpty(value)) { return value; } final StringBuilder sb = new StringBuilder(); for (int i = 0; i < value.length(); i++) { final char c = value.charAt(i); switch (c) { case '<': sb.append("&lt;"); break; case '>': sb.append("&gt;"); break; case '&': sb.append("&amp;"); break; case '"': sb.append("&quot;"); break; default: sb.append(c); break; } } return sb.toString(); } private  StringUtils(); static boolean isEmpty(final String s); static boolean nonEmpty(final String s); static boolean hasNonEmpty(final String... values); static boolean isQuoted(String str); static String createQuotedString(final String str); static String createQuotedStringIfNotNumeric(String str); static String replaceIllegalCharsAttribute(final String value); static String replaceIllegalCharsForDataObjects(final String value); static String revertIllegalCharsAttribute(final String value); static String createUnquotedString(String str);  }