@UseDataProvider("forAppendsStringInStringBuilderEscapesAndAddsQuoteIfNeed") @Test public void appendsStringInStringBuilderEscapesAndAddsQuoteIfNeed(String string, String expectedResult) throws Exception { StringBuilder builder = new StringBuilder(); HeaderHelper.appendWithQuote(builder, string); assertEquals(expectedResult, builder.toString()); }
static void appendWithQuote(StringBuilder target, String appendMe) { if (appendMe == null) { return; } Matcher matcher = WHITESPACE_QUOTE_PATTERN.matcher(appendMe); if (matcher.find()) { target.append('"'); appendEscapeQuote(target, appendMe); target.append('"'); } else { target.append(appendMe); } }
HeaderHelper { static void appendWithQuote(StringBuilder target, String appendMe) { if (appendMe == null) { return; } Matcher matcher = WHITESPACE_QUOTE_PATTERN.matcher(appendMe); if (matcher.find()) { target.append('"'); appendEscapeQuote(target, appendMe); target.append('"'); } else { target.append(appendMe); } } }
HeaderHelper { static void appendWithQuote(StringBuilder target, String appendMe) { if (appendMe == null) { return; } Matcher matcher = WHITESPACE_QUOTE_PATTERN.matcher(appendMe); if (matcher.find()) { target.append('"'); appendEscapeQuote(target, appendMe); target.append('"'); } else { target.append(appendMe); } } private  HeaderHelper(); }
HeaderHelper { static void appendWithQuote(StringBuilder target, String appendMe) { if (appendMe == null) { return; } Matcher matcher = WHITESPACE_QUOTE_PATTERN.matcher(appendMe); if (matcher.find()) { target.append('"'); appendEscapeQuote(target, appendMe); target.append('"'); } else { target.append(appendMe); } } private  HeaderHelper(); static List<AcceptMediaType> createAcceptMediaTypeList(String header); static List<AcceptLanguage> createAcceptedLanguageList(String header); static List<AcceptToken> createAcceptedCharsetList(String header); static List<AcceptToken> createAcceptedEncodingList(String header); static List<Cookie> parseCookies(String cookiesString); static NewCookie parseNewCookie(String newCookieString); static Date parseDateHeader(String header); static String formatDate(Date date); static long getContentLengthLong(MultivaluedMap<String, String> httpHeaders); @SuppressWarnings({"unchecked"}) static String getHeaderAsString(Object o); static String convertToString(Collection<String> collection); }
HeaderHelper { static void appendWithQuote(StringBuilder target, String appendMe) { if (appendMe == null) { return; } Matcher matcher = WHITESPACE_QUOTE_PATTERN.matcher(appendMe); if (matcher.find()) { target.append('"'); appendEscapeQuote(target, appendMe); target.append('"'); } else { target.append(appendMe); } } private  HeaderHelper(); static List<AcceptMediaType> createAcceptMediaTypeList(String header); static List<AcceptLanguage> createAcceptedLanguageList(String header); static List<AcceptToken> createAcceptedCharsetList(String header); static List<AcceptToken> createAcceptedEncodingList(String header); static List<Cookie> parseCookies(String cookiesString); static NewCookie parseNewCookie(String newCookieString); static Date parseDateHeader(String header); static String formatDate(Date date); static long getContentLengthLong(MultivaluedMap<String, String> httpHeaders); @SuppressWarnings({"unchecked"}) static String getHeaderAsString(Object o); static String convertToString(Collection<String> collection); static final Comparator<QualityValue> QUALITY_VALUE_COMPARATOR; }