1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package io.netty.handler.codec.dns;
17
18 import static io.netty.util.internal.ObjectUtil.checkNotNull;
19
20 import io.netty.util.internal.StringUtil;
21 import io.netty.util.internal.UnstableApi;
22
23 @UnstableApi
24 public class DefaultDnsPtrRecord extends AbstractDnsRecord implements DnsPtrRecord {
25
26 private final String hostname;
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44 public DefaultDnsPtrRecord(
45 String name, int dnsClass, long timeToLive, String hostname) {
46 super(name, DnsRecordType.PTR, dnsClass, timeToLive);
47 this.hostname = checkNotNull(hostname, "hostname");
48 }
49
50 @Override
51 public String hostname() {
52 return hostname;
53 }
54
55 @Override
56 public String toString() {
57 final StringBuilder buf = new StringBuilder(64).append(StringUtil.simpleClassName(this)).append('(');
58 final DnsRecordType type = type();
59 buf.append(name().isEmpty()? "<root>" : name())
60 .append(' ')
61 .append(timeToLive())
62 .append(' ');
63
64 DnsMessageUtil.appendRecordClass(buf, dnsClass())
65 .append(' ')
66 .append(type.name());
67
68 buf.append(' ')
69 .append(hostname);
70
71 return buf.toString();
72 }
73 }