Clover Coverage Report - JmDNS 3.4.1
Coverage timestamp: Thu Aug 25 2011 13:06:33 CEST
../../../../../img/srcFileCovDistChart0.png 77% of files have more coverage
10   75   6   2
2   36   0.6   5
5     1.2  
1    
 
  TypeResolver       Line # 25 10 0% 6 17 0% 0.0
 
No Tests
 
1    // Copyright 2003-2005 Arthur van Hoff, Rick Blair
2    // Licensed under Apache License version 2.0
3    // Original license LGPL
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.JmDNSImpl.ServiceTypeEntry;
14    import javax.jmdns.impl.constants.DNSConstants;
15    import javax.jmdns.impl.constants.DNSRecordClass;
16    import javax.jmdns.impl.constants.DNSRecordType;
17   
18    /**
19    * Helper class to resolve service types.
20    * <p/>
21    * The TypeResolver queries three times consecutively for service types, and then removes itself from the timer.
22    * <p/>
23    * The TypeResolver will run only if JmDNS is in state ANNOUNCED.
24    */
 
25    public class TypeResolver extends DNSResolverTask {
26   
27    /**
28    * @param jmDNSImpl
29    */
 
30  0 toggle public TypeResolver(JmDNSImpl jmDNSImpl) {
31  0 super(jmDNSImpl);
32    }
33   
34    /*
35    * (non-Javadoc)
36    * @see javax.jmdns.impl.tasks.DNSTask#getName()
37    */
 
38  0 toggle @Override
39    public String getName() {
40  0 return "TypeResolver(" + (this.getDns() != null ? this.getDns().getName() : "") + ")";
41    }
42   
43    /*
44    * (non-Javadoc)
45    * @see javax.jmdns.impl.tasks.Resolver#addAnswers(javax.jmdns.impl.DNSOutgoing)
46    */
 
47  0 toggle @Override
48    protected DNSOutgoing addAnswers(DNSOutgoing out) throws IOException {
49  0 DNSOutgoing newOut = out;
50  0 long now = System.currentTimeMillis();
51  0 for (String type : this.getDns().getServiceTypes().keySet()) {
52  0 ServiceTypeEntry typeEntry = this.getDns().getServiceTypes().get(type);
53  0 newOut = this.addAnswer(newOut, new DNSRecord.Pointer("_services._dns-sd._udp.local.", DNSRecordClass.CLASS_IN, DNSRecordClass.NOT_UNIQUE, DNSConstants.DNS_TTL, typeEntry.getType()), now);
54    }
55  0 return newOut;
56    }
57   
58    /*
59    * (non-Javadoc)
60    * @see javax.jmdns.impl.tasks.Resolver#addQuestions(javax.jmdns.impl.DNSOutgoing)
61    */
 
62  0 toggle @Override
63    protected DNSOutgoing addQuestions(DNSOutgoing out) throws IOException {
64  0 return this.addQuestion(out, DNSQuestion.newQuestion("_services._dns-sd._udp.local.", DNSRecordType.TYPE_PTR, DNSRecordClass.CLASS_IN, DNSRecordClass.NOT_UNIQUE));
65    }
66   
67    /*
68    * (non-Javadoc)
69    * @see javax.jmdns.impl.tasks.Resolver#description()
70    */
 
71  0 toggle @Override
72    protected String description() {
73  0 return "querying type";
74    }
75    }