public abstract class UriUtils
extends java.lang.Object
All encode*(String, String methods in this class operate in a similar way:
%<i>xy</i>" format.| Constructor and Description |
|---|
UriUtils() |
| Modifier and Type | Method and Description |
|---|---|
static java.lang.String |
decode(java.lang.String source,
java.lang.String encoding)
Decodes the given encoded source String into an URI.
|
static java.lang.String |
encodeAuthority(java.lang.String authority,
java.lang.String encoding)
Encodes the given URI authority with the given encoding.
|
static java.lang.String |
encodeFragment(java.lang.String fragment,
java.lang.String encoding)
Encodes the given URI fragment with the given encoding.
|
static java.lang.String |
encodeHost(java.lang.String host,
java.lang.String encoding)
Encodes the given URI host with the given encoding.
|
static java.lang.String |
encodeHttpUrl(java.lang.String httpUrl,
java.lang.String encoding)
Deprecated.
in favor of
UriComponentsBuilder; see note about query param encoding |
static java.lang.String |
encodePath(java.lang.String path,
java.lang.String encoding)
Encodes the given URI path with the given encoding.
|
static java.lang.String |
encodePathSegment(java.lang.String segment,
java.lang.String encoding)
Encodes the given URI path segment with the given encoding.
|
static java.lang.String |
encodePort(java.lang.String port,
java.lang.String encoding)
Encodes the given URI port with the given encoding.
|
static java.lang.String |
encodeQuery(java.lang.String query,
java.lang.String encoding)
Encodes the given URI query with the given encoding.
|
static java.lang.String |
encodeQueryParam(java.lang.String queryParam,
java.lang.String encoding)
Encodes the given URI query parameter with the given encoding.
|
static java.lang.String |
encodeScheme(java.lang.String scheme,
java.lang.String encoding)
Encodes the given URI scheme with the given encoding.
|
static java.lang.String |
encodeUri(java.lang.String uri,
java.lang.String encoding)
Deprecated.
in favor of
UriComponentsBuilder; see note about query param encoding |
static java.lang.String |
encodeUriComponents(java.lang.String scheme,
java.lang.String authority,
java.lang.String userInfo,
java.lang.String host,
java.lang.String port,
java.lang.String path,
java.lang.String query,
java.lang.String fragment,
java.lang.String encoding)
Deprecated.
in favor of
UriComponentsBuilder |
static java.lang.String |
encodeUserInfo(java.lang.String userInfo,
java.lang.String encoding)
Encodes the given URI user info with the given encoding.
|
@Deprecated
public static java.lang.String encodeUri(java.lang.String uri,
java.lang.String encoding)
throws java.io.UnsupportedEncodingException
UriComponentsBuilder; see note about query param encodingNote that this method does not attempt to encode "=" and "&" characters in query parameter names and query parameter values because they cannot be parsed in a reliable way. Instead use:
UriComponents uriComponents = UriComponentsBuilder.fromUri("/path?name={value}").buildAndExpand("a=b");
String encodedUri = uriComponents.encode().toUriString();
uri - the URI to be encodedencoding - the character encoding to encode tojava.lang.IllegalArgumentException - when the given uri parameter is not a valid URIjava.io.UnsupportedEncodingException - when the given encoding parameter is not supported@Deprecated
public static java.lang.String encodeHttpUrl(java.lang.String httpUrl,
java.lang.String encoding)
throws java.io.UnsupportedEncodingException
UriComponentsBuilder; see note about query param encodingNote that this method does not support fragments (#),
as these are not supposed to be sent to the server, but retained by the client.
Note that this method does not attempt to encode "=" and "&" characters in query parameter names and query parameter values because they cannot be parsed in a reliable way. Instead use:
UriComponents uriComponents = UriComponentsBuilder.fromHttpUrl("/path?name={value}").buildAndExpand("a=b");
String encodedUri = uriComponents.encode().toUriString();
httpUrl - the HTTP URL to be encodedencoding - the character encoding to encode tojava.lang.IllegalArgumentException - when the given uri parameter is not a valid URIjava.io.UnsupportedEncodingException - when the given encoding parameter is not supported@Deprecated
public static java.lang.String encodeUriComponents(java.lang.String scheme,
java.lang.String authority,
java.lang.String userInfo,
java.lang.String host,
java.lang.String port,
java.lang.String path,
java.lang.String query,
java.lang.String fragment,
java.lang.String encoding)
throws java.io.UnsupportedEncodingException
UriComponentsBuilderscheme - the schemeauthority - the authorityuserInfo - the user infohost - the hostport - the portpath - the pathquery - the queryfragment - the fragmentencoding - the character encoding to encode tojava.lang.IllegalArgumentException - when the given uri parameter is not a valid URIjava.io.UnsupportedEncodingException - when the given encoding parameter is not supportedpublic static java.lang.String encodeScheme(java.lang.String scheme,
java.lang.String encoding)
throws java.io.UnsupportedEncodingException
scheme - the scheme to be encodedencoding - the character encoding to encode tojava.io.UnsupportedEncodingException - when the given encoding parameter is not supportedpublic static java.lang.String encodeAuthority(java.lang.String authority,
java.lang.String encoding)
throws java.io.UnsupportedEncodingException
authority - the authority to be encodedencoding - the character encoding to encode tojava.io.UnsupportedEncodingException - when the given encoding parameter is not supportedpublic static java.lang.String encodeUserInfo(java.lang.String userInfo,
java.lang.String encoding)
throws java.io.UnsupportedEncodingException
userInfo - the user info to be encodedencoding - the character encoding to encode tojava.io.UnsupportedEncodingException - when the given encoding parameter is not supportedpublic static java.lang.String encodeHost(java.lang.String host,
java.lang.String encoding)
throws java.io.UnsupportedEncodingException
host - the host to be encodedencoding - the character encoding to encode tojava.io.UnsupportedEncodingException - when the given encoding parameter is not supportedpublic static java.lang.String encodePort(java.lang.String port,
java.lang.String encoding)
throws java.io.UnsupportedEncodingException
port - the port to be encodedencoding - the character encoding to encode tojava.io.UnsupportedEncodingException - when the given encoding parameter is not supportedpublic static java.lang.String encodePath(java.lang.String path,
java.lang.String encoding)
throws java.io.UnsupportedEncodingException
path - the path to be encodedencoding - the character encoding to encode tojava.io.UnsupportedEncodingException - when the given encoding parameter is not supportedpublic static java.lang.String encodePathSegment(java.lang.String segment,
java.lang.String encoding)
throws java.io.UnsupportedEncodingException
segment - the segment to be encodedencoding - the character encoding to encode tojava.io.UnsupportedEncodingException - when the given encoding parameter is not supportedpublic static java.lang.String encodeQuery(java.lang.String query,
java.lang.String encoding)
throws java.io.UnsupportedEncodingException
query - the query to be encodedencoding - the character encoding to encode tojava.io.UnsupportedEncodingException - when the given encoding parameter is not supportedpublic static java.lang.String encodeQueryParam(java.lang.String queryParam,
java.lang.String encoding)
throws java.io.UnsupportedEncodingException
queryParam - the query parameter to be encodedencoding - the character encoding to encode tojava.io.UnsupportedEncodingException - when the given encoding parameter is not supportedpublic static java.lang.String encodeFragment(java.lang.String fragment,
java.lang.String encoding)
throws java.io.UnsupportedEncodingException
fragment - the fragment to be encodedencoding - the character encoding to encode tojava.io.UnsupportedEncodingException - when the given encoding parameter is not supportedpublic static java.lang.String decode(java.lang.String source,
java.lang.String encoding)
throws java.io.UnsupportedEncodingException
"a" through "z", "A" through "Z", and
"0" through "9" stay the same."-", "_", ".", and "*" stay the same.%<i>xy</i>" is interpreted as a hexadecimal representation of the character.source - the source stringencoding - the encodingjava.lang.IllegalArgumentException - when the given source contains invalid encoded sequencesjava.io.UnsupportedEncodingException - when the given encoding parameter is not supportedURLDecoder.decode(String, String)