@Contract(threading=IMMUTABLE) public final class HttpHost extends Object implements NamedEndpoint, Serializable
Host
,
Serialized FormModifier and Type | Field and Description |
---|---|
static URIScheme |
DEFAULT_SCHEME
The default scheme is "http".
|
Constructor and Description |
---|
HttpHost(InetAddress address)
Creates
HttpHost instance with the default scheme and port and the given inet
address. |
HttpHost(InetAddress address,
int port)
Creates
HttpHost instance with the default scheme and the given inet address
and port. |
HttpHost(String hostname)
Creates
HttpHost instance with the default scheme and port and the given hostname. |
HttpHost(String scheme,
InetAddress address,
int port)
Creates
HttpHost instance with the given scheme, inet address and port. |
HttpHost(String scheme,
InetAddress address,
String hostname,
int port)
Creates a new
HttpHost , specifying all values. |
HttpHost(String hostname,
int port)
Creates
HttpHost instance with the default scheme and the given hostname and port. |
HttpHost(String scheme,
NamedEndpoint namedEndpoint) |
HttpHost(String scheme,
String hostname)
Creates
HttpHost instance with the given hostname and scheme and the default port for that scheme. |
HttpHost(String scheme,
String hostname,
int port)
Creates
HttpHost instance with the given scheme, hostname and port. |
HttpHost(URIAuthority authority) |
Modifier and Type | Method and Description |
---|---|
static HttpHost |
create(String s)
Creates
HttpHost instance from a string. |
static HttpHost |
create(URI uri)
Creates an
HttpHost instance from the scheme, host, and port from the given URI. |
boolean |
equals(Object obj) |
InetAddress |
getAddress()
Returns the inet address if explicitly set by a constructor,
null otherwise. |
String |
getHostName()
Returns the host name.
|
int |
getPort()
Returns the port.
|
String |
getSchemeName()
Returns the scheme name.
|
int |
hashCode() |
String |
toHostString()
Obtains the host string, without scheme prefix.
|
String |
toString() |
String |
toURI()
Return the host URI, as a string.
|
public static final URIScheme DEFAULT_SCHEME
public HttpHost(String scheme, InetAddress address, String hostname, int port)
HttpHost
, specifying all values.
Constructor for HttpHost.scheme
- the name of the scheme.
null
indicates the
default scheme
address
- the inet address. Can be null
hostname
- the hostname (IP or DNS name)port
- the port number.
-1
indicates the scheme default port.IllegalArgumentException
- If the port parameter is outside the specified range of valid port values, which is between 0 and
65535, inclusive. -1
indicates the scheme default port.public HttpHost(String scheme, String hostname, int port)
HttpHost
instance with the given scheme, hostname and port.scheme
- the name of the scheme.
null
indicates the
default scheme
hostname
- the hostname (IP or DNS name)port
- the port number.
-1
indicates the scheme default port.IllegalArgumentException
- If the port parameter is outside the specified range of valid port values, which is between 0 and
65535, inclusive. -1
indicates the scheme default port.public HttpHost(String hostname, int port)
HttpHost
instance with the default scheme and the given hostname and port.hostname
- the hostname (IP or DNS name)port
- the port number.
-1
indicates the scheme default port.IllegalArgumentException
- If the port parameter is outside the specified range of valid port values, which is between 0 and
65535, inclusive. -1
indicates the scheme default port.public HttpHost(String scheme, String hostname)
HttpHost
instance with the given hostname and scheme and the default port for that scheme.scheme
- the name of the scheme.
null
indicates the
default scheme
hostname
- the hostname (IP or DNS name)IllegalArgumentException
- If the port parameter is outside the specified range of valid port values, which is between 0 and
65535, inclusive. -1
indicates the scheme default port.public HttpHost(String hostname)
HttpHost
instance with the default scheme and port and the given hostname.hostname
- the hostname (IP or DNS name)IllegalArgumentException
- If the port parameter is outside the specified range of valid port values, which is between 0 and
65535, inclusive. -1
indicates the scheme default port.public HttpHost(String scheme, InetAddress address, int port)
HttpHost
instance with the given scheme, inet address and port.scheme
- the name of the scheme.
null
indicates the
default scheme
address
- the inet address.port
- the port number.
-1
indicates the scheme default port.IllegalArgumentException
- If the port parameter is outside the specified range of valid port values, which is between 0 and
65535, inclusive. -1
indicates the scheme default port.public HttpHost(InetAddress address, int port)
HttpHost
instance with the default scheme and the given inet address
and port.address
- the inet address.port
- the port number.
-1
indicates the scheme default port.IllegalArgumentException
- If the port parameter is outside the specified range of valid port values, which is between 0 and
65535, inclusive. -1
indicates the scheme default port.public HttpHost(InetAddress address)
HttpHost
instance with the default scheme and port and the given inet
address.address
- the inet address.IllegalArgumentException
- If the port parameter is outside the specified range of valid port values, which is between 0 and
65535, inclusive. -1
indicates the scheme default port.public HttpHost(String scheme, NamedEndpoint namedEndpoint)
IllegalArgumentException
- If the port parameter is outside the specified range of valid port values, which is between 0 and
65535, inclusive. -1
indicates the scheme default port.public HttpHost(URIAuthority authority)
IllegalArgumentException
- If the port parameter is outside the specified range of valid port values, which is between 0 and
65535, inclusive. -1
indicates the scheme default port.public static HttpHost create(String s) throws URISyntaxException
HttpHost
instance from a string. Text may not contain any blanks.URISyntaxException
public static HttpHost create(URI uri)
HttpHost
instance from the scheme, host, and port from the given URI. Other URI elements are ignored.uri
- scheme, host, and port.public String getHostName()
getHostName
in interface NamedEndpoint
public int getPort()
getPort
in interface NamedEndpoint
-1
if not setpublic String getSchemeName()
public InetAddress getAddress()
null
otherwise.public String toURI()
public String toHostString()
localhost:8080
public int hashCode()
hashCode
in class Object
Object.hashCode()
Copyright © 2005–2021 The Apache Software Foundation. All rights reserved.