public class RESTUtils
extends java.lang.Object
Utility class for working with REST related operations.
Modifier and Type | Method and Description |
---|---|
static java.util.Map<java.lang.String,java.lang.String> |
decodeFormData(java.lang.String formString)
Decode an URL encoded form data string into a map.
|
static java.lang.String |
decodeString(java.lang.String encoded)
Decode an URL encoded string.
|
static java.lang.String |
encodeFormData(java.util.Map<?,?> formData)
Encode a map of form data into an URL encoded string.
|
static java.lang.String |
encodeString(java.lang.String toEncode)
URL encode a string.
|
static int |
findAvailablePort(int portRangeStart,
int portRangeEnd)
Find an available port in the port range.
|
static java.lang.String |
stripTrailingSlash(java.lang.String path)
Remove trailing slashes from a path.
|
public static java.lang.String stripTrailingSlash(java.lang.String path)
path
- The path to strip trailing slashes from.public static java.lang.String encodeFormData(java.util.Map<?,?> formData)
formData
- The form data to encode.public static java.util.Map<java.lang.String,java.lang.String> decodeFormData(java.lang.String formString)
formString
- The URL encoded form data string.public static java.lang.String encodeString(java.lang.String toEncode)
toEncode
- The string to encode.java.lang.IllegalArgumentException
- If the input string is null.java.io.UncheckedIOException
- If URL encoding fails.public static java.lang.String decodeString(java.lang.String encoded)
encoded
- The URL encoded string to decode.java.lang.IllegalArgumentException
- if the input string is null.java.io.UncheckedIOException
- if URL decoding fails.public static int findAvailablePort(int portRangeStart, int portRangeEnd) throws java.io.IOException
portRangeStart
- the start of the port rangeportRangeEnd
- the end of the port rangejava.io.IOException
- if no available port in the port range