View Javadoc

    1   package org.mortbay.jetty.client;
    2
    3   import java.net.InetSocketAddress;
    4
    5   /**
    6    * @version $Revision: 3753 $ $Date: 2008-10-13 07:55:20 -0500 (Mon, 13 Oct 2008) $
    7    */
    8   public class Address
    9   {
    10      private final String host;
    11      private final int port;
    12
    13      public Address(String host, int port)
    14      {
    15          this.host = host;
    16          this.port = port;
    17      }
    18
    19      public boolean equals(Object obj)
    20      {
    21          if (this == obj) return true;
    22          if (obj == null || getClass() != obj.getClass()) return false;
    23          Address that = (Address)obj;
    24          if (port != that.port) return false;
    25          if (!host.equals(that.host)) return false;
    26          return true;
    27      }
    28
    29      public int hashCode()
    30      {
    31          int result = host.hashCode();
    32          result = 31 * result + port;
    33          return result;
    34      }
    35
    36      public String getHost()
    37      {
    38          return host;
    39      }
    40
    41      public int getPort()
    42      {
    43          return port;
    44      }
    45
    46      public InetSocketAddress toSocketAddress()
    47      {
    48          return new InetSocketAddress(getHost(), getPort());
    49      }
    50  }