|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
DNSRecordClass | Line # 14 | 19 | 0% | 10 | 18 | 43.8% |
0.4375
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||
(21) | |||
Result | |||
0.4375
|
javax.jmdns.test.DNSMessageTest.testCreateQuery
![]() |
1 PASS | |
0.34375
|
javax.jmdns.test.JmDNSTest.testUnregisterService
![]() |
1 PASS | |
0.34375
|
javax.jmdns.test.TextUpdateTest.testSubtype
![]() |
1 PASS | |
0.34375
|
javax.jmdns.test.TextUpdateTest.testListenForTextUpdateOnOtherRegistry
![]() |
1 PASS | |
0.34375
|
javax.jmdns.test.JmDNSTest.testRegisterServiceTwice
![]() |
1 PASS | |
0.34375
|
javax.jmdns.test.TextUpdateTest.testRegisterCaseSensitiveField
![]() |
1 PASS | |
0.34375
|
javax.jmdns.test.JmDNSTest.testRegisterService
![]() |
1 PASS | |
0.34375
|
javax.jmdns.test.JmDNSTest.testUnregisterAndReregisterService
![]() |
1 PASS | |
0.34375
|
javax.jmdns.test.JmDNSTest.testWaitAndQueryForServiceOnOtherRegistry
![]() |
1 PASS | |
0.34375
|
javax.jmdns.test.JmDNSTest.testListMyServiceWithToLowerCase
![]() |
1 PASS | |
0.34375
|
javax.jmdns.test.JmDNSTest.testListMyService
![]() |
1 PASS | |
0.34375
|
javax.jmdns.test.JmDNSTest.testQueryMyService
![]() |
1 PASS | |
0.34375
|
javax.jmdns.test.TextUpdateTest.testRenewExpiringRequests
![]() |
1 PASS | |
0.34375
|
javax.jmdns.test.TextUpdateTest.testRegisterEmptyTXTField
![]() |
1 PASS | |
0.34375
|
javax.jmdns.test.JmDNSTest.testListMyServiceWithoutLowerCase
![]() |
1 PASS | |
0.34375
|
javax.jmdns.test.JmDNSTest.testListenForMyServiceAndList
![]() |
1 PASS | |
0.34375
|
javax.jmdns.test.JmDNSTest.testListMyServiceIPV6
![]() |
1 PASS | |
0.34375
|
javax.jmdns.test.JmDNSTest.testRegisterAndListServiceOnOtherRegistry
![]() |
1 PASS | |
0.34375
|
javax.jmdns.test.DNSMessageTest.testCreateAnswer
![]() |
1 PASS | |
0.34375
|
javax.jmdns.test.JmDNSTest.testListenForMyService
![]() |
1 PASS | |
0.34375
|
javax.jmdns.test.JmDNSTest.testListenForServiceOnOtherRegistry
![]() |
1 PASS | |
1 | /** | |
2 | * | |
3 | */ | |
4 | package javax.jmdns.impl.constants; | |
5 | ||
6 | import java.util.logging.Level; | |
7 | import java.util.logging.Logger; | |
8 | ||
9 | /** | |
10 | * DNS Record Class | |
11 | * | |
12 | * @author Arthur van Hoff, Jeff Sonstein, Werner Randelshofer, Pierre Frisch, Rick Blair | |
13 | */ | |
14 | public enum DNSRecordClass { | |
15 | /** | |
16 | * | |
17 | */ | |
18 | CLASS_UNKNOWN("?", 0), | |
19 | /** | |
20 | * static final Internet | |
21 | */ | |
22 | CLASS_IN("in", 1), | |
23 | /** | |
24 | * CSNET | |
25 | */ | |
26 | CLASS_CS("cs", 2), | |
27 | /** | |
28 | * CHAOS | |
29 | */ | |
30 | CLASS_CH("ch", 3), | |
31 | /** | |
32 | * Hesiod | |
33 | */ | |
34 | CLASS_HS("hs", 4), | |
35 | /** | |
36 | * Used in DNS UPDATE [RFC 2136] | |
37 | */ | |
38 | CLASS_NONE("none", 254), | |
39 | /** | |
40 | * Not a DNS class, but a DNS query class, meaning "all classes" | |
41 | */ | |
42 | CLASS_ANY("any", 255); | |
43 | ||
44 | private static Logger logger = Logger.getLogger(DNSRecordClass.class.getName()); | |
45 | ||
46 | /** | |
47 | * Multicast DNS uses the bottom 15 bits to identify the record class...<br/> | |
48 | * Except for pseudo records like OPT. | |
49 | */ | |
50 | public static final int CLASS_MASK = 0x7FFF; | |
51 | ||
52 | /** | |
53 | * For answers the top bit indicates that all other cached records are now invalid.<br/> | |
54 | * For questions it indicates that we should send a unicast response. | |
55 | */ | |
56 | public static final int CLASS_UNIQUE = 0x8000; | |
57 | ||
58 | /** | |
59 | * | |
60 | */ | |
61 | public static final boolean UNIQUE = true; | |
62 | ||
63 | /** | |
64 | * | |
65 | */ | |
66 | public static final boolean NOT_UNIQUE = false; | |
67 | ||
68 | private final String _externalName; | |
69 | ||
70 | private final int _index; | |
71 | ||
72 | 7 |
![]() |
73 | 7 | _externalName = name; |
74 | 7 | _index = index; |
75 | } | |
76 | ||
77 | /** | |
78 | * Return the string representation of this type | |
79 | * | |
80 | * @return String | |
81 | */ | |
82 | 0 |
![]() |
83 | 0 | return _externalName; |
84 | } | |
85 | ||
86 | /** | |
87 | * Return the numeric value of this type | |
88 | * | |
89 | * @return String | |
90 | */ | |
91 | 1863 |
![]() |
92 | 1863 | return _index; |
93 | } | |
94 | ||
95 | /** | |
96 | * Checks if the class is unique | |
97 | * | |
98 | * @param index | |
99 | * @return <code>true</code> is the class is unique, <code>false</code> otherwise. | |
100 | */ | |
101 | 1403 |
![]() |
102 | 1427 | return (this != CLASS_UNKNOWN) && ((index & CLASS_UNIQUE) != 0); |
103 | } | |
104 | ||
105 | /** | |
106 | * @param name | |
107 | * @return class for name | |
108 | */ | |
109 | 0 |
![]() |
110 | 0 | if (name != null) { |
111 | 0 | String aName = name.toLowerCase(); |
112 | 0 | for (DNSRecordClass aClass : DNSRecordClass.values()) { |
113 | 0 | if (aClass._externalName.equals(aName)) return aClass; |
114 | } | |
115 | } | |
116 | 0 | logger.log(Level.WARNING, "Could not find record class for name: " + name); |
117 | 0 | return CLASS_UNKNOWN; |
118 | } | |
119 | ||
120 | /** | |
121 | * @param index | |
122 | * @return class for name | |
123 | */ | |
124 | 1399 |
![]() |
125 | 1422 | int maskedIndex = index & CLASS_MASK; |
126 | 1413 | for (DNSRecordClass aClass : DNSRecordClass.values()) { |
127 | 1425 | if (aClass._index == maskedIndex) return aClass; |
128 | } | |
129 | 0 | logger.log(Level.WARNING, "Could not find record class for index: " + index); |
130 | 0 | return CLASS_UNKNOWN; |
131 | } | |
132 | ||
133 | 0 |
![]() |
134 | public String toString() { | |
135 | 0 | return this.name() + " index " + this.indexValue(); |
136 | } | |
137 | ||
138 | } |
|