1
2
3
4 package javax.jmdns.impl.constants;
5
6 import java.util.logging.Logger;
7
8
9
10
11
12
13 public enum DNSRecordType {
14
15
16
17 TYPE_IGNORE("ignore", 0),
18
19
20
21 TYPE_A("a", 1),
22
23
24
25 TYPE_NS("ns", 2),
26
27
28
29 TYPE_MD("md", 3),
30
31
32
33 TYPE_MF("mf", 4),
34
35
36
37 TYPE_CNAME("cname", 5),
38
39
40
41 TYPE_SOA("soa", 6),
42
43
44
45 TYPE_MB("mb", 7),
46
47
48
49 TYPE_MG("mg", 8),
50
51
52
53 TYPE_MR("mr", 9),
54
55
56
57 TYPE_NULL("null", 10),
58
59
60
61 TYPE_WKS("wks", 11),
62
63
64
65 TYPE_PTR("ptr", 12),
66
67
68
69 TYPE_HINFO("hinfo", 13),
70
71
72
73 TYPE_MINFO("minfo", 14),
74
75
76
77 TYPE_MX("mx", 15),
78
79
80
81 TYPE_TXT("txt", 16),
82
83
84
85 TYPE_RP("rp", 17),
86
87
88
89 TYPE_AFSDB("afsdb", 18),
90
91
92
93 TYPE_X25("x25", 19),
94
95
96
97 TYPE_ISDN("isdn", 20),
98
99
100
101 TYPE_RT("rt", 21),
102
103
104
105 TYPE_NSAP("nsap", 22),
106
107
108
109 TYPE_NSAP_PTR("nsap-otr", 23),
110
111
112
113 TYPE_SIG("sig", 24),
114
115
116
117 TYPE_KEY("key", 25),
118
119
120
121 TYPE_PX("px", 26),
122
123
124
125 TYPE_GPOS("gpos", 27),
126
127
128
129 TYPE_AAAA("aaaa", 28),
130
131
132
133 TYPE_LOC("loc", 29),
134
135
136
137 TYPE_NXT("nxt", 30),
138
139
140
141 TYPE_EID("eid", 31),
142
143
144
145 TYPE_NIMLOC("nimloc", 32),
146
147
148
149 TYPE_SRV("srv", 33),
150
151
152
153 TYPE_ATMA("atma", 34),
154
155
156
157 TYPE_NAPTR("naptr", 35),
158
159
160
161 TYPE_KX("kx", 36),
162
163
164
165 TYPE_CERT("cert", 37),
166
167
168
169 TYPE_A6("a6", 38),
170
171
172
173 TYPE_DNAME("dname", 39),
174
175
176
177 TYPE_SINK("sink", 40),
178
179
180
181 TYPE_OPT("opt", 41),
182
183
184
185 TYPE_APL("apl", 42),
186
187
188
189 TYPE_DS("ds", 43),
190
191
192
193 TYPE_SSHFP("sshfp", 44),
194
195
196
197 TYPE_RRSIG("rrsig", 46),
198
199
200
201 TYPE_NSEC("nsec", 47),
202
203
204
205 TYPE_DNSKEY("dnskey", 48),
206
207
208
209 TYPE_UINFO("uinfo", 100),
210
211
212
213 TYPE_UID("uid", 101),
214
215
216
217 TYPE_GID("gid", 102),
218
219
220
221 TYPE_UNSPEC("unspec", 103),
222
223
224
225 TYPE_TKEY("tkey", 249),
226
227
228
229 TYPE_TSIG("tsig", 250),
230
231
232
233 TYPE_IXFR("ixfr", 251),
234
235
236
237 TYPE_AXFR("axfr", 252),
238
239
240
241 TYPE_MAILA("mails", 253),
242
243
244
245 TYPE_MAILB("mailb", 254),
246
247
248
249 TYPE_ANY("any", 255);
250
251 private static Logger logger = Logger.getLogger(DNSRecordType.class.getName());
252
253 private final String _externalName;
254
255 private final int _index;
256
257 DNSRecordType(String name, int index) {
258 _externalName = name;
259 _index = index;
260 }
261
262
263
264
265
266
267 public String externalName() {
268 return _externalName;
269 }
270
271
272
273
274
275
276 public int indexValue() {
277 return _index;
278 }
279
280
281
282
283
284 public static DNSRecordType typeForName(String name) {
285 if (name != null) {
286 String aName = name.toLowerCase();
287 for (DNSRecordType aType : DNSRecordType.values()) {
288 if (aType._externalName.equals(aName)) return aType;
289 }
290 }
291 logger.severe("Could not find record type for name: " + name);
292 return TYPE_IGNORE;
293 }
294
295
296
297
298
299 public static DNSRecordType typeForIndex(int index) {
300 for (DNSRecordType aType : DNSRecordType.values()) {
301 if (aType._index == index) return aType;
302 }
303 logger.severe("Could not find record type for index: " + index);
304 return TYPE_IGNORE;
305 }
306
307 @Override
308 public String toString() {
309 return this.name() + " index " + this.indexValue();
310 }
311
312 }