@Test public void testParamsFormatting() throws Exception { final NameValuePair param1 = new BasicNameValuePair("param", "regular_stuff"); final NameValuePair param2 = new BasicNameValuePair("param", "this\\that"); final NameValuePair param3 = new BasicNameValuePair("param", "this,that"); final NameValuePair[] params = new NameValuePair[] {param1, param2, param3}; final CharArrayBuffer buf = new CharArrayBuffer(64); buf.clear(); this.formatter.formatParameters(buf, params, false); Assert.assertEquals("param=regular_stuff; param=\"this\\\\that\"; param=\"this,that\"", buf.toString()); buf.clear(); this.formatter.formatParameters(buf, params, true); Assert.assertEquals("param=\"regular_stuff\"; param=\"this\\\\that\"; param=\"this,that\"", buf.toString()); }
@Override public void formatParameters( final CharArrayBuffer buffer, final NameValuePair[] nvps, final boolean quote) { Args.notNull(buffer, "Char array buffer"); Args.notNull(nvps, "Header parameter array"); for (int i = 0; i < nvps.length; i++) { if (i > 0) { buffer.append("; "); } formatNameValuePair(buffer, nvps[i], quote); } }
BasicHeaderValueFormatter implements HeaderValueFormatter { @Override public void formatParameters( final CharArrayBuffer buffer, final NameValuePair[] nvps, final boolean quote) { Args.notNull(buffer, "Char array buffer"); Args.notNull(nvps, "Header parameter array"); for (int i = 0; i < nvps.length; i++) { if (i > 0) { buffer.append("; "); } formatNameValuePair(buffer, nvps[i], quote); } } }
BasicHeaderValueFormatter implements HeaderValueFormatter { @Override public void formatParameters( final CharArrayBuffer buffer, final NameValuePair[] nvps, final boolean quote) { Args.notNull(buffer, "Char array buffer"); Args.notNull(nvps, "Header parameter array"); for (int i = 0; i < nvps.length; i++) { if (i > 0) { buffer.append("; "); } formatNameValuePair(buffer, nvps[i], quote); } } BasicHeaderValueFormatter(); }
BasicHeaderValueFormatter implements HeaderValueFormatter { @Override public void formatParameters( final CharArrayBuffer buffer, final NameValuePair[] nvps, final boolean quote) { Args.notNull(buffer, "Char array buffer"); Args.notNull(nvps, "Header parameter array"); for (int i = 0; i < nvps.length; i++) { if (i > 0) { buffer.append("; "); } formatNameValuePair(buffer, nvps[i], quote); } } BasicHeaderValueFormatter(); @Override void formatElements(
            final CharArrayBuffer buffer, final HeaderElement[] elems, final boolean quote); @Override void formatHeaderElement(
            final CharArrayBuffer buffer, final HeaderElement elem, final boolean quote); @Override void formatParameters(
            final CharArrayBuffer buffer, final NameValuePair[] nvps, final boolean quote); @Override void formatNameValuePair(
            final CharArrayBuffer buffer, final NameValuePair nvp, final boolean quote); }
BasicHeaderValueFormatter implements HeaderValueFormatter { @Override public void formatParameters( final CharArrayBuffer buffer, final NameValuePair[] nvps, final boolean quote) { Args.notNull(buffer, "Char array buffer"); Args.notNull(nvps, "Header parameter array"); for (int i = 0; i < nvps.length; i++) { if (i > 0) { buffer.append("; "); } formatNameValuePair(buffer, nvps[i], quote); } } BasicHeaderValueFormatter(); @Override void formatElements(
            final CharArrayBuffer buffer, final HeaderElement[] elems, final boolean quote); @Override void formatHeaderElement(
            final CharArrayBuffer buffer, final HeaderElement elem, final boolean quote); @Override void formatParameters(
            final CharArrayBuffer buffer, final NameValuePair[] nvps, final boolean quote); @Override void formatNameValuePair(
            final CharArrayBuffer buffer, final NameValuePair nvp, final boolean quote); final static BasicHeaderValueFormatter INSTANCE; }