| 1 package com.ubermq.jms.client.impl; 2 3 import com.ubermq.jms.client.*; 4 import java.net.*; 5 import java.util.*; 6 7 11 public class SimpleInternetConnectionDescriptor 12 implements InternetConnectionDescriptor 13 { 14 private static final long serialVersionUID = 1l; 15 private SocketAddress addr; 16 17 25 public SimpleInternetConnectionDescriptor(String url, 26 int defaultPort) 27 { 28 url = url.substring(url.lastIndexOf('/') + 1); 30 31 String host; 33 int port; 34 35 StringTokenizer st = new StringTokenizer(url, ":"); 36 if (st.countTokens() >= 2) { 37 host = st.nextToken(); 38 port = Integer.valueOf(st.nextToken()).intValue(); 39 } else { 40 host = url; 41 port = defaultPort; 42 } 43 44 this.addr = new InetSocketAddress(host, port); 45 } 46 47 51 public SimpleInternetConnectionDescriptor(SocketAddress addr) 52 { 53 this.addr = addr; 54 } 55 56 public SocketAddress getAddress() {return addr;} 57 58 public String toString() 59 { 60 return addr.toString(); 61 } 62 63 public int hashCode() 64 { 65 return addr.hashCode(); 66 } 67 68 public boolean equals(Object o) 69 { 70 if (o instanceof InternetConnectionDescriptor) { 71 return addr.equals(((InternetConnectionDescriptor)o).getAddress()); 72 } 73 else return false; 74 } 75 } 76 | Popular Tags |