1 25 26 27 package org.objectweb.jonathan.apis.protocols.ip; 28 29 import org.objectweb.jonathan.apis.protocols.SessionIdentifier; 30 import org.objectweb.jonathan.apis.protocols.ProtocolIdentifiers; 31 32 33 40 abstract public class IpSessionIdentifier implements SessionIdentifier, ProtocolIdentifiers { 41 42 43 public String hostname; 44 45 46 public int port; 47 48 56 public IpSessionIdentifier(String hostname, int port) { 57 this.hostname = hostname; 58 this.port = port; 59 } 60 61 64 public IpSessionIdentifier() { 65 this.port = 0; 66 } 67 68 73 public int hashCode() { 74 if (hostname == null) { 75 return port; 76 } else { 77 return hostname.hashCode() + port; 78 } 79 } 80 81 90 public boolean equals(Object o) { 91 if (o != null && o instanceof IpSessionIdentifier) { 92 IpSessionIdentifier k = (IpSessionIdentifier)o; 93 return port == k.port && hostname.equals(k.hostname); 94 } else { 95 return false; 96 } 97 } 98 99 104 public String toString() { 105 return "IpSessionIdentifier["+hostname+","+port+"]"; 106 } 107 108 115 public SessionIdentifier[] next() { 116 return new SessionIdentifier[0]; 117 } 118 119 public final int getProtocolId() { 120 return ProtocolIdentifiers.TCPIP; 121 } 122 123 } 124 | Popular Tags |