View Javadoc
1   /*
2    * Copyright 2014 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  
17  package io.netty.handler.codec.mqtt;
18  
19  import io.netty.util.internal.StringUtil;
20  
21  /**
22   * See <a href="http://public.dhe.ibm.com/software/dw/webservices/ws-mqtt/mqtt-v3r1.html#fixed-header">
23   *     MQTTV3.1/fixed-header</a>
24   */
25  public class MqttFixedHeader {
26  
27      private final MqttMessageType messageType;
28      private final boolean isDup;
29      private final MqttQoS qosLevel;
30      private final boolean isRetain;
31      private final int remainingLength;
32  
33      public MqttFixedHeader(
34              MqttMessageType messageType,
35              boolean isDup,
36              MqttQoS qosLevel,
37              boolean isRetain,
38              int remainingLength) {
39          this.messageType = messageType;
40          this.isDup = isDup;
41          this.qosLevel = qosLevel;
42          this.isRetain = isRetain;
43          this.remainingLength = remainingLength;
44      }
45  
46      public MqttMessageType messageType() {
47          return messageType;
48      }
49  
50      public boolean isDup() {
51          return isDup;
52      }
53  
54      public MqttQoS qosLevel() {
55          return qosLevel;
56      }
57  
58      public boolean isRetain() {
59          return isRetain;
60      }
61  
62      public int remainingLength() {
63          return remainingLength;
64      }
65  
66      @Override
67      public String toString() {
68          return new StringBuilder(StringUtil.simpleClassName(this))
69              .append('[')
70              .append("messageType=").append(messageType)
71              .append(", isDup=").append(isDup)
72              .append(", qosLevel=").append(qosLevel)
73              .append(", isRetain=").append(isRetain)
74              .append(", remainingLength=").append(remainingLength)
75              .append(']')
76              .toString();
77      }
78  }