public abstract class Uri
extends java.lang.Object
implements scala.Product, java.io.Serializable
Modifier and Type | Class and Description |
---|---|
static class |
Uri.Authority
param: port A port number that may be
0 to signal the default port of for scheme. |
static class |
Uri.Authority$ |
static class |
Uri.Empty$ |
static class |
Uri.Host |
static class |
Uri.Host$ |
static class |
Uri.IPv4Host |
static class |
Uri.IPv4Host$ |
static class |
Uri.IPv6Host |
static class |
Uri.IPv6Host$ |
static class |
Uri.NamedHost |
static class |
Uri.NamedHost$ |
static class |
Uri.NonEmptyHost |
static interface |
Uri.ParsingMode |
static class |
Uri.ParsingMode$ |
static class |
Uri.Path |
static class |
Uri.Path$ |
static class |
Uri.Query |
static class |
Uri.Query$ |
Constructor and Description |
---|
Uri(java.lang.String scheme,
Uri.Authority authority,
Uri.Path path,
scala.Option<java.lang.String> rawQueryString,
scala.Option<java.lang.String> fragment) |
Modifier and Type | Method and Description |
---|---|
static Uri |
apply(org.parboiled2.ParserInput input)
Parses a valid URI string into a normalized URI reference as defined
by http://tools.ietf.org/html/rfc3986#section-4.1.
|
static Uri |
apply(org.parboiled2.ParserInput input,
java.nio.charset.Charset charset,
Uri.ParsingMode mode)
Parses a valid URI string into a normalized URI reference as defined
by http://tools.ietf.org/html/rfc3986#section-4.1.
|
static Uri |
apply(org.parboiled2.ParserInput input,
Uri.ParsingMode mode)
Parses a valid URI string into a normalized URI reference as defined
by http://tools.ietf.org/html/rfc3986#section-4.1.
|
static Uri |
apply(java.lang.String input)
Parses a valid URI string into a normalized URI reference as defined
by http://tools.ietf.org/html/rfc3986#section-4.1.
|
static Uri |
apply(java.lang.String scheme,
Uri.Authority authority,
Uri.Path path,
scala.Option<java.lang.String> queryString,
scala.Option<java.lang.String> fragment)
Creates a new Uri instance from the given components.
|
Uri.Authority |
authority() |
static Uri.Path |
collapseDotSegments(Uri.Path path) |
Uri |
copy(java.lang.String scheme,
Uri.Authority authority,
Uri.Path path,
scala.Option<java.lang.String> rawQueryString,
scala.Option<java.lang.String> fragment)
Returns a copy of this Uri with the given components.
|
static Uri |
create(java.lang.String scheme,
java.lang.String userinfo,
Uri.Host host,
int port,
Uri.Path path,
scala.Option<java.lang.String> queryString,
scala.Option<java.lang.String> fragment) |
static Uri |
create(java.lang.String scheme,
Uri.Authority authority,
Uri.Path path,
scala.Option<java.lang.String> queryString,
scala.Option<java.lang.String> fragment) |
static Uri |
createUnsafe(java.lang.String scheme,
Uri.Authority authority,
Uri.Path path,
scala.Option<java.lang.String> queryString,
scala.Option<java.lang.String> fragment)
'Unsafe' in the sense that queryString validation must already have been done.
|
static java.lang.String |
decode(java.lang.String string,
java.nio.charset.Charset charset) |
static java.lang.String |
decode(java.lang.String string,
java.nio.charset.Charset charset,
int ix,
java.lang.StringBuilder sb) |
static Uri |
effectiveHttpRequestUri(java.lang.String scheme,
Uri.Host host,
int port,
Uri.Path path,
scala.Option<java.lang.String> query,
scala.Option<java.lang.String> fragment,
boolean securedConnection,
Uri.Host hostHeaderHost,
int hostHeaderPort,
Uri.Authority defaultAuthority)
Converts a set of URI components to an "effective HTTP request URI" as defined by
http://tools.ietf.org/html/rfc7230#section-5.5.
|
int |
effectivePort()
The effective port of this Uri given the currently set authority and scheme values.
|
static Uri |
effectiveRequestUri(java.lang.String scheme,
Uri.Host host,
int port,
Uri.Path path,
scala.Option<java.lang.String> query,
scala.Option<java.lang.String> fragment,
java.lang.String defaultScheme,
Uri.Host hostHeaderHost,
int hostHeaderPort,
Uri.Authority defaultAuthority)
Converts a set of URI components to an "effective request URI" as defined by
http://tools.ietf.org/html/rfc7230#section-5.5.
|
static scala.runtime.Nothing$ |
fail(java.lang.String summary,
java.lang.String detail) |
scala.Option<java.lang.String> |
fragment() |
static Uri |
from(java.lang.String scheme,
java.lang.String userinfo,
java.lang.String host,
int port,
java.lang.String path,
scala.Option<java.lang.String> queryString,
scala.Option<java.lang.String> fragment,
Uri.ParsingMode mode)
Creates a new Uri instance from the given components.
|
static java.lang.String |
httpScheme(boolean securedConnection) |
boolean |
isAbsolute() |
abstract boolean |
isEmpty() |
boolean |
isRelative() |
static java.lang.String |
normalize(org.parboiled2.ParserInput uri,
java.nio.charset.Charset charset,
Uri.ParsingMode mode)
Normalizes the given URI string by performing the following normalizations:
- the
scheme and host components are converted to lowercase
- a potentially existing port component is removed if it matches one of the defined default ports for the scheme
- percent-encoded octets are decoded if allowed, otherwise they are converted to uppercase hex notation
- . |
static int |
normalizePort(int port,
java.lang.String scheme) |
static java.lang.String |
normalizeScheme(java.lang.String scheme) |
static Uri |
parseAbsolute(org.parboiled2.ParserInput input,
java.nio.charset.Charset charset,
Uri.ParsingMode mode)
Parses a string into a normalized absolute URI as defined by http://tools.ietf.org/html/rfc3986#section-4.3.
|
static Uri |
parseAndResolve(org.parboiled2.ParserInput string,
Uri base,
java.nio.charset.Charset charset,
Uri.ParsingMode mode)
Parses a string into a normalized URI reference that is immediately resolved against the given base URI as
defined by http://tools.ietf.org/html/rfc3986#section-5.2.
|
static Uri.Authority |
parseHttp2AuthorityPseudoHeader(org.parboiled2.ParserInput headerValue,
java.nio.charset.Charset charset,
Uri.ParsingMode mode)
Parses the given string as if it were the value of an HTTP/2 ":authority" pseudo-header.
|
static scala.Tuple2<Uri.Path,scala.Option<java.lang.String>> |
parseHttp2PathPseudoHeader(org.parboiled2.ParserInput headerValue,
java.nio.charset.Charset charset,
Uri.ParsingMode mode)
Parses the given string as if it were the value of an HTTP/2 ":path" pseudo-header.
|
static Uri |
parseHttpRequestTarget(org.parboiled2.ParserInput requestTarget,
java.nio.charset.Charset charset,
Uri.ParsingMode mode)
Parses the given string into an HTTP request target URI as defined by
http://tools.ietf.org/html/rfc7230#section-5.3.
|
Uri.Path |
path() |
Uri.Query |
query(java.nio.charset.Charset charset,
Uri.ParsingMode mode)
Parses the rawQueryString member into a Query instance.
|
scala.Option<java.lang.String> |
queryString(java.nio.charset.Charset charset)
Returns the query part of the Uri in its decoded form.
|
scala.Option<java.lang.String> |
rawQueryString() |
Uri |
resolvedAgainst(Uri base)
Returns a new absolute Uri that is the result of the resolution process defined by
http://tools.ietf.org/html/rfc3986#section-5.2.2
The given base Uri must be absolute.
|
static Uri |
resolveUnsafe(java.lang.String scheme,
java.lang.String userinfo,
Uri.Host host,
int port,
Uri.Path path,
scala.Option<java.lang.String> query,
scala.Option<java.lang.String> fragment,
Uri base)
https://tools.ietf.org/html/rfc3986#section-5.2.2
'Unsafe' in the sense that queryString validation must already have been done.
|
java.lang.String |
scheme() |
Uri |
toEffectiveHttpRequestUri(Uri.Host hostHeaderHost,
int hostHeaderPort,
boolean securedConnection,
Uri.Authority defaultAuthority)
Converts this URI to an "effective HTTP request URI" as defined by
http://tools.ietf.org/html/rfc7230#section-5.5
|
Uri |
toEffectiveRequestUri(Uri.Host hostHeaderHost,
int hostHeaderPort,
java.lang.String defaultScheme,
Uri.Authority defaultAuthority)
Converts this URI to an "effective request URI" as defined by
http://tools.ietf.org/html/rfc7230#section-5.5
|
Uri |
toHttpRequestTargetOriginForm()
Converts this URI into an HTTP request target "origin-form" as defined by
https://tools.ietf.org/html/rfc7230#section-5.3.
|
Uri |
toRelative()
Converts this URI into a relative URI by keeping the path, query and fragment, but dropping the scheme and authority.
|
java.lang.String |
toString() |
static Uri.Path |
verifyPath(Uri.Path path,
java.lang.String scheme,
Uri.Host host) |
static java.lang.String |
websocketScheme(boolean securedConnection) |
Uri |
withAuthority(java.lang.String host,
int port)
Returns a copy of this Uri with a Authority created using the given host and port.
|
Uri |
withAuthority(Uri.Authority authority)
Returns a copy of this Uri with the given authority.
|
Uri |
withAuthority(Uri.Host host,
int port,
java.lang.String userinfo)
Returns a copy of this Uri with a Authority created using the given host, port and userinfo.
|
Uri |
withFragment(java.lang.String fragment)
Returns a copy of this Uri with the given fragment.
|
Uri |
withHost(java.lang.String host)
Returns a copy of this Uri with the given host.
|
Uri |
withHost(Uri.Host host)
Returns a copy of this Uri with the given host.
|
Uri |
withoutFragment()
Drops the fragment from this URI
|
Uri |
withPath(Uri.Path path)
Returns a copy of this Uri with the given path.
|
Uri |
withPort(int port)
Returns a copy of this Uri with the given port.
|
Uri |
withQuery(Uri.Query query)
Returns a copy of this Uri with the given query.
|
Uri |
withRawQueryString(java.lang.String rawQuery)
Returns a copy of this Uri with the given query string.
|
Uri |
withRawQueryString(java.lang.String rawQueryString,
Uri.ParsingMode mode)
Returns a copy of this Uri with the given query string.
|
Uri |
withScheme(java.lang.String scheme)
Returns a copy of this Uri with the given scheme.
|
Uri |
withUserInfo(java.lang.String userinfo)
Returns a copy of this Uri with the given userinfo.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
public Uri(java.lang.String scheme, Uri.Authority authority, Uri.Path path, scala.Option<java.lang.String> rawQueryString, scala.Option<java.lang.String> fragment)
public static Uri apply(java.lang.String input)
IllegalUriException
.input
- (undocumented)public static Uri apply(org.parboiled2.ParserInput input)
IllegalUriException
.input
- (undocumented)public static Uri apply(org.parboiled2.ParserInput input, Uri.ParsingMode mode)
IllegalUriException
.
mode
- if Relaxed
, accepts unencoded visible 7-bit ASCII characters in addition to the RFC.input
- (undocumented)public static Uri apply(org.parboiled2.ParserInput input, java.nio.charset.Charset charset, Uri.ParsingMode mode)
IllegalUriException
.
mode
- if Relaxed
, accepts unencoded visible 7-bit ASCII characters in addition to the RFC.input
- (undocumented)charset
- (undocumented)public static Uri apply(java.lang.String scheme, Uri.Authority authority, Uri.Path path, scala.Option<java.lang.String> queryString, scala.Option<java.lang.String> fragment)
IllegalUriException
.
queryString
- percent-encoded query string. When characters are
encountered that are outside of the RFC3986 range they
are automatically percent-encodedscheme
- (undocumented)authority
- (undocumented)path
- (undocumented)fragment
- (undocumented)public static Uri from(java.lang.String scheme, java.lang.String userinfo, java.lang.String host, int port, java.lang.String path, scala.Option<java.lang.String> queryString, scala.Option<java.lang.String> fragment, Uri.ParsingMode mode)
IllegalUriException
.scheme
- (undocumented)userinfo
- (undocumented)host
- (undocumented)port
- (undocumented)path
- (undocumented)queryString
- (undocumented)fragment
- (undocumented)mode
- (undocumented)public static Uri parseAbsolute(org.parboiled2.ParserInput input, java.nio.charset.Charset charset, Uri.ParsingMode mode)
IllegalUriException
.
mode
- if Relaxed
, accepts unencoded visible 7-bit ASCII characters in addition to the RFC.input
- (undocumented)charset
- (undocumented)public static Uri parseAndResolve(org.parboiled2.ParserInput string, Uri base, java.nio.charset.Charset charset, Uri.ParsingMode mode)
IllegalUriException
.
mode
- if Relaxed
, accepts unencoded visible 7-bit ASCII characters in addition to the RFC.string
- (undocumented)base
- (undocumented)charset
- (undocumented)public static Uri parseHttpRequestTarget(org.parboiled2.ParserInput requestTarget, java.nio.charset.Charset charset, Uri.ParsingMode mode)
IllegalUriException
.
mode
- if Relaxed
, accepts unencoded visible 7-bit ASCII characters in addition to the RFC.requestTarget
- (undocumented)charset
- (undocumented)public static scala.Tuple2<Uri.Path,scala.Option<java.lang.String>> parseHttp2PathPseudoHeader(org.parboiled2.ParserInput headerValue, java.nio.charset.Charset charset, Uri.ParsingMode mode)
IllegalUriException
.
mode
- if Relaxed
, accepts unencoded visible 7-bit ASCII characters in addition to the RFC.headerValue
- (undocumented)charset
- (undocumented)public static Uri.Authority parseHttp2AuthorityPseudoHeader(org.parboiled2.ParserInput headerValue, java.nio.charset.Charset charset, Uri.ParsingMode mode)
IllegalUriException
.
mode
- if Relaxed
, accepts unencoded visible 7-bit ASCII characters in addition to the RFC.headerValue
- (undocumented)charset
- (undocumented)public static java.lang.String normalize(org.parboiled2.ParserInput uri, java.nio.charset.Charset charset, Uri.ParsingMode mode)
scheme
and host
components are converted to lowercase
- a potentially existing port
component is removed if it matches one of the defined default ports for the scheme
- percent-encoded octets are decoded if allowed, otherwise they are converted to uppercase hex notation
- .
and ..
path segments are resolved as far as possible
If the given string is not a valid URI the method throws an IllegalUriException
.
mode
- if Relaxed
, accepts unencoded visible 7-bit ASCII characters in addition to the RFC.uri
- (undocumented)charset
- (undocumented)public static Uri effectiveHttpRequestUri(java.lang.String scheme, Uri.Host host, int port, Uri.Path path, scala.Option<java.lang.String> query, scala.Option<java.lang.String> fragment, boolean securedConnection, Uri.Host hostHeaderHost, int hostHeaderPort, Uri.Authority defaultAuthority)
scheme
- (undocumented)host
- (undocumented)port
- (undocumented)path
- (undocumented)query
- (undocumented)fragment
- (undocumented)securedConnection
- (undocumented)hostHeaderHost
- (undocumented)hostHeaderPort
- (undocumented)defaultAuthority
- (undocumented)public static Uri effectiveRequestUri(java.lang.String scheme, Uri.Host host, int port, Uri.Path path, scala.Option<java.lang.String> query, scala.Option<java.lang.String> fragment, java.lang.String defaultScheme, Uri.Host hostHeaderHost, int hostHeaderPort, Uri.Authority defaultAuthority)
scheme
- (undocumented)host
- (undocumented)port
- (undocumented)path
- (undocumented)query
- (undocumented)fragment
- (undocumented)defaultScheme
- (undocumented)hostHeaderHost
- (undocumented)hostHeaderPort
- (undocumented)defaultAuthority
- (undocumented)public static java.lang.String httpScheme(boolean securedConnection)
public static java.lang.String websocketScheme(boolean securedConnection)
public static Uri resolveUnsafe(java.lang.String scheme, java.lang.String userinfo, Uri.Host host, int port, Uri.Path path, scala.Option<java.lang.String> query, scala.Option<java.lang.String> fragment, Uri base)
'Unsafe' in the sense that queryString validation must already have been done.
query
- percent-encoded query string that must be guaranteed
not to contain invalid percent-encodings or characters not allowed by
the RFC.scheme
- (undocumented)userinfo
- (undocumented)host
- (undocumented)port
- (undocumented)path
- (undocumented)fragment
- (undocumented)base
- (undocumented)public static java.lang.String decode(java.lang.String string, java.nio.charset.Charset charset)
public static java.lang.String decode(java.lang.String string, java.nio.charset.Charset charset, int ix, java.lang.StringBuilder sb)
public static java.lang.String normalizeScheme(java.lang.String scheme)
public static int normalizePort(int port, java.lang.String scheme)
public static scala.runtime.Nothing$ fail(java.lang.String summary, java.lang.String detail)
public static Uri create(java.lang.String scheme, java.lang.String userinfo, Uri.Host host, int port, Uri.Path path, scala.Option<java.lang.String> queryString, scala.Option<java.lang.String> fragment)
queryString
- percent-encoded query string. When characters are
encountered that are outside of the RFC3986 range they
are automatically percent-encodedscheme
- (undocumented)userinfo
- (undocumented)host
- (undocumented)port
- (undocumented)path
- (undocumented)fragment
- (undocumented)public static Uri create(java.lang.String scheme, Uri.Authority authority, Uri.Path path, scala.Option<java.lang.String> queryString, scala.Option<java.lang.String> fragment)
queryString
- percent-encoded query string. When characters are
encountered that are outside of the RFC3986 range they
are automatically percent-encodedscheme
- (undocumented)authority
- (undocumented)path
- (undocumented)fragment
- (undocumented)public static Uri createUnsafe(java.lang.String scheme, Uri.Authority authority, Uri.Path path, scala.Option<java.lang.String> queryString, scala.Option<java.lang.String> fragment)
queryString
- percent-encoded query string that must be guaranteed
not to contain invalid percent-encodings or characters not allowed by
the RFC.scheme
- (undocumented)authority
- (undocumented)path
- (undocumented)fragment
- (undocumented)public java.lang.String scheme()
public Uri.Authority authority()
public Uri.Path path()
public scala.Option<java.lang.String> rawQueryString()
public scala.Option<java.lang.String> fragment()
public boolean isAbsolute()
public boolean isRelative()
public abstract boolean isEmpty()
public Uri.Query query(java.nio.charset.Charset charset, Uri.ParsingMode mode)
charset
- (undocumented)mode
- (undocumented)public scala.Option<java.lang.String> queryString(java.nio.charset.Charset charset)
charset
- (undocumented)public int effectivePort()
public Uri copy(java.lang.String scheme, Uri.Authority authority, Uri.Path path, scala.Option<java.lang.String> rawQueryString, scala.Option<java.lang.String> fragment)
If you want to use the copy constructor to update the 'rawQueryString', it is up to you to
make sure the query string does not contain invalid characters. For this reason we
recommend using Uri#withRawQueryString()
instead.
scheme
- (undocumented)authority
- (undocumented)path
- (undocumented)rawQueryString
- (undocumented)fragment
- (undocumented)public Uri withScheme(java.lang.String scheme)
scheme
change of the Uri has the following
effect on the port value:
- If the Uri has a non-default port for the scheme before the change this port will remain unchanged.
- If the Uri has the default port for the scheme before the change it will have the default port for
the '''new''' scheme after the change.scheme
- (undocumented)public Uri withAuthority(Uri.Authority authority)
authority
- (undocumented)public Uri withAuthority(Uri.Host host, int port, java.lang.String userinfo)
host
- (undocumented)port
- (undocumented)userinfo
- (undocumented)public Uri withAuthority(java.lang.String host, int port)
host
- (undocumented)port
- (undocumented)public Uri withHost(Uri.Host host)
host
- (undocumented)public Uri withHost(java.lang.String host)
host
- (undocumented)public Uri withPort(int port)
port
- (undocumented)public Uri withPath(Uri.Path path)
path
- (undocumented)public Uri withUserInfo(java.lang.String userinfo)
userinfo
- (undocumented)public Uri withQuery(Uri.Query query)
query
- (undocumented)public Uri withRawQueryString(java.lang.String rawQuery)
Characters that are not within the range described at https://tools.ietf.org/html/rfc3986#section-3.4 should be percent-encoded. Characters that are in that range may or may not be percent-encoded, and depending on how the query string is parsed this might be relevant: for example, when interpreting the query string as 'key=value' pairs you could use the percent-encoded '=' ('%22) to include a '=' in a key or value.
When characters are encountered that are outside of the RFC3986 range they are automatically percent-encoded, but be aware that relying on this is usually a programming error.
rawQuery
- (undocumented)public Uri withRawQueryString(java.lang.String rawQueryString, Uri.ParsingMode mode)
Characters that are not within the range described at https://tools.ietf.org/html/rfc3986#section-3.4 must be percent-encoded. Characters that are in that range may or may not be percent-encoded, and depending on how the query string is parsed this might be relevant: for example, when interpreting the query string as 'key=value' pairs you could use the percent-encoded '=' ('%22) to include a '=' in the key or value.
mode
- depending on the mode, characters outside of the range allowed by RFC3986 will
either cause an IllegalUriException
or be automatically percent-encoded. Be aware that relying
on automatic percent-encoding is usually a programming error.rawQueryString
- (undocumented)public Uri withFragment(java.lang.String fragment)
fragment
- (undocumented)public Uri resolvedAgainst(Uri base)
base
- (undocumented)public Uri toEffectiveHttpRequestUri(Uri.Host hostHeaderHost, int hostHeaderPort, boolean securedConnection, Uri.Authority defaultAuthority)
hostHeaderHost
- (undocumented)hostHeaderPort
- (undocumented)securedConnection
- (undocumented)defaultAuthority
- (undocumented)public Uri toEffectiveRequestUri(Uri.Host hostHeaderHost, int hostHeaderPort, java.lang.String defaultScheme, Uri.Authority defaultAuthority)
hostHeaderHost
- (undocumented)hostHeaderPort
- (undocumented)defaultScheme
- (undocumented)defaultAuthority
- (undocumented)public Uri toRelative()
public Uri toHttpRequestTargetOriginForm()
Note that the resulting URI instance is not a valid RFC 3986 URI! (As it might be a "relative" URI with a part component starting with a double slash.)
public Uri withoutFragment()
public java.lang.String toString()
toString
in class java.lang.Object