@Test public void testParseHEEscaped() { 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 HeaderElement[] elements = this.parser.parseElements(buf, cursor); Assert.assertEquals(3, elements.length); Assert.assertEquals("test1", elements[0].getName()); Assert.assertEquals("\"stuff\"", elements[0].getValue()); Assert.assertEquals("test2", elements[1].getName()); Assert.assertEquals("\\", elements[1].getValue()); Assert.assertEquals("test3", elements[2].getName()); Assert.assertEquals("stuff, stuff", elements[2].getValue()); }
@Override public HeaderElement[] parseElements(final CharSequence buffer, final ParserCursor cursor) { Args.notNull(buffer, "Char sequence"); Args.notNull(cursor, "Parser cursor"); final List<HeaderElement> elements = new ArrayList<>(); while (!cursor.atEnd()) { final HeaderElement element = parseHeaderElement(buffer, cursor); if (!(element.getName().isEmpty() && element.getValue() == null)) { elements.add(element); } } return elements.toArray(new HeaderElement[elements.size()]); }
BasicHeaderValueParser implements HeaderValueParser { @Override public HeaderElement[] parseElements(final CharSequence buffer, final ParserCursor cursor) { Args.notNull(buffer, "Char sequence"); Args.notNull(cursor, "Parser cursor"); final List<HeaderElement> elements = new ArrayList<>(); while (!cursor.atEnd()) { final HeaderElement element = parseHeaderElement(buffer, cursor); if (!(element.getName().isEmpty() && element.getValue() == null)) { elements.add(element); } } return elements.toArray(new HeaderElement[elements.size()]); } }
BasicHeaderValueParser implements HeaderValueParser { @Override public HeaderElement[] parseElements(final CharSequence buffer, final ParserCursor cursor) { Args.notNull(buffer, "Char sequence"); Args.notNull(cursor, "Parser cursor"); final List<HeaderElement> elements = new ArrayList<>(); while (!cursor.atEnd()) { final HeaderElement element = parseHeaderElement(buffer, cursor); if (!(element.getName().isEmpty() && element.getValue() == null)) { elements.add(element); } } return elements.toArray(new HeaderElement[elements.size()]); } BasicHeaderValueParser(); }
BasicHeaderValueParser implements HeaderValueParser { @Override public HeaderElement[] parseElements(final CharSequence buffer, final ParserCursor cursor) { Args.notNull(buffer, "Char sequence"); Args.notNull(cursor, "Parser cursor"); final List<HeaderElement> elements = new ArrayList<>(); while (!cursor.atEnd()) { final HeaderElement element = parseHeaderElement(buffer, cursor); if (!(element.getName().isEmpty() && element.getValue() == null)) { elements.add(element); } } return elements.toArray(new HeaderElement[elements.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 HeaderElement[] parseElements(final CharSequence buffer, final ParserCursor cursor) { Args.notNull(buffer, "Char sequence"); Args.notNull(cursor, "Parser cursor"); final List<HeaderElement> elements = new ArrayList<>(); while (!cursor.atEnd()) { final HeaderElement element = parseHeaderElement(buffer, cursor); if (!(element.getName().isEmpty() && element.getValue() == null)) { elements.add(element); } } return elements.toArray(new HeaderElement[elements.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; }