UrlEncoded extends MultiMap<String> implements Cloneable { public UrlEncoded(UrlEncoded url) { super(url); } UrlEncoded(UrlEncoded url);  UrlEncoded();  UrlEncoded(String query); static String encode(MultiMap<String> map, Charset charset, boolean equalsForNullValue); static void decodeTo(String content, MultiMap<String> map, String charset); static void decodeTo(String content, MultiMap<String> map, Charset charset); static void decodeUtf8To(String query, MultiMap<String> map); static void decodeUtf8To(String query, int offset, int length, MultiMap<String> map); static void decode88591To(InputStream in, MultiMap<String> map, int maxLength, int maxKeys); static void decodeUtf8To(InputStream in, MultiMap<String> map, int maxLength, int maxKeys); static void decodeUtf16To(InputStream in, MultiMap<String> map, int maxLength, int maxKeys); static void decodeTo(InputStream in, MultiMap<String> map, String charset, int maxLength, int maxKeys); static void decodeTo(InputStream in, MultiMap<String> map, Charset charset, int maxLength, int maxKeys); static String decodeString(String encoded); static String decodeString(String encoded, int offset, int length, Charset charset); static String encodeString(String string); static String encodeString(String string, Charset charset); void decode(String query); void decode(String query, Charset charset); String encode(); String encode(Charset charset); String encode(Charset charset, boolean equalsForNullValue); @Override Object clone(); static final Charset ENCODING; }
@Test void testUrlEncoded() { UrlEncoded url_encoded = new UrlEncoded(); assertEquals(0, url_encoded.size()); url_encoded.clear(); url_encoded.decode(""); assertEquals(0, url_encoded.size()); url_encoded.clear(); url_encoded.decode("Name1=Value1"); assertEquals(1, url_encoded.size()); assertEquals("Name1=Value1", url_encoded.encode()); assertEquals("Value1", url_encoded.getString("Name1")); url_encoded.clear(); url_encoded.decode("Name2="); assertEquals(1, url_encoded.size()); assertEquals("Name2", url_encoded.encode()); assertEquals("", url_encoded.getString("Name2")); url_encoded.clear(); url_encoded.decode("Name3"); assertEquals(1, url_encoded.size()); assertEquals("Name3", url_encoded.encode()); assertEquals("", url_encoded.getString("Name3")); url_encoded.clear(); url_encoded.decode("Name4=V\u0629lue+4%21"); assertEquals(1, url_encoded.size()); assertEquals("Name4=V%D8%A9lue+4%21", url_encoded.encode()); assertEquals("V\u0629lue 4!", url_encoded.getString("Name4")); url_encoded.clear(); url_encoded.decode("Name4=Value%2B4%21"); assertEquals(1, url_encoded.size()); assertEquals("Name4=Value%2B4%21", url_encoded.encode()); assertEquals("Value+4!", url_encoded.getString("Name4")); url_encoded.clear(); url_encoded.decode("Name4=Value+4%21%20%214"); assertEquals(1, url_encoded.size()); assertEquals("Name4=Value+4%21+%214", url_encoded.encode()); assertEquals("Value 4! !4", url_encoded.getString("Name4")); url_encoded.clear(); url_encoded.decode("Name5=aaa&Name6=bbb"); assertEquals(2, url_encoded.size()); assertTrue(url_encoded.encode().equals("Name5=aaa&Name6=bbb") || url_encoded.encode().equals("Name6=bbb&Name5=aaa") ); assertEquals("aaa", url_encoded.getString("Name5")); assertEquals("bbb", url_encoded.getString("Name6")); url_encoded.clear(); url_encoded.decode("Name7=aaa&Name7=b%2Cb&Name7=ccc"); assertEquals("Name7=aaa&Name7=b%2Cb&Name7=ccc", url_encoded.encode()); assertEquals("aaa,b,b,ccc", url_encoded.getString("Name7")); assertEquals("aaa", url_encoded.getValues("Name7").get(0)); assertEquals("b,b", url_encoded.getValues("Name7").get(1)); assertEquals("ccc", url_encoded.getValues("Name7").get(2)); url_encoded.clear(); url_encoded.decode("Name8=xx%2C++yy++%2Czz"); assertEquals(1, url_encoded.size()); assertEquals("Name8=xx%2C++yy++%2Czz", url_encoded.encode()); assertEquals("xx, yy ,zz", url_encoded.getString("Name8")); }