Package org.apache.hc.core5.net
Class Host
- java.lang.Object
-
- org.apache.hc.core5.net.Host
-
- All Implemented Interfaces:
java.io.Serializable,NamedEndpoint
@Contract(threading=IMMUTABLE) public final class Host extends java.lang.Object implements NamedEndpoint, java.io.Serializable
Component that holds all details needed to describe a network connection to a host. This includes remote host name and port.- Since:
- 5.0
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description Host(java.lang.String name, int port)Constructs a new instance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Hostcreate(java.lang.String s)booleanequals(java.lang.Object o)java.lang.StringgetHostName()Returns name (IP or DNS name).intgetPort()Returns the port.inthashCode()java.lang.StringtoString()
-
-
-
Constructor Detail
-
Host
public Host(java.lang.String name, int port)Constructs a new instance.- Parameters:
name- The host name, not null.port- The port value, between 0 and 65535, inclusive.-1indicates the scheme default port.- Throws:
java.lang.NullPointerException- if thenameisnull.java.lang.IllegalArgumentException- If the port parameter is outside the specified range of valid port values, which is between 0 and 65535, inclusive.-1indicates the scheme default port.
-
-
Method Detail
-
create
public static Host create(java.lang.String s) throws java.net.URISyntaxException
- Throws:
java.net.URISyntaxException
-
getHostName
public java.lang.String getHostName()
Description copied from interface:NamedEndpointReturns name (IP or DNS name).- Specified by:
getHostNamein interfaceNamedEndpoint- Returns:
- the host name (IP or DNS name)
-
getPort
public int getPort()
Description copied from interface:NamedEndpointReturns the port.- Specified by:
getPortin interfaceNamedEndpoint- Returns:
- the host port, or
-1if not set
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-