org.mortbay.util

Class UrlEncoded

public class UrlEncoded extends MultiMap

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.

Version: $Id: UrlEncoded.java,v 1.24 2005/12/21 23:14:38 gregwilkins Exp $

Author: Greg Wilkins (gregw)

See Also: java.net.URLEncoder

Constructor Summary
UrlEncoded(UrlEncoded url)
UrlEncoded()
UrlEncoded(String s)
UrlEncoded(String s, String charset)
Method Summary
Objectclone()
voiddecode(String query)
voiddecode(String query, String charset)
static StringdecodeString(String encoded)
Decode String with % encoding.
static StringdecodeString(String encoded, String charset)
Decode String with % encoding.
static StringdecodeString(String encoded, int offset, int length, String charset)
Decode String with % encoding.
static voiddecodeTo(String content, MultiMap map)
static voiddecodeTo(String content, MultiMap map, String charset)
Decoded parameters to Map.
static voiddecodeTo(byte[] data, int offset, int length, MultiMap map, String charset)
Decoded parameters to Map.
Stringencode()
Encode Hashtable with % encoding.
Stringencode(String charset)
Encode Hashtable with % encoding.
Stringencode(String charset, boolean equalsForNullValue)
Encode Hashtable with % encoding.
static StringencodeString(String string)
Perform URL encoding.
static StringencodeString(String string, String charset)
Perform URL encoding.

Constructor Detail

UrlEncoded

public UrlEncoded(UrlEncoded url)

UrlEncoded

public UrlEncoded()

UrlEncoded

public UrlEncoded(String s)

UrlEncoded

public UrlEncoded(String s, String charset)

Method Detail

clone

public Object clone()

decode

public void decode(String query)

decode

public void decode(String query, String charset)

decodeString

public static String decodeString(String encoded)
Decode String with % encoding. This method makes the assumption that the majority of calls will need no decoding and uses the 8859 encoding.

decodeString

public static String decodeString(String encoded, String charset)
Decode String with % encoding. This method makes the assumption that the majority of calls will need no decoding.

decodeString

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.

decodeTo

public static void decodeTo(String content, MultiMap map)

decodeTo

public static void decodeTo(String content, MultiMap map, String charset)
Decoded parameters to Map.

Parameters: content the string containing the encoded parameters

decodeTo

public static void decodeTo(byte[] data, int offset, int length, MultiMap map, String charset)
Decoded parameters to Map.

Parameters: data the byte[] containing the encoded parameters

encode

public String encode()
Encode Hashtable with % encoding.

encode

public String encode(String charset)
Encode Hashtable with % encoding.

encode

public String encode(String charset, boolean equalsForNullValue)
Encode Hashtable with % encoding.

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

encodeString

public static String encodeString(String string)
Perform URL encoding. Assumes 8859 charset

Parameters: string

Returns: encoded string.

encodeString

public static String encodeString(String string, String charset)
Perform URL encoding.

Parameters: string

Returns: encoded string.

Copyright © 2004 Mortbay Consulting Pty. Ltd. All Rights Reserved.