Top Description Fields Constructors Methods
org.mortbay.util

public Class UrlEncoded

extends MultiMap
Class Inheritance
Imports
java.io.IOException, .InputStream, .InputStreamReader, .UnsupportedEncodingException, java.util.Iterator, .Map

Handles coding of MIME "x-www-form-urlencoded". This class handles the encoding and decoding for either the query string of a URL or the _content of a POST HTTP request.

Notes

The hashtable either contains String single values, vectors of String or arrays of Strings.

The UTF-8 charset is assumed, unless otherwise defined by either passing a parameter or setting the "org.mortbay.util.UrlEncoding.charset" System property.

This class is only partially synchronized. In particular, simple get operations are not protected from concurrent updates.

See Also
java.net.URLEncoder

Field Summary

Modifier and TypeField and Description
public static final String

Constructor Summary

AccessConstructor and Description
public
public
public
public
UrlEncoded(String s, String charset)

Method Summary

Modifier and TypeMethod and Description
public Object
clone()

Overrides org.mortbay.util.MultiMap.clone.

Returns a shallow copy of this HashMap instance: the keys and values themselves are not cloned.
public void
decode(String query)

public void
decode(String query, String charset)

public static void
decode88591To(InputStream
InputSteam to read
in
,
MultiMap
MultiMap to add parameters to
map
,
int
maximum length of content to read 0r -1 for no limit
maxLength
)

Decoded parameters to Map.

public static String
decodeString(String encoded, int offset, int length, String charset)

Decode String with % encoding.

public static void
decodeTo(String
the string containing the encoded parameters
content
,
MultiMap map, String charset)

Decoded parameters to Map.

public static void
decodeTo(InputStream
the stream containing the encoded parameters
in
,
MultiMap map, String charset, int maxLength)

Decoded parameters to Map.

public static void
decodeUtf16To(InputStream in, MultiMap map, int maxLength)

public static void
decodeUtf8To(byte[]
the byte[] containing the encoded parameters
raw
,
int offset, int length, MultiMap map)

Decoded parameters to Map.

public static void
decodeUtf8To(byte[]
the byte[] containing the encoded parameters
raw
,
int offset, int length, MultiMap map, Utf8StringBuffer buffer)

Decoded parameters to Map.

public static void
decodeUtf8To(InputStream
InputSteam to read
in
,
MultiMap
MultiMap to add parameters to
map
,
int
maximum length of content to read 0r -1 for no limit
maxLength
)

Decoded parameters to Map.

public String
encode()

Encode Hashtable with % encoding.

public String
encode(String charset)

Encode Hashtable with % encoding.

public synchronized String
encode(String charset, boolean
if True, then an '=' is always used, even for parameters without a value. e.g. "blah?a=&b=&c=".
equalsForNullValue
)

Encode Hashtable with % encoding.

public static String
encode(MultiMap map, String charset, boolean
if True, then an '=' is always used, even for parameters without a value. e.g. "blah?a=&b=&c=".
equalsForNullValue
)

Encode Hashtable with % encoding.

public static String

Returns:

encoded string.
encodeString
(String string)

Perform URL encoding.

public static String

Returns:

encoded string.
encodeString
(String string, String charset)

Perform URL encoding.

Inherited from org.mortbay.util.MultiMap:
addaddValuesaddValuesgetgetStringgetValuegetValuesputputAllputValuesputValuesremoveValuetoStringArrayMap

Field Detail

ENCODINGback to summary
public static final String ENCODING

Constructor Detail

UrlEncodedback to summary
public UrlEncoded(UrlEncoded url)
UrlEncodedback to summary
public UrlEncoded()
UrlEncodedback to summary
public UrlEncoded(String s)
UrlEncodedback to summary
public UrlEncoded(String s, String charset)

Method Detail

cloneback to summary
public Object clone()

Overrides org.mortbay.util.MultiMap.clone.

Doc from java.util.HashMap.clone.

Returns a shallow copy of this HashMap instance: the keys and values themselves are not cloned.

Returns:Object

a shallow copy of this map

decodeback to summary
public void decode(String query)
decodeback to summary
public void decode(String query, String charset)
decode88591Toback to summary
public static void decode88591To(InputStream in, MultiMap map, int maxLength) throws IOException

Decoded parameters to Map.

Parameters
in:InputStream

InputSteam to read

map:MultiMap

MultiMap to add parameters to

maxLength:int

maximum length of content to read 0r -1 for no limit

decodeStringback to summary
public static String decodeString(String encoded, int offset, int length, String charset)

Decode String with % encoding. This method makes the assumption that the majority of calls will need no decoding.

decodeToback to summary
public static void decodeTo(String content, MultiMap map, String charset)

Decoded parameters to Map.

Parameters
content:String

the string containing the encoded parameters

decodeToback to summary
public static void decodeTo(InputStream in, MultiMap map, String charset, int maxLength) throws IOException

Decoded parameters to Map.

Parameters
in:InputStream

the stream containing the encoded parameters

decodeUtf16Toback to summary
public static void decodeUtf16To(InputStream in, MultiMap map, int maxLength) throws IOException
decodeUtf8Toback to summary
public static void decodeUtf8To(byte[] raw, int offset, int length, MultiMap map)

Decoded parameters to Map.

Parameters
raw:byte[]

the byte[] containing the encoded parameters

decodeUtf8Toback to summary
public static void decodeUtf8To(byte[] raw, int offset, int length, MultiMap map, Utf8StringBuffer buffer)

Decoded parameters to Map.

Parameters
raw:byte[]

the byte[] containing the encoded parameters

decodeUtf8Toback to summary
public static void decodeUtf8To(InputStream in, MultiMap map, int maxLength) throws IOException

Decoded parameters to Map.

Parameters
in:InputStream

InputSteam to read

map:MultiMap

MultiMap to add parameters to

maxLength:int

maximum length of content to read 0r -1 for no limit

encodeback to summary
public String encode()

Encode Hashtable with % encoding.

encodeback to summary
public String encode(String charset)

Encode Hashtable with % encoding.

encodeback to summary
public synchronized String encode(String charset, boolean equalsForNullValue)

Encode Hashtable with % encoding.

Parameters
equalsForNullValue:boolean

if True, then an '=' is always used, even for parameters without a value. e.g. "blah?a=&b=&c=".

encodeback to summary
public static String encode(MultiMap map, String charset, boolean equalsForNullValue)

Encode Hashtable with % encoding.

Parameters
equalsForNullValue:boolean

if True, then an '=' is always used, even for parameters without a value. e.g. "blah?a=&b=&c=".

encodeStringback to summary
public static String encodeString(String string)

Perform URL encoding.

Returns:String

encoded string.

encodeStringback to summary
public static String encodeString(String string, String charset)

Perform URL encoding.

Returns:String

encoded string.