1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
|
// /Copyright 2003-2005 Arthur van Hoff, Rick Blair
// Licensed under Apache License version 2.0
// Original license LGPL
package javax.jmdns.impl;
import javax.jmdns.JmDNS;
import javax.jmdns.ServiceEvent;
import javax.jmdns.ServiceInfo;
/**
* ServiceEvent.
*
* @author Werner Randelshofer, Rick Blair
*/
/**
*
*/
public class ServiceEventImpl extends ServiceEvent {
/**
*
*/
private static final long serialVersionUID = 7107973622016897488L;
// private static Logger logger = Logger.getLogger(ServiceEvent.class.getName());
/**
* The type name of the service.
*/
private final String _type;
/**
* The instance name of the service. Or null, if the event was fired to a service type listener.
*/
private final String _name;
/**
* The service info record, or null if the service could be be resolved. This is also null, if the event was fired to a service type listener.
*/
private final ServiceInfo _info;
/**
* Creates a new instance.
*
* @param jmDNS
* the JmDNS instance which originated the event.
* @param type
* the type name of the service.
* @param name
* the instance name of the service.
* @param info
* the service info record, or null if the service could be be resolved.
*/
public ServiceEventImpl(JmDNSImpl jmDNS, String type, String name, ServiceInfo info) {
super(jmDNS);
this._type = type;
this._name = name;
this._info = info;
}
/*
* (non-Javadoc)
* @see javax.jmdns.ServiceEvent#getDNS()
*/
@Override
public JmDNS getDNS() {
return (JmDNS) getSource();
}
/*
* (non-Javadoc)
* @see javax.jmdns.ServiceEvent#getType()
*/
@Override
public String getType() {
return _type;
}
/*
* (non-Javadoc)
* @see javax.jmdns.ServiceEvent#getName()
*/
@Override
public String getName() {
return _name;
}
/*
* (non-Javadoc)
* @see java.util.EventObject#toString()
*/
@Override
public String toString() {
StringBuilder buf = new StringBuilder();
buf.append("[" + this.getClass().getSimpleName() + "@" + System.identityHashCode(this) + " ");
buf.append("\n\tname: '");
buf.append(this.getName());
buf.append("' type: '");
buf.append(this.getType());
buf.append("' info: '");
buf.append(this.getInfo());
buf.append("']");
// buf.append("' source: ");
// buf.append("\n\t" + source + "");
// buf.append("\n]");
return buf.toString();
}
/*
* (non-Javadoc)
* @see javax.jmdns.ServiceEvent#getInfo()
*/
@Override
public ServiceInfo getInfo() {
return _info;
}
/*
* (non-Javadoc)
* @see javax.jmdns.ServiceEvent#clone()
*/
@Override
public ServiceEventImpl clone() {
ServiceInfoImpl newInfo = new ServiceInfoImpl(this.getInfo());
return new ServiceEventImpl((JmDNSImpl) this.getDNS(), this.getType(), this.getName(), newInfo);
}
}
|