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
22 public class DefaultDnsPtrRecord extends AbstractDnsRecord implements DnsPtrRecord {
23
24 private final String hostname;
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42 public DefaultDnsPtrRecord(
43 String name, int dnsClass, long timeToLive, String hostname) {
44 super(name, DnsRecordType.PTR, dnsClass, timeToLive);
45 this.hostname = checkNotNull(hostname, "hostname");
46 }
47
48 @Override
49 public String hostname() {
50 return hostname;
51 }
52
53 @Override
54 public String toString() {
55 final StringBuilder buf = new StringBuilder(64).append(StringUtil.simpleClassName(this)).append('(');
56 final DnsRecordType type = type();
57 buf.append(name().isEmpty()? "<root>" : name())
58 .append(' ')
59 .append(timeToLive())
60 .append(' ');
61
62 DnsMessageUtil.appendRecordClass(buf, dnsClass())
63 .append(' ')
64 .append(type.name());
65
66 buf.append(' ')
67 .append(hostname);
68
69 return buf.toString();
70 }
71 }