WriterUtil { public static void appendQuotedIfWhitespace(StringBuilder b, String value) { if (value==null) return; boolean quote = GrammarUtil.containsWhiteSpace(value); if (quote) b.append('"'); appendEscapingQuotes(b, value); if (quote) b.append('"'); }  static void appendQuotedIfNonToken(StringBuilder b, String value); static void appendQuotedIfWhitespace(StringBuilder b, String value); static void appendQuoted(StringBuilder b, String value); static void appendEscapingQuotes(StringBuilder b, String value);  }
@Test public void testAppendQuotedIfWhitespace() { StringBuilder sb = new StringBuilder(); WriterUtil.appendQuotedIfWhitespace(sb, "a b"); assertEquals("\"a b\"", sb.toString()); sb = new StringBuilder(); WriterUtil.appendQuotedIfWhitespace(sb, "a:b"); assertEquals("a:b", sb.toString()); }