View Javadoc
1   /*
2    * Copyright 2013 The Netty Project
3    *
4    * The Netty Project licenses this file to you under the Apache License,
5    * version 2.0 (the "License"); you may not use this file except in compliance
6    * with the License. You may obtain a copy of the License at:
7    *
8    *   http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13   * License for the specific language governing permissions and limitations
14   * under the License.
15   */
16  package io.netty.handler.codec.dns;
17  
18  import java.net.InetSocketAddress;
19  
20  /**
21   * A DNS query packet which is sent to a server to receive a DNS response packet
22   * with information answering a DnsQuery's questions.
23   */
24  public class DnsQuery extends DnsMessage {
25  
26      private final InetSocketAddress recipient;
27  
28      /**
29       * Constructs a DNS query. By default recursion will be toggled on.
30       */
31      public DnsQuery(int id, InetSocketAddress recipient) {
32          super(id);
33          if (recipient == null) {
34              throw new NullPointerException("recipient");
35          }
36          this.recipient = recipient;
37      }
38  
39      /**
40       * Return the {@link InetSocketAddress} of the recipient of the {@link DnsQuery}
41       */
42      public InetSocketAddress recipient() {
43          return recipient;
44      }
45  
46      @Override
47      public DnsQuery addAnswer(DnsResource answer) {
48          super.addAnswer(answer);
49          return this;
50      }
51  
52      @Override
53      public DnsQuery addQuestion(DnsQuestion question) {
54          super.addQuestion(question);
55          return this;
56      }
57  
58      @Override
59      public DnsQuery addAuthorityResource(DnsResource resource) {
60          super.addAuthorityResource(resource);
61          return this;
62      }
63  
64      @Override
65      public DnsQuery addAdditionalResource(DnsResource resource) {
66          super.addAdditionalResource(resource);
67          return this;
68      }
69  
70      @Override
71      public DnsQuery touch(Object hint) {
72          super.touch(hint);
73          return this;
74      }
75  
76      @Override
77      public DnsQuery retain() {
78          super.retain();
79          return this;
80      }
81  
82      @Override
83      public DnsQuery retain(int increment) {
84          super.retain(increment);
85          return this;
86      }
87  
88      @Override
89      public DnsQuery touch() {
90          super.touch();
91          return this;
92      }
93  
94      @Override
95      public DnsQueryHeader header() {
96          return (DnsQueryHeader) super.header();
97      }
98  
99      @Override
100     protected DnsQueryHeader newHeader(int id) {
101         return new DnsQueryHeader(this, id);
102     }
103 }