1 /*
   2  * Copyright (c) 1998, 2004, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package com.sun.corba.se.impl.legacy.connection;
  27 
  28 import com.sun.corba.se.spi.legacy.connection.LegacyServerSocketEndPointInfo;
  29 import com.sun.corba.se.spi.transport.SocketInfo;
  30 
  31 public class EndPointInfoImpl
  32     implements
  33         SocketInfo,
  34         LegacyServerSocketEndPointInfo
  35 {
  36 
  37     protected String type;
  38     protected String hostname;
  39     protected int port;
  40     protected int locatorPort;
  41     protected String name;
  42 
  43     public EndPointInfoImpl(String type, int port, String hostname) {
  44         this.type = type;
  45         this.port = port;
  46         this.hostname = hostname;
  47         this.locatorPort = -1;
  48         this.name = LegacyServerSocketEndPointInfo.NO_NAME;
  49     }
  50 
  51     public String getType() {
  52         return type;
  53     }
  54 
  55     public String getHost() {
  56         return hostname;
  57     }
  58 
  59     public String getHostName() {
  60         return hostname;
  61     }
  62 
  63     public int getPort() {
  64         return port;
  65     }
  66 
  67     public int getLocatorPort ()
  68     {
  69         return locatorPort;
  70     }
  71 
  72     public void setLocatorPort (int port)
  73     {
  74         locatorPort = port;
  75     }
  76 
  77     public String getName()
  78     {
  79         return name;
  80     }
  81 
  82     public int hashCode() {
  83         return type.hashCode() ^ hostname.hashCode() ^ port;
  84     }
  85 
  86     public boolean equals(Object obj) {
  87         if (!(obj instanceof EndPointInfoImpl)) {
  88             return false;
  89         }
  90         EndPointInfoImpl other = (EndPointInfoImpl)obj;
  91         if (type == null) {
  92             if (other.type != null) {
  93                 return false;
  94             }
  95         } else if (!type.equals(other.type)) {
  96             return false;
  97         }
  98         if (port != other.port) {
  99             return false;
 100         }
 101         if (!hostname.equals(other.hostname)) {
 102             return false;
 103         }
 104         return true;
 105     }
 106 
 107     public String toString ()
 108     {
 109         return
 110             type + " " +
 111             name + " " +
 112             hostname + " " +
 113             port;
 114     }
 115 }
 116 
 117 // End of file.