1 package org.sapia.ubik.mcast; 2 3 import org.sapia.ubik.net.ServerAddress; 4 5 import java.net.InetAddress ; 6 7 8 19 public class InetServerAddress implements ServerAddress { 20 private String _transportType = "udp/event/address"; 21 private InetAddress _addr; 22 private int _port; 23 private int _hashCode; 24 25 34 public InetServerAddress(InetAddress addr, int port) { 35 _addr = addr; 36 _port = port; 37 _hashCode = (addr.toString() + port).hashCode(); 38 } 39 40 45 public InetAddress getInetAddress() { 46 return _addr; 47 } 48 49 54 public int getPort() { 55 return _port; 56 } 57 58 61 public boolean equals(Object other) { 62 try { 63 InetServerAddress addr = (InetServerAddress) other; 64 65 return addr._addr.equals(_addr) && (addr._port == _port); 66 } catch (ClassCastException e) { 67 return false; 68 } 69 } 70 71 74 public String getTransportType() { 75 return _transportType; 76 } 77 78 81 public int hashCode() { 82 return _hashCode; 83 } 84 85 public String toString(){ 86 return new StringBuffer ("[") 87 .append("address=").append(_addr) 88 .append(" ,port=").append(_port) 89 .append("]").toString(); 90 } 91 } 92 | Popular Tags |