Class UrlEncoded
java.lang.Object
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.
NotesThe UTF-8 charset is assumed, unless otherwise defined by either passing a parameter or setting the "org.eclipse.jetty.util.UrlEncoding.charset" System property.
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.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class AbstractMap
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K, V> -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static voidcheckMaxKeys(MultiMap<String> map, int maxKeys) private static voidcheckMaxLength(int length, int maxLength) clone()voidvoidstatic voiddecode88591To(InputStream in, MultiMap<String> map, int maxLength, int maxKeys) Decoded parameters to MultiMap, using ISO8859-1 encodings.private static bytedecodeHexByte(char hi, char lo) private static chardecodeHexChar(int hi, int lo) static StringdecodeString(String encoded) Decode String with % encoding.static StringdecodeString(String encoded, int offset, int length, Charset charset) Decode String with % encoding.static voiddecodeTo(InputStream in, MultiMap<String> map, String charset, int maxLength, int maxKeys) Decoded parameters to Map.static voiddecodeTo(InputStream in, MultiMap<String> map, Charset charset, int maxLength, int maxKeys) Decoded parameters to Map.static voidDecoded parameters to Map.static voidDecoded parameters to Map.static voiddecodeUtf16To(InputStream in, MultiMap<String> map, int maxLength, int maxKeys) static voiddecodeUtf8To(InputStream in, MultiMap<String> map, int maxLength, int maxKeys) Decoded parameters to Map.static voiddecodeUtf8To(String query, int offset, int length, MultiMap<String> map) Decoded parameters to Map.static voiddecodeUtf8To(String query, MultiMap<String> map) encode()Encode MultiMap with % encoding for UTF8 sequences.Encode MultiMap with % encoding for arbitrary Charset sequences.Encode MultiMap with % encoding.static StringEncode MultiMap with % encoding.static StringencodeString(String string) Perform URL encoding.static StringencodeString(String string, Charset charset) Perform URL encoding.Methods inherited from class MultiMap
add, addAllValues, addValues, addValues, containsSimpleValue, getString, getValue, getValues, put, putAllValues, putValues, putValues, removeValue, toString, toStringArrayMapMethods inherited from class LinkedHashMap
clear, containsValue, entrySet, forEach, get, getOrDefault, keySet, removeEldestEntry, replaceAll, valuesMethods inherited from class HashMap
compute, computeIfAbsent, computeIfPresent, containsKey, isEmpty, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, sizeMethods inherited from class AbstractMap
equals, hashCodeMethods inherited from interface Map
compute, computeIfAbsent, computeIfPresent, containsKey, equals, hashCode, isEmpty, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, size
-
Field Details
-
LOG
-
ENCODING
-
-
Constructor Details
-
UrlEncoded
-
UrlEncoded
public UrlEncoded() -
UrlEncoded
-
-
Method Details
-
decode
-
decode
-
encode
Encode MultiMap with % encoding for UTF8 sequences.- Returns:
- the MultiMap as a string with % encoding
-
encode
-
encode
Encode MultiMap with % encoding.- Parameters:
charset- the charset to encode withequalsForNullValue- if True, then an '=' is always used, even for parameters without a value. e.g."blah?a=&b=&c=".- Returns:
- the MultiMap as a string encoded with % encodings
-
encode
Encode MultiMap with % encoding.- Parameters:
map- the map to encodecharset- the charset to use for encoding (uses default encoding if null)equalsForNullValue- if True, then an '=' is always used, even for parameters without a value. e.g."blah?a=&b=&c=".- Returns:
- the MultiMap as a string encoded with % encodings.
-
decodeTo
-
decodeTo
-
decodeUtf8To
-
decodeUtf8To
Decoded parameters to Map.- Parameters:
query- the string containing the encoded parametersoffset- the offset within raw to decode fromlength- the length of the section to decodemap- theMultiMapto populate
-
decode88591To
public static void decode88591To(InputStream in, MultiMap<String> map, int maxLength, int maxKeys) throws IOException Decoded parameters to MultiMap, using ISO8859-1 encodings.- Parameters:
in- InputSteam to readmap- MultiMap to add parameters tomaxLength- maximum length of form to read or -1 for no limitmaxKeys- maximum number of keys to read or -1 for no limit- Throws:
IOException- if unable to decode the InputStream as ISO8859-1
-
decodeUtf8To
public static void decodeUtf8To(InputStream in, MultiMap<String> map, int maxLength, int maxKeys) throws IOException Decoded parameters to Map.- Parameters:
in- InputSteam to readmap- MultiMap to add parameters tomaxLength- maximum form length to decode or -1 for no limitmaxKeys- the maximum number of keys to read or -1 for no limit- Throws:
IOException- if unable to decode the input stream
-
decodeUtf16To
public static void decodeUtf16To(InputStream in, MultiMap<String> map, int maxLength, int maxKeys) throws IOException - Throws:
IOException
-
decodeTo
public static void decodeTo(InputStream in, MultiMap<String> map, String charset, int maxLength, int maxKeys) throws IOException Decoded parameters to Map.- Parameters:
in- the stream containing the encoded parametersmap- the MultiMap to decode intocharset- the charset to use for decodingmaxLength- the maximum length of the form to decode or -1 for no limitmaxKeys- the maximum number of keys to decode or -1 for no limit- Throws:
IOException- if unable to decode the input stream
-
decodeTo
public static void decodeTo(InputStream in, MultiMap<String> map, Charset charset, int maxLength, int maxKeys) throws IOException Decoded parameters to Map.- Parameters:
in- the stream containing the encoded parametersmap- the MultiMap to decode intocharset- the charset to use for decodingmaxLength- the maximum length of the form to decodemaxKeys- the maximum number of keys to decode- Throws:
IOException- if unable to decode input stream
-
checkMaxKeys
-
checkMaxLength
private static void checkMaxLength(int length, int maxLength) -
decodeString
-
decodeString
Decode String with % encoding. This method makes the assumption that the majority of calls will need no decoding.- Parameters:
encoded- the encoded string to decodeoffset- the offset in the encoded string to decode fromlength- the length of characters in the encoded string to decodecharset- the charset to use for decoding- Returns:
- the decoded string
-
decodeHexChar
private static char decodeHexChar(int hi, int lo) -
decodeHexByte
private static byte decodeHexByte(char hi, char lo) -
encodeString
-
encodeString
-
clone
-