Class UriAuthority
URI authority is a host plus an optional port. Userinfo is not supported.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic UriAuthorityCreate a normalized authority from a host and optional port.static UriAuthorityParse and normalize authority text.static UriAuthoritycreateForUri(String authority) Parse and normalize URI authority text.static UriAuthoritycreateForUri(String host, int port) Create a normalized URI authority from a host and optional port.booleaninthashCode()booleanhasPort()Whether the authority has a port.host()Host.intport()Port.intportOrDefault(int defaultPort) Port or a default value.toString()
-
Field Details
-
UNDEFINED_PORT
public static final int UNDEFINED_PORTUndefined port value.- See Also:
-
-
Method Details
-
create
Create a normalized authority from a host and optional port. The host must be a DNS name or IP literal, not a generic URI registered name.- Parameters:
host- normalized hostport- port, or -1 when absent- Returns:
- normalized authority
- Throws:
NullPointerException- in case the host isnullIllegalArgumentException- in case the host is a generic registered name or the port is invalid
-
create
Parse and normalize authority text.Only DNS hosts and IP literals are accepted. DNS hosts are normalized to lower-case ASCII. IPv6 authorities must use brackets. An explicit port must not be empty. Use
createForUri(String)for generic URI registered names or an empty port.- Parameters:
authority- authority text containing a host and optional port- Returns:
- normalized authority
- Throws:
NullPointerException- in case the authority isnullIllegalArgumentException- in case the authority is invalid
-
createForUri
Parse and normalize URI authority text.Unlike
create(String), this method accepts generic registered names as defined by RFC 3986. Unreserved percent-encoded characters are decoded. DNS and IP normalization is used when applicable; other registered names are normalized to lower case, retaining other percent-encoded characters using upper-case hex digits. IPv6 authorities must use brackets. An empty port is treated as absent. Userinfo and empty hosts are not supported.- Parameters:
authority- authority text containing a host and optional port- Returns:
- normalized URI authority
- Throws:
NullPointerException- in case the authority isnullIllegalArgumentException- in case the authority is invalid
-
createForUri
Create a normalized URI authority from a host and optional port.Unlike
create(UriHost, int), this method accepts generic registered names as defined by RFC 3986. Host normalization is the same as forcreateForUri(String).- Parameters:
host- host text, without a port or IPv6 bracketsport- port, or -1 when absent- Returns:
- normalized URI authority
- Throws:
NullPointerException- in case the host isnullIllegalArgumentException- in case the host or port is invalid
-
host
-
port
-
hasPort
public boolean hasPort()Whether the authority has a port.- Returns:
- whether a port is defined
-
portOrDefault
public int portOrDefault(int defaultPort) Port or a default value.- Parameters:
defaultPort- default port to use when the authority has no port- Returns:
- authority port or the provided default port
-
equals
-
hashCode
-
toString
-