public abstract class UriUtils extends Object
All encode*(String, String)
methods in this class operate in a similar way:
%xy
"
format.Constructor and Description |
---|
UriUtils() |
Modifier and Type | Method and Description |
---|---|
static String |
decode(String source,
Charset charset)
Decode the given encoded URI component.
|
static String |
decode(String source,
String encoding)
Decode the given encoded URI component.
|
static String |
encode(String source,
Charset charset)
Encode characters outside the unreserved character set as defined in
RFC 3986 Section 2.
|
static String |
encode(String source,
String encoding)
Encode characters outside the unreserved character set as defined in
RFC 3986 Section 2.
|
static String |
encodeAuthority(String authority,
Charset charset)
Encode the given URI authority with the given encoding.
|
static String |
encodeAuthority(String authority,
String encoding)
Encode the given URI authority with the given encoding.
|
static String |
encodeFragment(String fragment,
Charset charset)
Encode the given URI fragment with the given encoding.
|
static String |
encodeFragment(String fragment,
String encoding)
Encode the given URI fragment with the given encoding.
|
static String |
encodeHost(String host,
Charset charset)
Encode the given URI host with the given encoding.
|
static String |
encodeHost(String host,
String encoding)
Encode the given URI host with the given encoding.
|
static String |
encodePath(String path,
Charset charset)
Encode the given URI path with the given encoding.
|
static String |
encodePath(String path,
String encoding)
Encode the given URI path with the given encoding.
|
static String |
encodePathSegment(String segment,
Charset charset)
Encode the given URI path segment with the given encoding.
|
static String |
encodePathSegment(String segment,
String encoding)
Encode the given URI path segment with the given encoding.
|
static String |
encodePort(String port,
Charset charset)
Encode the given URI port with the given encoding.
|
static String |
encodePort(String port,
String encoding)
Encode the given URI port with the given encoding.
|
static String |
encodeQuery(String query,
Charset charset)
Encode the given URI query with the given encoding.
|
static String |
encodeQuery(String query,
String encoding)
Encode the given URI query with the given encoding.
|
static String |
encodeQueryParam(String queryParam,
Charset charset)
Encode the given URI query parameter with the given encoding.
|
static String |
encodeQueryParam(String queryParam,
String encoding)
Encode the given URI query parameter with the given encoding.
|
static String |
encodeScheme(String scheme,
Charset charset)
Encode the given URI scheme with the given encoding.
|
static String |
encodeScheme(String scheme,
String encoding)
Encode the given URI scheme with the given encoding.
|
static String |
encodeUserInfo(String userInfo,
Charset charset)
Encode the given URI user info with the given encoding.
|
static String |
encodeUserInfo(String userInfo,
String encoding)
Encode the given URI user info with the given encoding.
|
static String |
extractFileExtension(String path)
Extract the file extension from the given URI path.
|
public static String encodeScheme(String scheme, String encoding) throws UnsupportedEncodingException
scheme
- the scheme to be encodedencoding
- the character encoding to encode toUnsupportedEncodingException
- when the given encoding parameter is not supportedpublic static String encodeScheme(String scheme, Charset charset)
scheme
- the scheme to be encodedcharset
- the character encoding to encode topublic static String encodeAuthority(String authority, String encoding) throws UnsupportedEncodingException
authority
- the authority to be encodedencoding
- the character encoding to encode toUnsupportedEncodingException
- when the given encoding parameter is not supportedpublic static String encodeAuthority(String authority, Charset charset)
authority
- the authority to be encodedcharset
- the character encoding to encode topublic static String encodeUserInfo(String userInfo, String encoding) throws UnsupportedEncodingException
userInfo
- the user info to be encodedencoding
- the character encoding to encode toUnsupportedEncodingException
- when the given encoding parameter is not supportedpublic static String encodeUserInfo(String userInfo, Charset charset)
userInfo
- the user info to be encodedcharset
- the character encoding to encode topublic static String encodeHost(String host, String encoding) throws UnsupportedEncodingException
host
- the host to be encodedencoding
- the character encoding to encode toUnsupportedEncodingException
- when the given encoding parameter is not supportedpublic static String encodeHost(String host, Charset charset)
host
- the host to be encodedcharset
- the character encoding to encode topublic static String encodePort(String port, String encoding) throws UnsupportedEncodingException
port
- the port to be encodedencoding
- the character encoding to encode toUnsupportedEncodingException
- when the given encoding parameter is not supportedpublic static String encodePort(String port, Charset charset)
port
- the port to be encodedcharset
- the character encoding to encode topublic static String encodePath(String path, String encoding) throws UnsupportedEncodingException
path
- the path to be encodedencoding
- the character encoding to encode toUnsupportedEncodingException
- when the given encoding parameter is not supportedpublic static String encodePath(String path, Charset charset)
path
- the path to be encodedcharset
- the character encoding to encode topublic static String encodePathSegment(String segment, String encoding) throws UnsupportedEncodingException
segment
- the segment to be encodedencoding
- the character encoding to encode toUnsupportedEncodingException
- when the given encoding parameter is not supportedpublic static String encodePathSegment(String segment, Charset charset)
segment
- the segment to be encodedcharset
- the character encoding to encode topublic static String encodeQuery(String query, String encoding) throws UnsupportedEncodingException
query
- the query to be encodedencoding
- the character encoding to encode toUnsupportedEncodingException
- when the given encoding parameter is not supportedpublic static String encodeQuery(String query, Charset charset)
query
- the query to be encodedcharset
- the character encoding to encode topublic static String encodeQueryParam(String queryParam, String encoding) throws UnsupportedEncodingException
queryParam
- the query parameter to be encodedencoding
- the character encoding to encode toUnsupportedEncodingException
- when the given encoding parameter is not supportedpublic static String encodeQueryParam(String queryParam, Charset charset)
queryParam
- the query parameter to be encodedcharset
- the character encoding to encode topublic static String encodeFragment(String fragment, String encoding) throws UnsupportedEncodingException
fragment
- the fragment to be encodedencoding
- the character encoding to encode toUnsupportedEncodingException
- when the given encoding parameter is not supportedpublic static String encodeFragment(String fragment, Charset charset)
fragment
- the fragment to be encodedcharset
- the character encoding to encode topublic static String encode(String source, String encoding) throws UnsupportedEncodingException
This can be used to ensure the given String will not contain any characters with reserved URI meaning regardless of URI component.
source
- the String to be encodedencoding
- the character encoding to encode toUnsupportedEncodingException
- when the given encoding parameter is not supportedpublic static String encode(String source, Charset charset)
This can be used to ensure the given String will not contain any characters with reserved URI meaning regardless of URI component.
source
- the String to be encodedcharset
- the character encoding to encode topublic static String decode(String source, String encoding) throws UnsupportedEncodingException
See StringUtils.uriDecode(String, Charset)
for the decoding rules.
source
- the encoded Stringencoding
- the character encoding to useIllegalArgumentException
- when the given source contains invalid encoded sequencesUnsupportedEncodingException
- when the given encoding parameter is not supportedStringUtils.uriDecode(String, Charset)
,
URLDecoder.decode(String, String)
public static String decode(String source, Charset charset)
See StringUtils.uriDecode(String, Charset)
for the decoding rules.
source
- the encoded Stringcharset
- the character encoding to useIllegalArgumentException
- when the given source contains invalid encoded sequencesStringUtils.uriDecode(String, Charset)
,
URLDecoder.decode(String, String)