Tokenizer { public void copyQuotedContent(final CharSequence buf, final Cursor cursor, final StringBuilder dst) { Args.notNull(buf, "Char sequence"); Args.notNull(cursor, "Parser cursor"); Args.notNull(dst, "String builder"); if (cursor.atEnd()) { return; } int pos = cursor.getPos(); int indexFrom = cursor.getPos(); final int indexTo = cursor.getUpperBound(); char current = buf.charAt(pos); if (current != DQUOTE) { return; } pos++; indexFrom++; boolean escaped = false; for (int i = indexFrom; i < indexTo; i++, pos++) { current = buf.charAt(i); if (escaped) { if (current != DQUOTE && current != ESCAPE) { dst.append(ESCAPE); } dst.append(current); escaped = false; } else { if (current == DQUOTE) { pos++; break; } if (current == ESCAPE) { escaped = true; } else if (current != CR && current != LF) { dst.append(current); } } } cursor.updatePos(pos); }  static BitSet INIT_BITSET(final int ... b); static boolean isWhitespace(final char ch); String parseContent(final CharSequence buf, final Cursor cursor, final BitSet delimiters); String parseToken(final CharSequence buf, final Cursor cursor, final BitSet delimiters); String parseValue(final CharSequence buf, final Cursor cursor, final BitSet delimiters); void skipWhiteSpace(final CharSequence buf, final Cursor cursor); void copyContent(final CharSequence buf, final Cursor cursor, final BitSet delimiters,
                            final StringBuilder dst); void copyUnquotedContent(final CharSequence buf, final Cursor cursor,
            final BitSet delimiters, final StringBuilder dst); void copyQuotedContent(final CharSequence buf, final Cursor cursor,
            final StringBuilder dst); static final char DQUOTE; static final char ESCAPE; static final int CR; static final int LF; static final int SP; static final int HT; static final Tokenizer INSTANCE; }
@Test public void testTokenParsingIncompleteQuote() throws Exception { final String s = "\"stuff and more stuff "; final CharArrayBuffer raw = createBuffer(s); final Tokenizer.Cursor cursor = new Tokenizer.Cursor(0, s.length()); final StringBuilder strbuf1 = new StringBuilder(); parser.copyQuotedContent(raw, cursor, strbuf1); Assert.assertEquals("stuff and more stuff ", strbuf1.toString()); }