StringHelper { public static String dequote(String string) { if (string == null) { return null; } else { string = string.trim(); StringBuilder builder = new StringBuilder(); for (int i = 0; i < string.length(); i++) { char c = string.charAt(i); if (c != '\"' && c != '\'' && c != '`') { builder.append(c); } } return builder.toString(); } }  static String unquote(String string); static String dequote(String string); static String doubleQuoteIfNecessary(String string); static String repeat(String string,
                                int    count); static String trimTrailingWhiteSpace(String string);  }
@Test public void shouldDequoteNullString() { String string = StringHelper.dequote(null); assertThat(string, is(nullValue())); }
@Test public void shouldDequoteStringWithoutQuotes() { String string1 = StringHelper.dequote(""); assertThat(string1, is("")); String string2 = StringHelper.dequote("hello"); assertThat(string2, is("hello")); String string3 = StringHelper.dequote("hello world"); assertThat(string3, is("hello world")); }
@Test public void shouldDequoteSingleQuotedStrings() { String string1 = StringHelper.dequote("\'\'"); assertThat(string1, is("")); String string2 = StringHelper.dequote(" \'\' "); assertThat(string2, is("")); String string3 = StringHelper.dequote("\'hello\'"); assertThat(string3, is("hello")); String string4 = StringHelper.dequote("\'hello world\'"); assertThat(string4, is("hello world")); String string5 = StringHelper.dequote(" \'hello world\' "); assertThat(string5, is("hello world")); String string6 = StringHelper.dequote("\"\'hello\'\" world\"\' "); assertThat(string6, is("hello world")); }
@Test public void shouldDequoteDoubleQuotedStrings() { String string1 = StringHelper.dequote("\"\""); assertThat(string1, is("")); String string2 = StringHelper.dequote(" \"\" "); assertThat(string2, is("")); String string3 = StringHelper.dequote("\"hello\""); assertThat(string3, is("hello")); String string4 = StringHelper.dequote("\"hello world\""); assertThat(string4, is("hello world")); String string5 = StringHelper.dequote(" \"hello world\" "); assertThat(string5, is("hello world")); String string6 = StringHelper.dequote("\"\'hello\'\" world\"\' "); assertThat(string6, is("hello world")); }