Package org.apache.http
Class HttpHost
- java.lang.Object
-
- org.apache.http.HttpHost
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable
@Immutable public final class HttpHost extends java.lang.Object implements java.lang.Cloneable, java.io.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 protected java.net.InetAddressaddressstatic java.lang.StringDEFAULT_SCHEME_NAMEThe default scheme is "http".protected java.lang.StringhostnameThe host to use.protected java.lang.StringlcHostnameThe lowercase host, forequals(java.lang.Object)andhashCode().protected intportThe port to use, defaults to -1 if not set.protected java.lang.StringschemeNameThe scheme (lowercased)
-
Constructor Summary
Constructors Constructor Description HttpHost(java.lang.String hostname)Creates a newHttpHost, with default scheme and port.HttpHost(java.lang.String hostname, int port)Creates a newHttpHost, with default scheme.HttpHost(java.lang.String hostname, int port, java.lang.String scheme)Creates a newHttpHost, specifying all values.HttpHost(java.net.InetAddress address)Creates a newHttpHost, with default scheme and port.HttpHost(java.net.InetAddress address, int port)Creates a newHttpHost, with default scheme.HttpHost(java.net.InetAddress address, int port, java.lang.String scheme)Creates a newHttpHost, specifying all values.HttpHost(HttpHost httphost)Copy constructor forHttpHost.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Objectclone()booleanequals(java.lang.Object obj)java.net.InetAddressgetAddress()Returns the inet address if explicitly set by a constructor,nullotherwise.java.lang.StringgetHostName()Returns the host name.intgetPort()Returns the port.java.lang.StringgetSchemeName()Returns the scheme name.inthashCode()java.lang.StringtoHostString()Obtains the host string, without scheme prefix.java.lang.StringtoString()java.lang.StringtoURI()Return the host URI, as a string.
-
-
-
Field Detail
-
DEFAULT_SCHEME_NAME
public static final java.lang.String DEFAULT_SCHEME_NAME
The default scheme is "http".- See Also:
- Constant Field Values
-
hostname
protected final java.lang.String hostname
The host to use.
-
lcHostname
protected final java.lang.String lcHostname
The lowercase host, forequals(java.lang.Object)andhashCode().
-
port
protected final int port
The port to use, defaults to -1 if not set.
-
schemeName
protected final java.lang.String schemeName
The scheme (lowercased)
-
address
protected final java.net.InetAddress address
-
-
Constructor Detail
-
HttpHost
public HttpHost(java.lang.String hostname, int port, java.lang.String scheme)Creates a newHttpHost, specifying all values. Constructor for HttpHost.- Parameters:
hostname- the hostname (IP or DNS name)port- the port number.-1indicates the scheme default port.scheme- the name of the scheme.nullindicates thedefault scheme
-
HttpHost
public HttpHost(java.lang.String hostname, int port)Creates a newHttpHost, with default scheme.- Parameters:
hostname- the hostname (IP or DNS name)port- the port number.-1indicates the scheme default port.
-
HttpHost
public HttpHost(java.lang.String hostname)
Creates a newHttpHost, with default scheme and port.- Parameters:
hostname- the hostname (IP or DNS name)
-
HttpHost
public HttpHost(java.net.InetAddress address, int port, java.lang.String scheme)Creates a newHttpHost, specifying all values. Constructor for HttpHost.- Parameters:
address- the inet address.port- the port number.-1indicates the scheme default port.scheme- the name of the scheme.nullindicates thedefault scheme- Since:
- 4.3
-
HttpHost
public HttpHost(java.net.InetAddress address, int port)Creates a newHttpHost, with default scheme.- Parameters:
address- the inet address.port- the port number.-1indicates the scheme default port.- Since:
- 4.3
-
HttpHost
public HttpHost(java.net.InetAddress address)
Creates a newHttpHost, with default scheme and port.- Parameters:
address- the inet address.- Since:
- 4.3
-
-
Method Detail
-
getHostName
public java.lang.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
-1if not set
-
getSchemeName
public java.lang.String getSchemeName()
Returns the scheme name.- Returns:
- the scheme name
-
getAddress
public java.net.InetAddress getAddress()
Returns the inet address if explicitly set by a constructor,nullotherwise.- Returns:
- the inet address
- Since:
- 4.3
-
toURI
public java.lang.String toURI()
Return the host URI, as a string.- Returns:
- the host URI
-
toHostString
public java.lang.String toHostString()
Obtains the host string, without scheme prefix.- Returns:
- the host string, for example
localhost:8080
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object- See Also:
Object.hashCode()
-
clone
public java.lang.Object clone() throws java.lang.CloneNotSupportedException- Overrides:
clonein classjava.lang.Object- Throws:
java.lang.CloneNotSupportedException
-
-