@Contract(threading=IMMUTABLE) public final class HttpHost extends Object implements NamedEndpoint, Serializable
Host, 
Serialized Form| Modifier and Type | Field and Description | 
|---|---|
| static URIScheme | DEFAULT_SCHEMEThe default scheme is "http". | 
| Constructor and Description | 
|---|
| HttpHost(InetAddress address)Creates  HttpHostinstance with the default scheme and port and the given inet
 address. | 
| HttpHost(InetAddress address,
        int port)Creates  HttpHostinstance with the default scheme and the given inet address
 and port. | 
| HttpHost(String hostname)Creates  HttpHostinstance with the default scheme and port and the given hostname. | 
| HttpHost(String scheme,
        InetAddress address,
        int port)Creates  HttpHostinstance 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  HttpHostinstance with the default scheme and the given hostname and port. | 
| HttpHost(String scheme,
        NamedEndpoint namedEndpoint) | 
| HttpHost(String scheme,
        String hostname)Creates  HttpHostinstance with the given hostname and scheme and the default port for that scheme. | 
| HttpHost(String scheme,
        String hostname,
        int port)Creates  HttpHostinstance with the given scheme, hostname and port. | 
| HttpHost(URIAuthority authority) | 
| Modifier and Type | Method and Description | 
|---|---|
| static HttpHost | create(String s)Creates  HttpHostinstance from a string. | 
| static HttpHost | create(URI uri)Creates an  HttpHostinstance from the scheme, host, and port from the given URI. | 
| boolean | equals(Object obj)Indicates whether some other object is "equal to" this one. | 
| InetAddress | getAddress()Returns the inet address if explicitly set by a constructor,
    nullotherwise. | 
| String | getHostName()Returns the host name. | 
| int | getPort()Returns the port. | 
| String | getSchemeName()Returns the scheme name. | 
| int | hashCode()Returns a hash code value for the object. | 
| String | toHostString()Obtains the host string, without scheme prefix. | 
| String | toString()Returns a string representation of the object. | 
| String | toURI()Return the host URI, as a string. | 
public static final URIScheme DEFAULT_SCHEME
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(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(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 schemeaddress - 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(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 schemeaddress - the inet address. Can be nullhostname - 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, 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(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 schemehostname - 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, String hostname, int port)
HttpHost instance with the given scheme, hostname and port.scheme - the name of the scheme.
                  null indicates the
                  default schemehostname - 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(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.URISyntaxExceptionpublic 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 boolean equals(Object obj)
Object
 The equals method implements an equivalence relation on non-null object references:
 
x, x.equals(x)
 should return true.
 x and y,
 x.equals(y) should return true if and only if y.equals(x) returns
 true.
 x, y, and
 z, if x.equals(y) returns true and y.equals(z) returns
 true, then x.equals(z) should return true.
 x and y, multiple
 invocations of x.equals(y) consistently return true or consistently return
 false, provided no information used in equals comparisons on the objects is
 modified.
 x, x.equals(null) should return
 false.
 
 The equals method for class Object implements the most discriminating possible
 equivalence relation on objects; that is, for any non-null reference values x and
 y, this method returns true if and only if x and y refer to the
 same object (x == y has the value true).
 
 Note that it is generally necessary to override the hashCode method whenever this method
 is overridden, so as to maintain the general contract for the hashCode method, which
 states that equal objects must have equal hash codes.
equals in class Objectobj - the reference object with which to compare.true if this object is the same as the obj argument; false otherwise.Object.hashCode(), 
HashMappublic InetAddress getAddress()
null otherwise.public String getHostName()
getHostName in interface NamedEndpointpublic int getPort()
getPort in interface NamedEndpoint-1 if not setpublic String getSchemeName()
public int hashCode()
ObjectHashMap.
 
 The general contract of hashCode is:
 
hashCode method must consistently return the same integer, provided no
 information used in equals comparisons on the object is modified. This integer need not
 remain consistent from one execution of an application to another execution of the same
 application.
 equals(Object) method, then calling the
 hashCode method on each of the two objects must produce the same integer result.
 Object.equals(java.lang.Object) method, then calling the hashCode
 method on each of the two objects must produce distinct integer results. However, the programmer
 should be aware that producing distinct integer results for unequal objects may improve the
 performance of hash tables.
 
 As much as is reasonably practical, the hashCode method defined by class Object does
 return distinct integers for distinct objects. (This is typically implemented by converting the
 internal address of the object into an integer, but this implementation technique is not required
 by the JavaTM programming language.)
hashCode in class ObjectObject.hashCode()public String toHostString()
localhost:8080public String toString()
ObjecttoString method returns a
 string that "textually represents" this object. The result should be a concise but informative
 representation that is easy for a person to read. It is recommended that all subclasses override
 this method.
 
 The toString method for class Object returns a string consisting of the name of
 the class of which the object is an instance, the at-sign character `@', and the unsigned
 hexadecimal representation of the hash code of the object. In other words, this method returns a
 string equal to the value of: 
getClass().getName() + '@' + Integer.toHexString(hashCode())
public String toURI()