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