org.apache.hc.core5.net

## Class Host

- java.lang.Object
- - org.apache.hc.core5.net.Host

- All Implemented Interfaces:
    Serializable, NamedEndpoint

      @Contract(threading=IMMUTABLE)
      public final class Host
      extends Object
      implements NamedEndpoint, 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 and Description
    `Host(String name, int port)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static Host` | `create(String s)`
    `boolean` | `equals(Object o)`
    `String` | `getHostName()` Returns name (IP or DNS name).
    `int` | `getPort()` Returns the port.
    `int` | `hashCode()`
    `String` | `toString()`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### Host

          public Host(String name,
              int port)

  - ### Method Detail

    - #### create

          public static Host create(String s)
                             throws URISyntaxException

      Throws:
        `URISyntaxException`

    - #### getHostName

          public String getHostName()

      Description copied from interface: `NamedEndpoint`
      Returns name (IP or DNS name).
      Specified by:
        `getHostName` in interface `NamedEndpoint`
      Returns:
        the host name (IP or DNS name)

    - #### getPort

          public int getPort()

      Description copied from interface: `NamedEndpoint`
      Returns the port.
      Specified by:
        `getPort` in interface `NamedEndpoint`
      Returns:
        the host port, or `-1` if not set

    - #### equals

          public boolean equals(Object o)

      Overrides:
        `equals` in class `Object`

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `Object`

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

Copyright © 2005–2020 The Apache Software Foundation. All rights reserved.