public final class Uris extends Object
Modifier and Type | Method and Description |
---|---|
static URI |
create(String scheme,
String rawUserInfo,
String host,
int port,
String rawPath,
String rawQuery,
String rawFragment)
Returns a hierarchical URI constructed from the given components.
|
static URI |
createNonStrict(String scheme,
String rawUserInfo,
String host,
int port,
String rawPath,
String rawQuery,
String rawFragment)
Returns a hierarchical URI constructed from the given components.
|
static String |
formDecodeParameterNameOrValue(String nameOrValue)
Decodes the provided form encoded parameter name or value as per application/x-www-form-urlencoded.
|
static String |
formEncodeParameterNameOrValue(String nameOrValue)
Form encodes the provided parameter name or value as per application/x-www-form-urlencoded.
|
static URI |
rebase(URI uri,
URI base)
Changes the base scheme, host and port of a request to that specified in a base URI,
or leaves them unchanged if the base URI is
null . |
static String |
urlDecodeFragment(String fragment)
Decodes the provided URL encoded fragment as per RFC 3986.
|
static String |
urlDecodePathElement(String pathElement)
Decodes the provided URL encoded path element as per RFC 3986.
|
static String |
urlDecodeQueryParameterNameOrValue(String nameOrValue)
Decodes the provided URL encoded query parameter name or value as per RFC 3986.
|
static String |
urlDecodeUserInfo(String userInfo)
Decodes the provided URL encoded userInfo as per RFC 3986.
|
static String |
urlEncodeFragment(String fragment)
URL encodes the provided fragment as per RFC 3986.
|
static String |
urlEncodePathElement(String pathElement)
URL encodes the provided path element as per RFC 3986.
|
static String |
urlEncodeQueryParameterNameOrValue(String nameOrValue)
URL encodes the provided query parameter name or value as per RFC 3986.
|
static String |
urlEncodeUserInfo(String userInfo)
URL encodes the provided userInfo as per RFC 3986.
|
static URI |
withoutQueryAndFragment(URI uri)
Returns a new URI having the same scheme, authority and path, but no
query nor fragment.
|
static URI |
withQuery(URI uri,
Form query)
Returns a new URI having the provided query parameters.
|
public static URI create(String scheme, String rawUserInfo, String host, int port, String rawPath, String rawQuery, String rawFragment) throws URISyntaxException
Unlike createNonStrict(java.lang.String, java.lang.String, java.lang.String, int, java.lang.String, java.lang.String, java.lang.String)
, this method does not tolerate invalid characters, such
as double-quotes, in the query string.
scheme
- the scheme component of the URI or null
if none.rawUserInfo
- the raw user-information component of the URI or null
if none.host
- the host component of the URI or null
if none.port
- the port number of the URI or -1
if none.rawPath
- the raw path component of the URI or null
if none.rawQuery
- the raw query component of the URI or null
if none. The raw query must not contain
characters that should have been percent encoded.rawFragment
- the raw fragment component of the URI or null
if none.URISyntaxException
- if the resulting URI would be malformed per RFC 2396.public static URI createNonStrict(String scheme, String rawUserInfo, String host, int port, String rawPath, String rawQuery, String rawFragment) throws URISyntaxException
Unlike create(java.lang.String, java.lang.String, java.lang.String, int, java.lang.String, java.lang.String, java.lang.String)
, this method tolerates invalid characters, such as double-quotes,
in the query string.
scheme
- the scheme component of the URI or null
if none.rawUserInfo
- the raw user-information component of the URI or null
if none.host
- the host component of the URI or null
if none.port
- the port number of the URI or -1
if none.rawPath
- the raw path component of the URI or null
if none.rawQuery
- the raw query component of the URI or null
if none. The raw query may contain
characters that should have been percent encoded.rawFragment
- the raw fragment component of the URI or null
if none.URISyntaxException
- if the resulting URI would be malformed per RFC 2396.public static URI rebase(URI uri, URI base)
null
. This implementation only
uses scheme, host and port. The remaining components of the URI remain intact.uri
- the URI whose base is to be changed.base
- the URI to base the other URI on.public static URI withQuery(URI uri, Form query)
uri
- the URI whose query is to be changed.query
- the form containing the query parameters.public static URI withoutQueryAndFragment(URI uri)
uri
- the URI whose query and fragments are to be removed.public static String formDecodeParameterNameOrValue(String nameOrValue)
nameOrValue
- the form encoded parameter name or value, which may be null
.null
if nameOrValue
was null
.public static String formEncodeParameterNameOrValue(String nameOrValue)
nameOrValue
- the parameter name or value, which may be null
.null
if nameOrValue
was null
.public static String urlDecodePathElement(String pathElement)
pathElement
- the URL encoded path element, which may be null
.null
if pathElement
was null
.public static String urlEncodePathElement(String pathElement)
pathElement
- the path element, which may be null
.null
if pathElement
was null
.public static String urlDecodeQueryParameterNameOrValue(String nameOrValue)
nameOrValue
- the URL encoded query parameter name or value, which may be null
.null
if nameOrValue
was null
.public static String urlEncodeQueryParameterNameOrValue(String nameOrValue)
nameOrValue
- the query parameter name or value, which may be null
.null
if nameOrValue
was null
.public static String urlDecodeFragment(String fragment)
fragment
- the URL encoded fragment, which may be null
.null
if fragment
was null
.public static String urlEncodeFragment(String fragment)
fragment
- the fragment, which may be null
.null
if fragment
was null
.public static String urlDecodeUserInfo(String userInfo)
userInfo
- the URL encoded userInfo, which may be null
.null
if userInfo
was null
.Copyright © 2025 Open Identity Platform Community. All rights reserved.