Top Description Fields Constructors Methods
org.mortbay.util

public Class UrlEncoded

extends MultiMap
Class Inheritance
Imports
java.io.IOException, .InputStream, .InputStreamReader, .StringWriter, .UnsupportedEncodingException, java.util.Iterator, .Map, org.mortbay.log.Log

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. This class is only partially synchronised. In particular, simple get operations are not protected from concurrent updates.
Author
Greg Wilkins (gregw)
See Also
java.net.URLEncoder

Field Summary

Inherited from org.mortbay.util.MultiMap:
_cmap_map

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 java.lang.Object.clone.

Creates and returns a copy of this object.
public void
decode(String query)

public void
decode(String query, String charset)

public static void
decode88591To(InputStream
InputSteam to read
in
,
MultiMap<K>
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<K> map, String charset)

Decoded parameters to Map.

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

Decoded parameters to Map.

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

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

Decoded parameters to Map.

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

Decoded parameters to Map.

public static void
decodeUtf8To(InputStream
InputSteam to read
in
,
MultiMap<K>
MultiMap to add parameters to
map
,
int
maximum length of conent 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<K> 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:
addaddValuesaddValuesclearcontainsKeycontainsValueentrySetequalsgetgetStringgetValuegetValueshashCodeisEmptykeySetputputAllputIfAbsentputValuesputValuesremoveremoveremoveValuereplacereplacesizetoStringArrayMapvalues

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 java.lang.Object.clone.

Doc from java.lang.Object.clone.

Creates and returns a copy of this object. The precise meaning of "copy" may depend on the class of the object. The general intent is that, for any object x, the expression:

x.clone() != x
will be true, and that the expression:
x.clone().getClass() == x.getClass()
will be true, but these are not absolute requirements. While it is typically the case that:
x.clone().equals(x)
will be true, this is not an absolute requirement.

By convention, the returned object should be obtained by calling super.clone. If a class and all of its superclasses (except Object) obey this convention, it will be the case that x.clone().getClass() == x.getClass().

By convention, the object returned by this method should be independent of this object (which is being cloned). To achieve this independence, it may be necessary to modify one or more fields of the object returned by super.clone before returning it. Typically, this means copying any mutable objects that comprise the internal "deep structure" of the object being cloned and replacing the references to these objects with references to the copies. If a class contains only primitive fields or references to immutable objects, then it is usually the case that no fields in the object returned by super.clone need to be modified.

Returns:Object

a clone of this instance.

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<K> map, int maxLength) throws IOException

Decoded parameters to Map.

Parameters
in:InputStream

InputSteam to read

map:MultiMap<K>

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<K> 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<K> 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<K> map, int maxLength) throws IOException
decodeUtf8Toback to summary
public static void decodeUtf8To(byte[] raw, int offset, int length, MultiMap<K> 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<K> map, Utf8StringBuilder buffer)

Decoded parameters to Map.

Parameters
raw:byte[]

the byte[] containing the encoded parameters

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

Decoded parameters to Map.

Parameters
in:InputStream

InputSteam to read

map:MultiMap<K>

MultiMap to add parameters to

maxLength:int

maximum length of conent 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<K> 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. Assumes 8859 charset

Returns:String

encoded string.

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

Perform URL encoding.

Returns:String

encoded string.