1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
package javax.jmdns.impl.tasks.resolver; |
6 |
|
|
7 |
|
import java.io.IOException; |
8 |
|
|
9 |
|
import javax.jmdns.impl.DNSOutgoing; |
10 |
|
import javax.jmdns.impl.DNSQuestion; |
11 |
|
import javax.jmdns.impl.DNSRecord; |
12 |
|
import javax.jmdns.impl.JmDNSImpl; |
13 |
|
import javax.jmdns.impl.ServiceInfoImpl; |
14 |
|
import javax.jmdns.impl.constants.DNSRecordClass; |
15 |
|
import javax.jmdns.impl.constants.DNSRecordType; |
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
|
|
|
| 46.8% |
Uncovered Elements: 25 (47) |
Complexity: 13 |
Complexity Density: 0.48 |
|
22 |
|
public class ServiceInfoResolver extends DNSResolverTask { |
23 |
|
|
24 |
|
private final ServiceInfoImpl _info; |
25 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
26 |
21
|
public ServiceInfoResolver(JmDNSImpl jmDNSImpl, ServiceInfoImpl info) {... |
27 |
21
|
super(jmDNSImpl); |
28 |
21
|
this._info = info; |
29 |
21
|
info.setDns(this.getDns()); |
30 |
21
|
this.getDns().addListener(info, DNSQuestion.newQuestion(info.getQualifiedName(), DNSRecordType.TYPE_ANY, DNSRecordClass.CLASS_IN, DNSRecordClass.NOT_UNIQUE)); |
31 |
|
} |
32 |
|
|
33 |
|
|
34 |
|
|
35 |
|
@see |
36 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 2 |
Complexity Density: 2 |
|
37 |
0
|
@Override... |
38 |
|
public String getName() { |
39 |
0
|
return "ServiceInfoResolver(" + (this.getDns() != null ? this.getDns().getName() : "") + ")"; |
40 |
|
} |
41 |
|
|
42 |
|
|
43 |
|
|
44 |
|
@see |
45 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
46 |
18
|
@Override... |
47 |
|
public boolean cancel() { |
48 |
|
|
49 |
18
|
boolean result = super.cancel(); |
50 |
18
|
if (!_info.isPersistent()) { |
51 |
2
|
this.getDns().removeListener(_info); |
52 |
|
} |
53 |
18
|
return result; |
54 |
|
} |
55 |
|
|
56 |
|
|
57 |
|
|
58 |
|
@see |
59 |
|
|
|
|
| 30.8% |
Uncovered Elements: 9 (13) |
Complexity: 3 |
Complexity Density: 0.33 |
|
60 |
54
|
@Override... |
61 |
|
protected DNSOutgoing addAnswers(DNSOutgoing out) throws IOException { |
62 |
54
|
DNSOutgoing newOut = out; |
63 |
54
|
if (!_info.hasData()) { |
64 |
0
|
long now = System.currentTimeMillis(); |
65 |
0
|
newOut = this.addAnswer(newOut, (DNSRecord) this.getDns().getCache().getDNSEntry(_info.getQualifiedName(), DNSRecordType.TYPE_SRV, DNSRecordClass.CLASS_IN), now); |
66 |
0
|
newOut = this.addAnswer(newOut, (DNSRecord) this.getDns().getCache().getDNSEntry(_info.getQualifiedName(), DNSRecordType.TYPE_TXT, DNSRecordClass.CLASS_IN), now); |
67 |
0
|
if (_info.getServer().length() > 0) { |
68 |
0
|
newOut = this.addAnswer(newOut, (DNSRecord) this.getDns().getCache().getDNSEntry(_info.getServer(), DNSRecordType.TYPE_A, DNSRecordClass.CLASS_IN), now); |
69 |
0
|
newOut = this.addAnswer(newOut, (DNSRecord) this.getDns().getCache().getDNSEntry(_info.getServer(), DNSRecordType.TYPE_AAAA, DNSRecordClass.CLASS_IN), now); |
70 |
|
} |
71 |
|
} |
72 |
54
|
return newOut; |
73 |
|
} |
74 |
|
|
75 |
|
|
76 |
|
|
77 |
|
@see |
78 |
|
|
|
|
| 33.3% |
Uncovered Elements: 8 (12) |
Complexity: 3 |
Complexity Density: 0.38 |
|
79 |
54
|
@Override... |
80 |
|
protected DNSOutgoing addQuestions(DNSOutgoing out) throws IOException { |
81 |
54
|
DNSOutgoing newOut = out; |
82 |
54
|
if (!_info.hasData()) { |
83 |
0
|
newOut = this.addQuestion(newOut, DNSQuestion.newQuestion(_info.getQualifiedName(), DNSRecordType.TYPE_SRV, DNSRecordClass.CLASS_IN, DNSRecordClass.NOT_UNIQUE)); |
84 |
0
|
newOut = this.addQuestion(newOut, DNSQuestion.newQuestion(_info.getQualifiedName(), DNSRecordType.TYPE_TXT, DNSRecordClass.CLASS_IN, DNSRecordClass.NOT_UNIQUE)); |
85 |
0
|
if (_info.getServer().length() > 0) { |
86 |
0
|
newOut = this.addQuestion(newOut, DNSQuestion.newQuestion(_info.getServer(), DNSRecordType.TYPE_A, DNSRecordClass.CLASS_IN, DNSRecordClass.NOT_UNIQUE)); |
87 |
0
|
newOut = this.addQuestion(newOut, DNSQuestion.newQuestion(_info.getServer(), DNSRecordType.TYPE_AAAA, DNSRecordClass.CLASS_IN, DNSRecordClass.NOT_UNIQUE)); |
88 |
|
} |
89 |
|
} |
90 |
54
|
return newOut; |
91 |
|
} |
92 |
|
|
93 |
|
|
94 |
|
|
95 |
|
@see |
96 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 2 |
Complexity Density: 2 |
|
97 |
0
|
@Override... |
98 |
|
protected String description() { |
99 |
0
|
return "querying service info: " + (_info != null ? _info.getQualifiedName() : "null"); |
100 |
|
} |
101 |
|
|
102 |
|
} |