00001 00004 package javax.jmdns.impl; 00005 00006 import java.net.InetAddress; 00007 00008 import javax.jmdns.JmDNS; 00009 import javax.jmdns.NetworkTopologyEvent; 00010 import javax.jmdns.NetworkTopologyListener; 00011 00015 public class NetworkTopologyEventImpl extends NetworkTopologyEvent implements Cloneable { 00016 00020 private static final long serialVersionUID = 1445606146153550463L; 00021 00022 private final InetAddress _inetAddress; 00023 00032 public NetworkTopologyEventImpl(JmDNS jmDNS, InetAddress inetAddress) { 00033 super(jmDNS); 00034 this._inetAddress = inetAddress; 00035 } 00036 00037 NetworkTopologyEventImpl(NetworkTopologyListener jmmDNS, InetAddress inetAddress) { 00038 super(jmmDNS); 00039 this._inetAddress = inetAddress; 00040 } 00041 00042 /* 00043 * (non-Javadoc) 00044 * @see javax.jmdns.NetworkTopologyEvent#getDNS() 00045 */ 00046 @Override 00047 public JmDNS getDNS() { 00048 return (this.getSource() instanceof JmDNS ? (JmDNS) getSource() : null); 00049 } 00050 00051 /* 00052 * (non-Javadoc) 00053 * @see javax.jmdns.NetworkTopologyEvent#getInetAddress() 00054 */ 00055 @Override 00056 public InetAddress getInetAddress() { 00057 return _inetAddress; 00058 } 00059 00060 @Override 00061 public String toString() { 00062 StringBuilder buf = new StringBuilder(); 00063 buf.append("[" + this.getClass().getSimpleName() + "@" + System.identityHashCode(this) + " "); 00064 buf.append("\n\tinetAddress: '"); 00065 buf.append(this.getInetAddress()); 00066 buf.append("']"); 00067 // buf.append("' source: "); 00068 // buf.append("\n\t" + source + ""); 00069 // buf.append("\n]"); 00070 return buf.toString(); 00071 } 00072 00073 /* 00074 * (non-Javadoc) 00075 * @see java.lang.Object#clone() 00076 */ 00077 @Override 00078 public NetworkTopologyEventImpl clone() throws CloneNotSupportedException { 00079 return new NetworkTopologyEventImpl(getDNS(), getInetAddress()); 00080 } 00081 00082 }