com.dyuproject.util.http
Class UrlEncodedParameterMap

java.lang.Object
  extended by java.util.AbstractMap<K,V>
      extended by java.util.HashMap<String,String>
          extended by com.dyuproject.util.http.UrlEncodedParameterMap
All Implemented Interfaces:
Serializable, Cloneable, Map<String,String>

public final class UrlEncodedParameterMap
extends HashMap<String,String>

A parameter map where the values of the parameter names are url encoded on toString()

Author:
David Yu
See Also:
Serialized Form
Date created:
Sep 11, 2008

Nested Class Summary
 
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>
 
Constructor Summary
UrlEncodedParameterMap()
           
UrlEncodedParameterMap(String url)
           
 
Method Summary
 UrlEncodedParameterMap add(String key, String value)
           
static String decode(String value)
          Decodes (url encoding) the value with the default charset UTF-8.
static String decode(String value, int start, int len, String charset)
          Decodes (url encoding) the value with the specified charset, starting at start with the length len.
static String decode(String value, String charset)
          Decodes (url encoding) the value with the specified charset.
static String encode(String value)
          Encodes (url encoding) the value with the default charset UTF-8.
static String encode(String value, String charset)
          Encodes (url encoding) the value with the specified charset.
 String encodedGet(String key)
          Gets the url encoded value from the given key.
static String encodeRFC3986(String value)
          Encodes the value using RFC 3986 url encoding - which basically skips {'-', '.', '_', '~'}.
static String encodeRFC3986(String value, String charset)
          Encodes the value with the given charset using RFC 3986 url encoding - which basically skips {'-', '.', '_', '~'}.
 String getEncoded(String key)
          Gets the url encoded value from the given key.
 String getUrl()
           
 byte[] getUrlFormEncodedBytes(String charset)
           
 byte[] getUrlFormEncodedBytesRFC3986(String charset)
           
 void prettyPrint(PrintStream out)
           
 UrlEncodedParameterMap setUrl(String url)
           
 String toString()
           
 String toStringRFC3986()
           
 
Methods inherited from class java.util.HashMap
clear, clone, containsKey, containsValue, entrySet, get, isEmpty, keySet, put, putAll, remove, size, values
 
Methods inherited from class java.util.AbstractMap
equals, hashCode
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Constructor Detail

UrlEncodedParameterMap

public UrlEncodedParameterMap()

UrlEncodedParameterMap

public UrlEncodedParameterMap(String url)
Method Detail

getUrl

public String getUrl()

setUrl

public UrlEncodedParameterMap setUrl(String url)

add

public UrlEncodedParameterMap add(String key,
                                  String value)

toString

public String toString()
Overrides:
toString in class AbstractMap<String,String>

toStringRFC3986

public String toStringRFC3986()

getUrlFormEncodedBytes

public byte[] getUrlFormEncodedBytes(String charset)
                              throws UnsupportedEncodingException
Throws:
UnsupportedEncodingException

getUrlFormEncodedBytesRFC3986

public byte[] getUrlFormEncodedBytesRFC3986(String charset)
                                     throws UnsupportedEncodingException
Throws:
UnsupportedEncodingException

prettyPrint

public void prettyPrint(PrintStream out)

getEncoded

public String getEncoded(String key)
Gets the url encoded value from the given key.


encodedGet

public String encodedGet(String key)
Gets the url encoded value from the given key.


encode

public static String encode(String value)
Encodes (url encoding) the value with the default charset UTF-8.


encode

public static String encode(String value,
                            String charset)
Encodes (url encoding) the value with the specified charset.


decode

public static String decode(String value)
Decodes (url encoding) the value with the default charset UTF-8.


decode

public static String decode(String value,
                            String charset)
Decodes (url encoding) the value with the specified charset.


decode

public static String decode(String value,
                            int start,
                            int len,
                            String charset)
Decodes (url encoding) the value with the specified charset, starting at start with the length len.


encodeRFC3986

public static String encodeRFC3986(String value)
Encodes the value using RFC 3986 url encoding - which basically skips {'-', '.', '_', '~'}.


encodeRFC3986

public static String encodeRFC3986(String value,
                                   String charset)
Encodes the value with the given charset using RFC 3986 url encoding - which basically skips {'-', '.', '_', '~'}.

Parameters:
value - string to encode
Returns:
encoded string.


Copyright © 2008-2013. All Rights Reserved.