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