|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.web.util.UriUtils
public abstract class UriUtils
Utility class for URI encoding and decoding based on RFC 3986. Offers encoding methods for the various URI components.
All encode*(String, String
methods in this class operate in a similar way:
%xy
" format.
Constructor Summary | |
---|---|
UriUtils()
|
Method Summary | |
---|---|
static String |
decode(String source,
String encoding)
Decodes the given encoded source String into an URI. |
static String |
encodeFragment(String fragment,
String encoding)
Encodes the given URI fragment. |
static String |
encodeHost(String host,
String encoding)
Encodes the given URI host. |
static String |
encodeHttpUrl(String httpUrl,
String encoding)
Encodes the given HTTP URI into an encoded String. |
static String |
encodePath(String path,
String encoding)
Encodes the given URI path. |
static String |
encodePathSegment(String segment,
String encoding)
Encodes the given URI path segment. |
static String |
encodePort(String port,
String encoding)
Encodes the given URI port. |
static String |
encodeQuery(String query,
String encoding)
Encodes the given URI query. |
static String |
encodeQueryParam(String queryParam,
String encoding)
Encodes the given URI query parameter. |
static String |
encodeScheme(String scheme,
String encoding)
Encodes the given URI scheme. |
static String |
encodeUri(String uri,
String encoding)
Encodes the given source URI into an encoded String. |
static String |
encodeUriComponents(String scheme,
String authority,
String userinfo,
String host,
String port,
String path,
String query,
String fragment,
String encoding)
Encodes the given source URI components into an encoded String. |
static String |
encodeUserInfo(String userInfo,
String encoding)
Encodes the given URI user info. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public UriUtils()
Method Detail |
---|
public static String encodeUri(String uri, String encoding) throws UnsupportedEncodingException
uri
- the URI to be encodedencoding
- the character encoding to encode to
IllegalArgumentException
- when the given uri parameter is not a valid URI
UnsupportedEncodingException
- when the given encoding parameter is not supportedpublic static String encodeHttpUrl(String httpUrl, String encoding) throws UnsupportedEncodingException
Note that this method does not support fragments (#
),
as these are not supposed to be sent to the server, but retained by the client.
httpUrl
- the HTTP URL to be encodedencoding
- the character encoding to encode to
IllegalArgumentException
- when the given uri parameter is not a valid URI
UnsupportedEncodingException
- when the given encoding parameter is not supportedpublic static String encodeUriComponents(String scheme, String authority, String userinfo, String host, String port, String path, String query, String fragment, String encoding) throws UnsupportedEncodingException
scheme
- the schemeauthority
- the authorityuserinfo
- the user infohost
- the hostport
- the portpath
- the pathquery
- the queryfragment
- the fragmentencoding
- the character encoding to encode to
IllegalArgumentException
- when the given uri parameter is not a valid URI
UnsupportedEncodingException
- when the given encoding parameter is not supportedpublic static String encodeScheme(String scheme, String encoding) throws UnsupportedEncodingException
scheme
- the scheme to be encodedencoding
- the character encoding to encode to
UnsupportedEncodingException
- when the given encoding parameter is not supportedpublic static String encodeUserInfo(String userInfo, String encoding) throws UnsupportedEncodingException
userInfo
- the user info to be encodedencoding
- the character encoding to encode to
UnsupportedEncodingException
- when the given encoding parameter is not supportedpublic static String encodeHost(String host, String encoding) throws UnsupportedEncodingException
host
- the host to be encodedencoding
- the character encoding to encode to
UnsupportedEncodingException
- when the given encoding parameter is not supportedpublic static String encodePort(String port, String encoding) throws UnsupportedEncodingException
port
- the port to be encodedencoding
- the character encoding to encode to
UnsupportedEncodingException
- when the given encoding parameter is not supportedpublic static String encodePath(String path, String encoding) throws UnsupportedEncodingException
path
- the path to be encodedencoding
- the character encoding to encode to
UnsupportedEncodingException
- when the given encoding parameter is not supportedpublic static String encodePathSegment(String segment, String encoding) throws UnsupportedEncodingException
segment
- the segment to be encodedencoding
- the character encoding to encode to
UnsupportedEncodingException
- when the given encoding parameter is not supportedpublic static String encodeQuery(String query, String encoding) throws UnsupportedEncodingException
query
- the query to be encodedencoding
- the character encoding to encode to
UnsupportedEncodingException
- when the given encoding parameter is not supportedpublic static String encodeQueryParam(String queryParam, String encoding) throws UnsupportedEncodingException
queryParam
- the query parameter to be encodedencoding
- the character encoding to encode to
UnsupportedEncodingException
- when the given encoding parameter is not supportedpublic static String encodeFragment(String fragment, String encoding) throws UnsupportedEncodingException
fragment
- the fragment to be encodedencoding
- the character encoding to encode to
UnsupportedEncodingException
- when the given encoding parameter is not supportedpublic static String decode(String source, String encoding) throws UnsupportedEncodingException
"a"
through "z"
,
"A"
through "Z"
, and "0"
through "9"
stay the same.
"-"
, "_"
, "."
, and
"*"
stay the same.
%xy
format.
%xy
" is interpreted as a hexadecimal
representation of the character.
source
- the source stringencoding
- the encoding
UnsupportedEncodingException
- when the given encoding parameter is not supportedURLDecoder.decode(String, String)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |