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
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.String
lcName
private java.lang.String
name
private int
port
private static long
serialVersionUID
-
Constructor Summary
Constructors Constructor Description Host(java.lang.String name, int port)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Host
create(java.lang.String s)
boolean
equals(java.lang.Object o)
(package private) static void
format(java.lang.StringBuilder buf, Host host)
(package private) static void
format(java.lang.StringBuilder buf, NamedEndpoint endpoint)
(package private) static java.lang.String
format(Host host)
java.lang.String
getHostName()
Returns name (IP or DNS name).int
getPort()
Returns the port.int
hashCode()
(package private) static Host
parse(java.lang.CharSequence s)
(package private) static Host
parse(java.lang.CharSequence s, Tokenizer.Cursor cursor)
java.lang.String
toString()
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
name
private final java.lang.String name
-
lcName
private final java.lang.String lcName
-
port
private final int port
-
-
Method Detail
-
parse
static Host parse(java.lang.CharSequence s, Tokenizer.Cursor cursor) throws java.net.URISyntaxException
- Throws:
java.net.URISyntaxException
-
parse
static Host parse(java.lang.CharSequence s) throws java.net.URISyntaxException
- Throws:
java.net.URISyntaxException
-
format
static void format(java.lang.StringBuilder buf, NamedEndpoint endpoint)
-
format
static void format(java.lang.StringBuilder buf, Host host)
-
format
static java.lang.String format(Host host)
-
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:NamedEndpoint
Returns name (IP or DNS name).- Specified by:
getHostName
in interfaceNamedEndpoint
- Returns:
- the host name (IP or DNS name)
-
getPort
public int getPort()
Description copied from interface:NamedEndpoint
Returns the port.- Specified by:
getPort
in interfaceNamedEndpoint
- Returns:
- the host port, or
-1
if not set
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-