java.lang.Object
org.newsclub.net.unix.HostAndPort
-
Constructor Summary
ConstructorDescriptionHostAndPort
(String hostname, int port) Creates a new hostname and port combination. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Returns the hostname.int
getPort()
Returns the port, or-1
for "no port specified".int
hashCode()
static HostAndPort
Tries to extract hostname and port information from the given URI.toString()
Returns a URI with this hostname and port.Returns a URI with this hostname and port, potentially using other URI parameters from the given set of parameters.Returns a URI with this hostname and port, potentially reusing other URI parameters from the given template URI (authority, path, query, fragment).
-
Constructor Details
-
HostAndPort
Creates a new hostname and port combination.- Parameters:
hostname
- The hostname.port
- The port, or-1
for "no port".
-
-
Method Details
-
hashCode
-
equals
-
toString
-
parseFrom
Tries to extract hostname and port information from the given URI.- Parameters:
u
- The URI to extract from.- Returns:
- The parsed
HostAndPort
instance. - Throws:
SocketException
- on error.
-
getHostname
-
getPort
public int getPort()Returns the port, or-1
for "no port specified".- Returns:
- The port.
-
toURI
-
toURI
-
toURI
public URI toURI(String scheme, String rawAuthority, String rawPath, String rawQuery, String rawFragment) Returns a URI with this hostname and port, potentially using other URI parameters from the given set of parameters.- Parameters:
scheme
- The scheme to use.rawAuthority
- The raw authority field, ornull
.rawPath
- The raw path field, ornull
.rawQuery
- The raw query field, ornull
.rawFragment
- The raw fragment field, ornull
.- Returns:
- The URI.
-