@Test public void testNVParseEscaped() { final String headerValue = "test1 = \"\\\"stuff\\\"\"; test2= \"\\\\\"; test3 = \"stuff; stuff\""; final CharArrayBuffer buf = new CharArrayBuffer(64); buf.append(headerValue); final ParserCursor cursor = new ParserCursor(0, buf.length()); final NameValuePair[] params = this.parser.parseParameters(buf, cursor); Assert.assertEquals(3, params.length); Assert.assertEquals("test1", params[0].getName()); Assert.assertEquals("\"stuff\"", params[0].getValue()); Assert.assertEquals("test2", params[1].getName()); Assert.assertEquals("\\", params[1].getValue()); Assert.assertEquals("test3", params[2].getName()); Assert.assertEquals("stuff; stuff", params[2].getValue()); }
@Override public NameValuePair[] parseParameters(final CharSequence buffer, final ParserCursor cursor) { Args.notNull(buffer, "Char sequence"); Args.notNull(cursor, "Parser cursor"); tokenizer.skipWhiteSpace(buffer, cursor); final List<NameValuePair> params = new ArrayList<>(); while (!cursor.atEnd()) { final NameValuePair param = parseNameValuePair(buffer, cursor); params.add(param); final char ch = buffer.charAt(cursor.getPos() - 1); if (ch == ELEM_DELIMITER) { break; } } return params.toArray(new NameValuePair[params.size()]); }
BasicHeaderValueParser implements HeaderValueParser { @Override public NameValuePair[] parseParameters(final CharSequence buffer, final ParserCursor cursor) { Args.notNull(buffer, "Char sequence"); Args.notNull(cursor, "Parser cursor"); tokenizer.skipWhiteSpace(buffer, cursor); final List<NameValuePair> params = new ArrayList<>(); while (!cursor.atEnd()) { final NameValuePair param = parseNameValuePair(buffer, cursor); params.add(param); final char ch = buffer.charAt(cursor.getPos() - 1); if (ch == ELEM_DELIMITER) { break; } } return params.toArray(new NameValuePair[params.size()]); } }
BasicHeaderValueParser implements HeaderValueParser { @Override public NameValuePair[] parseParameters(final CharSequence buffer, final ParserCursor cursor) { Args.notNull(buffer, "Char sequence"); Args.notNull(cursor, "Parser cursor"); tokenizer.skipWhiteSpace(buffer, cursor); final List<NameValuePair> params = new ArrayList<>(); while (!cursor.atEnd()) { final NameValuePair param = parseNameValuePair(buffer, cursor); params.add(param); final char ch = buffer.charAt(cursor.getPos() - 1); if (ch == ELEM_DELIMITER) { break; } } return params.toArray(new NameValuePair[params.size()]); } BasicHeaderValueParser(); }
BasicHeaderValueParser implements HeaderValueParser { @Override public NameValuePair[] parseParameters(final CharSequence buffer, final ParserCursor cursor) { Args.notNull(buffer, "Char sequence"); Args.notNull(cursor, "Parser cursor"); tokenizer.skipWhiteSpace(buffer, cursor); final List<NameValuePair> params = new ArrayList<>(); while (!cursor.atEnd()) { final NameValuePair param = parseNameValuePair(buffer, cursor); params.add(param); final char ch = buffer.charAt(cursor.getPos() - 1); if (ch == ELEM_DELIMITER) { break; } } return params.toArray(new NameValuePair[params.size()]); } BasicHeaderValueParser(); @Override HeaderElement[] parseElements(final CharSequence buffer, final ParserCursor cursor); @Override HeaderElement parseHeaderElement(final CharSequence buffer, final ParserCursor cursor); @Override NameValuePair[] parseParameters(final CharSequence buffer, final ParserCursor cursor); @Override NameValuePair parseNameValuePair(final CharSequence buffer, final ParserCursor cursor); }
BasicHeaderValueParser implements HeaderValueParser { @Override public NameValuePair[] parseParameters(final CharSequence buffer, final ParserCursor cursor) { Args.notNull(buffer, "Char sequence"); Args.notNull(cursor, "Parser cursor"); tokenizer.skipWhiteSpace(buffer, cursor); final List<NameValuePair> params = new ArrayList<>(); while (!cursor.atEnd()) { final NameValuePair param = parseNameValuePair(buffer, cursor); params.add(param); final char ch = buffer.charAt(cursor.getPos() - 1); if (ch == ELEM_DELIMITER) { break; } } return params.toArray(new NameValuePair[params.size()]); } BasicHeaderValueParser(); @Override HeaderElement[] parseElements(final CharSequence buffer, final ParserCursor cursor); @Override HeaderElement parseHeaderElement(final CharSequence buffer, final ParserCursor cursor); @Override NameValuePair[] parseParameters(final CharSequence buffer, final ParserCursor cursor); @Override NameValuePair parseNameValuePair(final CharSequence buffer, final ParserCursor cursor); final static BasicHeaderValueParser INSTANCE; }