1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package io.netty.handler.codec.memcache.binary;
17
18 import io.netty.buffer.ByteBuf;
19 import io.netty.buffer.Unpooled;
20 import io.netty.util.internal.UnstableApi;
21
22
23
24
25 @UnstableApi
26 public class BinaryMemcacheRequestDecoder
27 extends AbstractBinaryMemcacheDecoder<BinaryMemcacheRequest> {
28
29 public BinaryMemcacheRequestDecoder() {
30 this(DEFAULT_MAX_CHUNK_SIZE);
31 }
32
33 public BinaryMemcacheRequestDecoder(int chunkSize) {
34 super(chunkSize);
35 }
36
37 @Override
38 protected BinaryMemcacheRequest decodeHeader(ByteBuf in) {
39 DefaultBinaryMemcacheRequest header = new DefaultBinaryMemcacheRequest();
40 header.setMagic(in.readByte());
41 header.setOpcode(in.readByte());
42 header.setKeyLength(in.readShort());
43 header.setExtrasLength(in.readByte());
44 header.setDataType(in.readByte());
45 header.setReserved(in.readShort());
46 header.setTotalBodyLength(in.readInt());
47 header.setOpaque(in.readInt());
48 header.setCas(in.readLong());
49 return header;
50 }
51
52 @Override
53 protected BinaryMemcacheRequest buildInvalidMessage() {
54 return new DefaultBinaryMemcacheRequest(Unpooled.EMPTY_BUFFER, Unpooled.EMPTY_BUFFER);
55 }
56 }