Package org.apache.http
Class HttpHost
- java.lang.Object
-
- org.apache.http.HttpHost
-
- All Implemented Interfaces:
Serializable
,Cloneable
@Contract(threading=IMMUTABLE) public final class HttpHost extends Object implements Cloneable, Serializable
Holds all of the variables needed to describe an HTTP connection to a host. This includes remote host name, port and scheme.- Since:
- 4.0
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static String
DEFAULT_SCHEME_NAME
The default scheme is "http".
-
Constructor Summary
Constructors Constructor Description HttpHost(String hostname)
CreatesHttpHost
instance with the default scheme and port and the given hostname.HttpHost(String hostname, int port)
CreatesHttpHost
instance with the default scheme and the given hostname and port.HttpHost(String hostname, int port, String scheme)
CreatesHttpHost
instance with the given scheme, hostname and port.HttpHost(InetAddress address)
CreatesHttpHost
instance with the default scheme and port and the given inet address.HttpHost(InetAddress address, int port)
CreatesHttpHost
instance with the default scheme and the given inet address and port.HttpHost(InetAddress address, int port, String scheme)
CreatesHttpHost
instance with the given scheme, inet address and port.HttpHost(InetAddress address, String hostname, int port, String scheme)
Creates a newHttpHost
, specifying all values.HttpHost(HttpHost httphost)
Copy constructor forHttpHost
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Object
clone()
static HttpHost
create(String s)
CreatesHttpHost
instance from string.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.
-
-
-
Field Detail
-
DEFAULT_SCHEME_NAME
public static final String DEFAULT_SCHEME_NAME
The default scheme is "http".- See Also:
- Constant Field Values
-
-
Constructor Detail
-
HttpHost
public HttpHost(String hostname, int port, String scheme)
CreatesHttpHost
instance with the given scheme, hostname and port.- Parameters:
hostname
- the hostname (IP or DNS name)port
- the port number.-1
indicates the scheme default port.scheme
- the name of the scheme.null
indicates thedefault scheme
-
HttpHost
public HttpHost(String hostname, int port)
CreatesHttpHost
instance with the default scheme and the given hostname and port.- Parameters:
hostname
- the hostname (IP or DNS name)port
- the port number.-1
indicates the scheme default port.
-
HttpHost
public HttpHost(String hostname)
CreatesHttpHost
instance with the default scheme and port and the given hostname.- Parameters:
hostname
- the hostname (IP or DNS name)
-
HttpHost
public HttpHost(InetAddress address, int port, String scheme)
CreatesHttpHost
instance with the given scheme, inet address and port.- Parameters:
address
- the inet address.port
- the port number.-1
indicates the scheme default port.scheme
- the name of the scheme.null
indicates thedefault scheme
- Since:
- 4.3
-
HttpHost
public HttpHost(InetAddress address, String hostname, int port, String scheme)
Creates a newHttpHost
, specifying all values. Constructor for HttpHost.- Parameters:
address
- the inet address.hostname
- the hostname (IP or DNS name)port
- the port number.-1
indicates the scheme default port.scheme
- the name of the scheme.null
indicates thedefault scheme
- Since:
- 4.4
-
HttpHost
public HttpHost(InetAddress address, int port)
CreatesHttpHost
instance with the default scheme and the given inet address and port.- Parameters:
address
- the inet address.port
- the port number.-1
indicates the scheme default port.- Since:
- 4.3
-
HttpHost
public HttpHost(InetAddress address)
CreatesHttpHost
instance with the default scheme and port and the given inet address.- Parameters:
address
- the inet address.- Since:
- 4.3
-
-
Method Detail
-
create
public static HttpHost create(String s)
CreatesHttpHost
instance from string. Text may not contain any blanks.- Since:
- 4.4
-
getHostName
public String getHostName()
Returns the host name.- Returns:
- the host name (IP or DNS name)
-
getPort
public int getPort()
Returns the port.- Returns:
- the host port, or
-1
if not set
-
getSchemeName
public String getSchemeName()
Returns the scheme name.- Returns:
- the scheme name
-
getAddress
public InetAddress getAddress()
Returns the inet address if explicitly set by a constructor,null
otherwise.- Returns:
- the inet address
- Since:
- 4.3
-
toURI
public String toURI()
Return the host URI, as a string.- Returns:
- the host URI
-
toHostString
public String toHostString()
Obtains the host string, without scheme prefix.- Returns:
- the host string, for example
localhost:8080
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classObject
- See Also:
Object.hashCode()
-
clone
public Object clone() throws CloneNotSupportedException
- Throws:
CloneNotSupportedException
-
-