- java.lang.Object
-
- org.eclipse.jetty.util.UrlEncoded
-
public class UrlEncoded extends java.lang.ObjectHandles 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.
- See Also:
URLEncoder
-
-
Field Summary
Fields Modifier and Type Field Description static java.nio.charset.CharsetENCODING
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static voiddecode88591To(java.io.InputStream in, MultiMap<java.lang.String> map, int maxLength, int maxKeys)Decoded parameters to MultiMap, using ISO8859-1 encodings.static java.lang.StringdecodeString(java.lang.String encoded)Decode String with % encoding.static java.lang.StringdecodeString(java.lang.String encoded, int offset, int length, java.nio.charset.Charset charset)Decode String with % encoding.static voiddecodeTo(java.io.InputStream in, MultiMap<java.lang.String> map, java.lang.String charset, int maxLength, int maxKeys)Deprecated, for removal: This API element is subject to removal in a future version.static voiddecodeTo(java.io.InputStream in, MultiMap<java.lang.String> map, java.nio.charset.Charset charset, int maxLength, int maxKeys)Decoded parameters to Map.static voiddecodeTo(java.lang.String content, MultiMap<java.lang.String> map, java.lang.String charset)Deprecated, for removal: This API element is subject to removal in a future version.usedecodeTo(String, MultiMap, Charset)insteadstatic voiddecodeTo(java.lang.String content, MultiMap<java.lang.String> map, java.nio.charset.Charset charset)Decoded parameters to Map.static voiddecodeTo(java.lang.String content, MultiMap<java.lang.String> map, java.nio.charset.Charset charset, int maxKeys)Decoded parameters to Map.static voiddecodeUtf16To(java.io.InputStream in, MultiMap<java.lang.String> map, int maxLength, int maxKeys)static voiddecodeUtf8To(java.io.InputStream in, MultiMap<java.lang.String> map, int maxLength, int maxKeys)Decoded parameters to Map.static voiddecodeUtf8To(java.lang.String query, int offset, int length, MultiMap<java.lang.String> map)Decoded parameters to Map.static voiddecodeUtf8To(java.lang.String query, MultiMap<java.lang.String> map)static java.lang.Stringencode(MultiMap<java.lang.String> map, java.nio.charset.Charset charset, boolean equalsForNullValue)Encode MultiMap with % encoding.static java.lang.StringencodeString(java.lang.String string)Perform URL encoding.static java.lang.StringencodeString(java.lang.String string, java.nio.charset.Charset charset)Perform URL encoding.
-
-
-
Method Detail
-
encode
public static java.lang.String encode(MultiMap<java.lang.String> map, java.nio.charset.Charset charset, boolean equalsForNullValue)
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
@Deprecated(since="10", forRemoval=true) public static void decodeTo(java.lang.String content, MultiMap<java.lang.String> map, java.lang.String charset)Deprecated, for removal: This API element is subject to removal in a future version.usedecodeTo(String, MultiMap, Charset)insteadDecoded parameters to Map.- Parameters:
content- the string containing the encoded parametersmap- the MultiMap to put parsed query parameters intocharset- the charset to use for decoding
-
decodeTo
public static void decodeTo(java.lang.String content, MultiMap<java.lang.String> map, java.nio.charset.Charset charset)Decoded parameters to Map.- Parameters:
content- the string containing the encoded parametersmap- the MultiMap to put parsed query parameters intocharset- the charset to use for decoding
-
decodeTo
public static void decodeTo(java.lang.String content, MultiMap<java.lang.String> map, java.nio.charset.Charset charset, int maxKeys)Decoded parameters to Map.- Parameters:
content- the string containing the encoded parametersmap- the MultiMap to put parsed query parameters intocharset- the charset to use for decoding
-
decodeUtf8To
public static void decodeUtf8To(java.lang.String query, MultiMap<java.lang.String> map)
-
decodeUtf8To
public static void decodeUtf8To(java.lang.String query, int offset, int length, MultiMap<java.lang.String> map)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(java.io.InputStream in, MultiMap<java.lang.String> map, int maxLength, int maxKeys) throws java.io.IOExceptionDecoded 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:
java.io.IOException- if unable to decode the InputStream as ISO8859-1
-
decodeUtf8To
public static void decodeUtf8To(java.io.InputStream in, MultiMap<java.lang.String> map, int maxLength, int maxKeys) throws java.io.IOExceptionDecoded 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:
java.io.IOException- if unable to decode the input stream
-
decodeUtf16To
public static void decodeUtf16To(java.io.InputStream in, MultiMap<java.lang.String> map, int maxLength, int maxKeys) throws java.io.IOException- Throws:
java.io.IOException
-
decodeTo
@Deprecated(since="10", forRemoval=true) public static void decodeTo(java.io.InputStream in, MultiMap<java.lang.String> map, java.lang.String charset, int maxLength, int maxKeys) throws java.io.IOExceptionDeprecated, for removal: This API element is subject to removal in a future version.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:
java.io.IOException- if unable to decode the input stream
-
decodeTo
public static void decodeTo(java.io.InputStream in, MultiMap<java.lang.String> map, java.nio.charset.Charset charset, int maxLength, int maxKeys) throws java.io.IOExceptionDecoded 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:
java.io.IOException- if unable to decode input stream
-
decodeString
public static java.lang.String decodeString(java.lang.String encoded)
Decode String with % encoding. This method makes the assumption that the majority of calls will need no decoding.- Parameters:
encoded- the encoded string to decode- Returns:
- the decoded string
-
decodeString
public static java.lang.String decodeString(java.lang.String encoded, int offset, int length, java.nio.charset.Charset charset)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
-
encodeString
public static java.lang.String encodeString(java.lang.String string)
Perform URL encoding.- Parameters:
string- the string to encode- Returns:
- encoded string.
-
encodeString
public static java.lang.String encodeString(java.lang.String string, java.nio.charset.Charset charset)Perform URL encoding.- Parameters:
string- the string to encodecharset- the charset to use for encoding- Returns:
- encoded string.
-
-