@Test public void testEncodeObjects() throws Exception { final URLCodec urlCodec = new URLCodec(); final String plain = "Hello there!"; String encoded = (String) urlCodec.encode((Object) plain); assertEquals("Basic URL encoding test", "Hello+there%21", encoded); final byte[] plainBA = plain.getBytes(Charsets.UTF_8); final byte[] encodedBA = (byte[]) urlCodec.encode((Object) plainBA); encoded = new String(encodedBA); assertEquals("Basic URL encoding test", "Hello+there%21", encoded); final Object result = urlCodec.encode((Object) null); assertEquals( "Encoding a null Object should return null", null, result); try { final Object dObj = new Double(3.0); urlCodec.encode( dObj ); fail( "Trying to url encode a Double object should cause an exception."); } catch (final EncoderException ee) { } this.validateState(urlCodec); }
@Override public byte[] encode(final byte[] bytes) { return encodeUrl(WWW_FORM_URL, bytes); }
URLCodec implements BinaryEncoder, BinaryDecoder, StringEncoder, StringDecoder { @Override public byte[] encode(final byte[] bytes) { return encodeUrl(WWW_FORM_URL, bytes); } }
URLCodec implements BinaryEncoder, BinaryDecoder, StringEncoder, StringDecoder { @Override public byte[] encode(final byte[] bytes) { return encodeUrl(WWW_FORM_URL, bytes); } URLCodec();  URLCodec(final String charset); }
URLCodec implements BinaryEncoder, BinaryDecoder, StringEncoder, StringDecoder { @Override public byte[] encode(final byte[] bytes) { return encodeUrl(WWW_FORM_URL, bytes); } URLCodec();  URLCodec(final String charset); static final byte[] encodeUrl(BitSet urlsafe, final byte[] bytes); static final byte[] decodeUrl(final byte[] bytes); @Override byte[] encode(final byte[] bytes); @Override byte[] decode(final byte[] bytes); String encode(final String str, final String charset); @Override String encode(final String str); String decode(final String str, final String charset); @Override String decode(final String str); @Override Object encode(final Object obj); @Override Object decode(final Object obj); String getDefaultCharset(); @Deprecated String getEncoding(); }
URLCodec implements BinaryEncoder, BinaryDecoder, StringEncoder, StringDecoder { @Override public byte[] encode(final byte[] bytes) { return encodeUrl(WWW_FORM_URL, bytes); } URLCodec();  URLCodec(final String charset); static final byte[] encodeUrl(BitSet urlsafe, final byte[] bytes); static final byte[] decodeUrl(final byte[] bytes); @Override byte[] encode(final byte[] bytes); @Override byte[] decode(final byte[] bytes); String encode(final String str, final String charset); @Override String encode(final String str); String decode(final String str, final String charset); @Override String decode(final String str); @Override Object encode(final Object obj); @Override Object decode(final Object obj); String getDefaultCharset(); @Deprecated String getEncoding();  }