|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.norther.tammi.acorn.net.URLEncoder
public abstract class URLEncoder
A static URL encoder. It encodes strings as specified in RFC3986 Unified Resource Identifier.
Unreserved characters include 'a'-'z', 'A' - 'Z', '0' - '9', '-', '.', '_', and '~' in RFC3986. In addition, characters '!', '$, '&', ''', '(', ')', '*', '+', ',', ';' and '=' may be applied as sub-delimiters. The HTTP scheme reserves '?', '&', '=', '+' and ';' of these. From the general delimiters ':', '/', '?', '#', '[', ']' and '@', characters ':' and '@' may be applied within a path segment of an absolute URI, ':' is not allowed within relative URIs.
Reserved characters and HTTP scheme specific gen-delimiters and sub-delimiters are decoded as character triplets consisting of the character '%' followed by the two hexadecimal digits, which form the hexadecimal value of the octet.
Encoded characters that are longer than 8-bits can be decoded back to UTF strings reliably only with the UTF-8 character encoding.
The encoder uses the platform's default character encoding if nothing else is specified.
Field Summary | |
---|---|
static String |
AMPERSAND
XML references (old WML browsers required an XML entity references, newer ones don't work with it!?) We apply the one required by the HTML DTD. |
static char |
SLASH_COUNT_DELIMITER
The slash count delimiter for keys. |
Constructor Summary | |
---|---|
URLEncoder()
|
Method Summary | |
---|---|
static String |
encode(Map<String,?> map,
int offset,
int count,
String... encoding)
Encodes part of a map of URL parameters using the specified encoding. |
static String |
encode(Map<String,?> map,
String... encoding)
Encodes a map of URL parameters using the specified encoding. |
protected static String |
encode(String str,
char[] chars,
int offset,
int count,
boolean ispath,
StringBuilder buffer,
String... encoding)
Encodes a URL parameter. |
static String |
encode(String param,
String... encoding)
Encodes a URL parameter using the specified encoding. |
static String |
encodePath(String path,
String... encoding)
Encodes a URL path using the specified encoding. |
static String |
encodePathInfo(Map<String,?> map,
int offset,
int count,
String... encoding)
Encodes part of a map of URL path parameters using the specified encoding. |
static String |
encodePathInfo(Map<String,?> map,
String... encoding)
Encodes a map of URL path parameters using the specified encoding. |
static String |
encodePathInfo(String name,
String[] value,
String... encoding)
Encodes a URL path parameters using the specified encoding. |
static String |
encodePathInfo(String name,
String value,
String... encoding)
Encodes a URL path parameter using the specified encoding. |
static int |
keySlashCount(String value)
Returns the slash count of the specified value to be appended to key. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String AMPERSAND
public static final char SLASH_COUNT_DELIMITER
Constructor Detail |
---|
public URLEncoder()
Method Detail |
---|
public static final String encode(String param, String... encoding)
param
- a URL parameter.encoding
- the encoding.
public static final String encode(Map<String,?> map, String... encoding)
map
- a map of URL parameters.encoding
- the encoding.
public static final String encode(Map<String,?> map, int offset, int count, String... encoding)
map
- a map of URL parameters.offset
- the initial offset.count
- the number keys to process (-1 = all).encoding
- the encoding and parameter separator.
public static final String encodePath(String path, String... encoding)
path
- a URL path.encoding
- the encoding.
public static final String encodePathInfo(String name, String value, String... encoding)
name
- the parameter name.value
- the parameter value.encoding
- the encoding.
public static final String encodePathInfo(String name, String[] value, String... encoding)
name
- the parameter name.value
- the parameter values.encoding
- the encoding.
public static final String encodePathInfo(Map<String,?> map, String... encoding)
map
- a map of path components.encoding
- the encoding.
public static final String encodePathInfo(Map<String,?> map, int offset, int count, String... encoding)
map
- a map of path components.offset
- the initial offset.count
- the number keys to process (-1 = all).encoding
- the encoding.
public static final int keySlashCount(String value)
value
- the value to count.
protected static final String encode(String str, char[] chars, int offset, int count, boolean ispath, StringBuilder buffer, String... encoding)
str
- a URL parameter as a string.chars
- a URL parameter as a char array.offset
- the start offset in the array.count
- the number of characters to encode.ispath
- true for path parameters.buffer
- an optional temporary buffer.encoding
- the encoding.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |