HttpHostpublic final class HttpHost extends Object implements CloneableHolds all of the variables needed to describe an HTTP connection to a host.
This includes remote host name, port and scheme. |
Fields Summary |
---|
public static final String | DEFAULT_SCHEME_NAMEThe default scheme is "http". | protected final String | hostnameThe host to use. | protected final String | lcHostnameThe lowercase host, for {@link #equals} and {@link #hashCode}. | protected final int | portThe port to use. | protected final String | schemeNameThe scheme |
Constructors Summary |
---|
public HttpHost(String hostname, int port, String scheme)Creates a new {@link HttpHost HttpHost}, specifying all values.
Constructor for HttpHost.
super();
if (hostname == null) {
throw new IllegalArgumentException("Host name may not be null");
}
this.hostname = hostname;
this.lcHostname = hostname.toLowerCase(Locale.ENGLISH);
if (scheme != null) {
this.schemeName = scheme.toLowerCase(Locale.ENGLISH);
} else {
this.schemeName = DEFAULT_SCHEME_NAME;
}
this.port = port;
| public HttpHost(String hostname, int port)Creates a new {@link HttpHost HttpHost}, with default scheme.
this(hostname, port, null);
| public HttpHost(String hostname)Creates a new {@link HttpHost HttpHost}, with default scheme and port.
this(hostname, -1, null);
| public HttpHost(HttpHost httphost)Copy constructor for {@link HttpHost HttpHost}.
this(httphost.hostname, httphost.port, httphost.schemeName);
|
Methods Summary |
---|
public java.lang.Object | clone()
return super.clone();
| public boolean | equals(java.lang.Object obj)
if (obj == null) return false;
if (this == obj) return true;
if (obj instanceof HttpHost) {
HttpHost that = (HttpHost) obj;
return this.lcHostname.equals(that.lcHostname)
&& this.port == that.port
&& this.schemeName.equals(that.schemeName);
} else {
return false;
}
| public java.lang.String | getHostName()Returns the host name.
return this.hostname;
| public int | getPort()Returns the port.
return this.port;
| public java.lang.String | getSchemeName()Returns the scheme name.
return this.schemeName;
| public int | hashCode()
int hash = LangUtils.HASH_SEED;
hash = LangUtils.hashCode(hash, this.lcHostname);
hash = LangUtils.hashCode(hash, this.port);
hash = LangUtils.hashCode(hash, this.schemeName);
return hash;
| public java.lang.String | toHostString()Obtains the host string, without scheme prefix.
CharArrayBuffer buffer = new CharArrayBuffer(32);
buffer.append(this.hostname);
if (this.port != -1) {
buffer.append(':");
buffer.append(Integer.toString(this.port));
}
return buffer.toString();
| public java.lang.String | toString()
return toURI();
| public java.lang.String | toURI()Return the host URI, as a string.
CharArrayBuffer buffer = new CharArrayBuffer(32);
buffer.append(this.schemeName);
buffer.append("://");
buffer.append(this.hostname);
if (this.port != -1) {
buffer.append(':");
buffer.append(Integer.toString(this.port));
}
return buffer.toString();
|
|