@Test public void escapeHTMLテスト() { assertThat(Strings.escapeHTML("&"), is("&amp;")); assertThat(Strings.escapeHTML("<"), is("&lt;")); assertThat(Strings.escapeHTML(">"), is("&gt;")); assertThat(Strings.escapeHTML("\""), is("&quot;")); assertThat(Strings.escapeHTML("a"), is("a")); }
public static String escapeHTML(CharSequence html) { StringBuilder buff = new StringBuilder(); for (int i = 0; i < html.length(); i++) { char c = html.charAt(i); switch (c) { case '&': buff.append("&amp;"); break; case '"': buff.append("&quot;"); break; case '<': buff.append("&lt;"); break; case '>': buff.append("&gt;"); break; default: buff.append(c); break; } } return buff.toString(); }
Strings { public static String escapeHTML(CharSequence html) { StringBuilder buff = new StringBuilder(); for (int i = 0; i < html.length(); i++) { char c = html.charAt(i); switch (c) { case '&': buff.append("&amp;"); break; case '"': buff.append("&quot;"); break; case '<': buff.append("&lt;"); break; case '>': buff.append("&gt;"); break; default: buff.append(c); break; } } return buff.toString(); } }
Strings { public static String escapeHTML(CharSequence html) { StringBuilder buff = new StringBuilder(); for (int i = 0; i < html.length(); i++) { char c = html.charAt(i); switch (c) { case '&': buff.append("&amp;"); break; case '"': buff.append("&quot;"); break; case '<': buff.append("&lt;"); break; case '>': buff.append("&gt;"); break; default: buff.append(c); break; } } return buff.toString(); } private  Strings(); }
Strings { public static String escapeHTML(CharSequence html) { StringBuilder buff = new StringBuilder(); for (int i = 0; i < html.length(); i++) { char c = html.charAt(i); switch (c) { case '&': buff.append("&amp;"); break; case '"': buff.append("&quot;"); break; case '<': buff.append("&lt;"); break; case '>': buff.append("&gt;"); break; default: buff.append(c); break; } } return buff.toString(); } private  Strings(); static String substitute(String string, Map<String, ? extends Object> replace); static String substitute(String string, Map<String, ? extends Object> replace, Locale locale); static String findPlaceHolder(String string); static String clearEscapedPlaceHolder(String dirty); static T proper(T returnIfNotEmpty, T alternative); static String toCamel(String snake); static String toSnake(String camel); static String join(T... joinees); static String joinBy(String separator, T... joinees); static String join(List<T> joinees); static String joinBy(String separator, List<T> joinees); static boolean isBlank(CharSequence suspect); static boolean containBlank(CharSequence suspect); static String removeBlanks(CharSequence target); static boolean isEmpty(CharSequence suspect); static boolean isEmpty(CharSequence suspect, boolean removeBlanks); static String reverse(String reversee); static String trim(String target); static String[] split(String regex, String target); static boolean equalsIgnoreCase(String source, String destination); static boolean startsWith(String text, String prefix); static boolean startsWith(String text, String prefix, boolean textCompare); static boolean endsWith(String text, String prefix); static boolean endsWith(String text, String prefix, boolean textCompare); static String escapeHTML(CharSequence html); static String escapeRegex(CharSequence text); }
Strings { public static String escapeHTML(CharSequence html) { StringBuilder buff = new StringBuilder(); for (int i = 0; i < html.length(); i++) { char c = html.charAt(i); switch (c) { case '&': buff.append("&amp;"); break; case '"': buff.append("&quot;"); break; case '<': buff.append("&lt;"); break; case '>': buff.append("&gt;"); break; default: buff.append(c); break; } } return buff.toString(); } private  Strings(); static String substitute(String string, Map<String, ? extends Object> replace); static String substitute(String string, Map<String, ? extends Object> replace, Locale locale); static String findPlaceHolder(String string); static String clearEscapedPlaceHolder(String dirty); static T proper(T returnIfNotEmpty, T alternative); static String toCamel(String snake); static String toSnake(String camel); static String join(T... joinees); static String joinBy(String separator, T... joinees); static String join(List<T> joinees); static String joinBy(String separator, List<T> joinees); static boolean isBlank(CharSequence suspect); static boolean containBlank(CharSequence suspect); static String removeBlanks(CharSequence target); static boolean isEmpty(CharSequence suspect); static boolean isEmpty(CharSequence suspect, boolean removeBlanks); static String reverse(String reversee); static String trim(String target); static String[] split(String regex, String target); static boolean equalsIgnoreCase(String source, String destination); static boolean startsWith(String text, String prefix); static boolean startsWith(String text, String prefix, boolean textCompare); static boolean endsWith(String text, String prefix); static boolean endsWith(String text, String prefix, boolean textCompare); static String escapeHTML(CharSequence html); static String escapeRegex(CharSequence text);  }