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.memcache.binary;
17  
18  import io.netty.buffer.ByteBuf;
19  
20  /**
21   * The default implementation of the {@link BinaryMemcacheRequest}.
22   */
23  public class DefaultBinaryMemcacheRequest extends AbstractBinaryMemcacheMessage implements BinaryMemcacheRequest {
24  
25      /**
26       * Default magic byte for a request.
27       */
28      public static final byte REQUEST_MAGIC_BYTE = (byte) 0x80;
29  
30      private short reserved;
31  
32      /**
33       * Create a new {@link DefaultBinaryMemcacheRequest} with the header only.
34       */
35      public DefaultBinaryMemcacheRequest() {
36          this(null, null);
37      }
38  
39      /**
40       * Create a new {@link DefaultBinaryMemcacheRequest} with the header and key.
41       *
42       * @param key    the key to use.
43       */
44      public DefaultBinaryMemcacheRequest(String key) {
45          this(key, null);
46      }
47  
48      /**
49       * Create a new {@link DefaultBinaryMemcacheRequest} with the header and extras.
50       *
51       * @param extras the extras to use.
52       */
53      public DefaultBinaryMemcacheRequest(ByteBuf extras) {
54          this(null, extras);
55      }
56  
57      /**
58       * Create a new {@link DefaultBinaryMemcacheRequest} with the header only.
59       *
60       * @param key    the key to use.
61       * @param extras the extras to use.
62       */
63      public DefaultBinaryMemcacheRequest(String key, ByteBuf extras) {
64          super(key, extras);
65          setMagic(REQUEST_MAGIC_BYTE);
66      }
67  
68      @Override
69      public short reserved() {
70          return reserved;
71      }
72  
73      @Override
74      public BinaryMemcacheRequest setReserved(short reserved) {
75          this.reserved = reserved;
76          return this;
77      }
78  
79      @Override
80      public BinaryMemcacheRequest retain() {
81          super.retain();
82          return this;
83      }
84  
85      @Override
86      public BinaryMemcacheRequest retain(int increment) {
87          super.retain(increment);
88          return this;
89      }
90  
91      @Override
92      public BinaryMemcacheRequest touch() {
93          super.touch();
94          return this;
95      }
96  
97      @Override
98      public BinaryMemcacheRequest touch(Object hint) {
99          super.touch(hint);
100         return this;
101     }
102 }