1 20 package fr.dyade.aaa.util; 21 22 import java.util.*; 23 24 public class ServerAddress implements java.io.Serializable { 25 26 public static ServerAddress valueOf(String s) throws Exception { 27 StringTokenizer tokenizer = new StringTokenizer(s, "=:"); 28 String serverName = tokenizer.nextToken(); 29 String hostName = tokenizer.nextToken(); 30 String portS = tokenizer.nextToken(); 31 int port = Integer.valueOf(portS).intValue(); 32 return new ServerAddress(serverName, hostName, port); 33 } 34 35 private String serverName; 36 37 private String hostName; 38 39 private int port; 40 41 public ServerAddress(String serverName, 42 String hostName, 43 int port) { 44 this.serverName = serverName; 45 this.hostName = hostName; 46 this.port = port; 47 } 48 49 public final String getServerName() { 50 return serverName; 51 } 52 53 public final String getHostName() { 54 return hostName; 55 } 56 57 public final int getPort() { 58 return port; 59 } 60 61 public String toString() { 62 return serverName + '=' + hostName + ':' + port; 63 } 64 65 public boolean equals(Object obj) { 66 if (obj instanceof ServerAddress) { 67 ServerAddress sa = (ServerAddress)obj; 68 if (! sa.serverName.equals(serverName)) return false; 69 if (! sa.hostName.equals(hostName)) return false; 70 return (sa.port == port); 71 } else { 72 return false; 73 } 74 } 75 } 76 | Popular Tags |