StringUtil { public static String unescapeComma(final String escapedStr) { final StringBuilder str = new StringBuilder(escapedStr.length()); boolean isEscaped = false; for (int i = 0; i < escapedStr.length(); i++) { char c = escapedStr.charAt(i); if (isEscaped) { if (REPLACEMENT_CHAR == c) { str.append(ESCAPE_CHAR); } else if (ESCAPE_CHAR == c) { str.append(COMMA); } else { str.append(c); } isEscaped = false; } else { if (ESCAPE_CHAR == c) { isEscaped = true; } else { str.append(c); } } } return str.toString(); } private  StringUtil(); static String toString(final byte[] bytes); static byte[] toBytes(final String string); static String escapeComma(final String str); static String unescapeComma(final String escapedStr); static byte[] toCsv(final Class<?>... classes); static Set<Class<? extends T>> csvToClasses(final byte[] bytes, final Class<? extends T> clazz); static String nullIfEmpty(final String string); static final char COMMA; }
@Test public void unescapeCommaShouldReplaceBackslashesWithComma() { assertEquals("replaceBackslashesWith,Comma", StringUtil.unescapeComma("replaceBackslashesWith\\\\Comma")); }
@Test public void unescapeCommaShouldNotRemoveSemicolon() { assertEquals("don'tRemove;SemiColon", StringUtil.unescapeComma("don'tRemove;SemiColon")); }
@Test public void unescapeCommaShouldNotRemoveComma() { assertEquals("don'tRemove,Comma", StringUtil.unescapeComma("don'tRemove,Comma")); }
@Test public void unescapeCommaShouldRemoveBackslash() { assertEquals("removeBackslash", StringUtil.unescapeComma("remove\\Backslash")); }