QuoteUtil { public static Iterator<String> splitAt(String str, String delims) { return new DeQuotingStringIterator(str.trim(), delims); }  static String dequote(String str); static void escape(StringBuilder buf, String str); static void quote(StringBuilder buf, String str); static void quoteIfNeeded(StringBuilder buf, String str, String delim); static Iterator<String> splitAt(String str, String delims); static String unescape(String str); static String join(Object[] objs, String delim); static String join(Collection<?> objs, String delim); static final String ABNF_REQUIRED_QUOTING; }
@Test public void testSplitAtPreserveQuoting() { Iterator<String> iter = QuoteUtil.splitAt("permessage-compress; method=\"foo, bar\"", ";"); assertSplitAt(iter, "permessage-compress", "method=\"foo, bar\""); }
@Test public void testSplitAtPreserveQuotingWithNestedDelim() { Iterator<String> iter = QuoteUtil.splitAt("permessage-compress; method=\"foo; x=10\"", ";"); assertSplitAt(iter, "permessage-compress", "method=\"foo; x=10\""); }
@Test public void testSplitAtAllWhitespace() { Iterator<String> iter = QuoteUtil.splitAt(" ", "="); assertFalse(iter.hasNext()); assertThrows(NoSuchElementException.class, () -> iter.next()); }
@Test public void testSplitAtEmpty() { Iterator<String> iter = QuoteUtil.splitAt("", "="); assertFalse(iter.hasNext()); assertThrows(NoSuchElementException.class, () -> iter.next()); }
@Test public void testSplitAtHelloWorld() { Iterator<String> iter = QuoteUtil.splitAt("Hello World", " ="); assertSplitAt(iter, "Hello", "World"); }
@Test public void testSplitAtKeyValueMessage() { Iterator<String> iter = QuoteUtil.splitAt("method=\"foo, bar\"", "="); assertSplitAt(iter, "method", "foo, bar"); }
@Test public void testSplitAtQuotedDelim() { Iterator<String> iter = QuoteUtil.splitAt("A,\"B,C\",D", ","); assertSplitAt(iter, "A", "B,C", "D"); }
@Test public void testSplitAtSimple() { Iterator<String> iter = QuoteUtil.splitAt("Hi", "="); assertSplitAt(iter, "Hi"); }
@Test public void testSplitKeyValueQuoted() { Iterator<String> iter = QuoteUtil.splitAt("Key = \"Value\"", "="); assertSplitAt(iter, "Key", "Value"); }
@Test public void testSplitKeyValueQuotedValueList() { Iterator<String> iter = QuoteUtil.splitAt("Fruit = \"Apple, Banana, Cherry\"", "="); assertSplitAt(iter, "Fruit", "Apple, Banana, Cherry"); }
@Test public void testSplitKeyValueQuotedWithDelim() { Iterator<String> iter = QuoteUtil.splitAt("Key = \"Option=Value\"", "="); assertSplitAt(iter, "Key", "Option=Value"); }
@Test public void testSplitKeyValueSimple() { Iterator<String> iter = QuoteUtil.splitAt("Key=Value", "="); assertSplitAt(iter, "Key", "Value"); }
@Test public void testSplitKeyValueWithWhitespace() { Iterator<String> iter = QuoteUtil.splitAt("Key = Value", "="); assertSplitAt(iter, "Key", "Value"); }