1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package io.netty.handler.codec.memcache;
17
18 import io.netty.buffer.ByteBuf;
19 import io.netty.util.internal.ObjectUtil;
20 import io.netty.util.internal.StringUtil;
21 import io.netty.util.internal.UnstableApi;
22
23
24
25
26 @UnstableApi
27 public class DefaultMemcacheContent extends AbstractMemcacheObject implements MemcacheContent {
28
29 private final ByteBuf content;
30
31
32
33
34 public DefaultMemcacheContent(ByteBuf content) {
35 this.content = ObjectUtil.checkNotNull(content, "content");
36 }
37
38 @Override
39 public ByteBuf content() {
40 return content;
41 }
42
43 @Override
44 public MemcacheContent copy() {
45 return replace(content.copy());
46 }
47
48 @Override
49 public MemcacheContent duplicate() {
50 return replace(content.duplicate());
51 }
52
53 @Override
54 public MemcacheContent retainedDuplicate() {
55 return replace(content.retainedDuplicate());
56 }
57
58 @Override
59 public MemcacheContent replace(ByteBuf content) {
60 return new DefaultMemcacheContent(content);
61 }
62
63 @Override
64 public MemcacheContent retain() {
65 super.retain();
66 return this;
67 }
68
69 @Override
70 public MemcacheContent retain(int increment) {
71 super.retain(increment);
72 return this;
73 }
74
75 @Override
76 public MemcacheContent touch() {
77 super.touch();
78 return this;
79 }
80
81 @Override
82 public MemcacheContent touch(Object hint) {
83 content.touch(hint);
84 return this;
85 }
86
87 @Override
88 protected void deallocate() {
89 content.release();
90 }
91
92 @Override
93 public String toString() {
94 return StringUtil.simpleClassName(this) +
95 "(data: " + content() + ", decoderResult: " + decoderResult() + ')';
96 }
97 }