Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.mortbay.util
Class UrlEncoded

    java.lang.Object
      java.util.AbstractMap<K,V>
          java.util.HashMap
              org.mortbay.util.MultiMap
                  org.mortbay.util.UrlEncoded

All Implemented Interfaces:
  Serializable, Cloneable, Map

    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.

Author:
  Greg Wilkins (gregw)
See Also:
  `URLEncoder`, Serialized Form

Constructor Summary
`UrlEncoded()`
`UrlEncoded(String s)`
`UrlEncoded(String s, String charset)`
`UrlEncoded(UrlEncoded url)`

Method Summary
`Object` | `clone()`
`void` | `decode(String query)`
`void` | `decode(String query, String charset)`
`static String` | `decodeString(String encoded, int offset, int length, String charset)` Decode String with % encoding.
`static void` | `decodeTo(InputStream in, MultiMap map, String charset, int maxLength)` Decoded parameters to Map.
`static void` | `decodeTo(String content, MultiMap map, String charset)` Decoded parameters to Map.
`static void` | `decodeUtf8To(byte[] raw, int offset, int length, MultiMap map)` Decoded parameters to Map.
`static void` | `decodeUtf8To(InputStream in, MultiMap map, int maxLength)` Decoded parameters to Map.
`String` | `encode()` Encode Hashtable with % encoding.
`static String` | `encode(MultiMap map, String charset, boolean equalsForNullValue)` Encode Hashtable with % encoding.
`String` | `encode(String charset)` Encode Hashtable with % encoding.
`String` | `encode(String charset, boolean equalsForNullValue)` Encode Hashtable with % encoding.
`static String` | `encodeString(String string)` Perform URL encoding.
`static String` | `encodeString(String string, String charset)` Perform URL encoding.

Methods inherited from class org.mortbay.util.MultiMap
`add, addValues, addValues, get, getString, getValue, getValues, put, putAll, putValues, putValues, removeValue, toStringArrayMap`

Methods inherited from class java.util.HashMap
`clear, containsKey, containsValue, entrySet, isEmpty, keySet, remove, size, values`

Methods inherited from class java.util.AbstractMap
`equals, hashCode, toString`

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

### UrlEncoded

    public UrlEncoded(UrlEncoded url)

### UrlEncoded

    public UrlEncoded()

### UrlEncoded

    public UrlEncoded(String s)

### UrlEncoded

    public UrlEncoded(String s,
                      String charset)

Method Detail

### decode

    public void decode(String query)

### decode

    public void decode(String query,
                       String charset)

### 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=".

### encode

    public static String encode(MultiMap map,
                                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=".

### decodeTo

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

  Decoded parameters to Map.

  Parameters:
    `content` - the string containing the encoded parameters

### decodeUtf8To

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

  Decoded parameters to Map.

  Parameters:
    `data` - the byte[] containing the encoded parameters

### decodeUtf8To

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

  Decoded parameters to Map.

  Parameters:
    `in` - InputSteam to read
    `map` - MultiMap to add parameters to
    `maxLength` - maximum length of conent to read 0r -1 for no limit
  Throws:
    `IOException`

### decodeTo

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

  Decoded parameters to Map.

  Parameters:
    `in` - the stream containing the encoded parameters
  Throws:
    `IOException`

### 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.

### 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.

### clone

    public Object clone()

  Overrides:
    `clone` in class `MultiMap`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2007 Mort Bay Consulting. All Rights Reserved.