1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package io.netty.handler.codec.http.websocketx;
17
18 import io.netty.buffer.ByteBuf;
19 import io.netty.buffer.Unpooled;
20 import io.netty.util.CharsetUtil;
21
22
23
24
25
26 public class ContinuationWebSocketFrame extends WebSocketFrame {
27
28
29
30
31 public ContinuationWebSocketFrame() {
32 this(Unpooled.buffer(0));
33 }
34
35
36
37
38
39
40
41 public ContinuationWebSocketFrame(ByteBuf binaryData) {
42 super(binaryData);
43 }
44
45
46
47
48
49
50
51
52
53
54
55 public ContinuationWebSocketFrame(boolean finalFragment, int rsv, ByteBuf binaryData) {
56 super(finalFragment, rsv, binaryData);
57 }
58
59
60
61
62
63
64
65
66
67
68
69 public ContinuationWebSocketFrame(boolean finalFragment, int rsv, String text) {
70 this(finalFragment, rsv, fromText(text));
71 }
72
73
74
75
76 public String text() {
77 return content().toString(CharsetUtil.UTF_8);
78 }
79
80
81
82
83
84
85
86 private static ByteBuf fromText(String text) {
87 if (text == null || text.isEmpty()) {
88 return Unpooled.EMPTY_BUFFER;
89 } else {
90 return Unpooled.copiedBuffer(text, CharsetUtil.UTF_8);
91 }
92 }
93
94 @Override
95 public ContinuationWebSocketFrame copy() {
96 return new ContinuationWebSocketFrame(isFinalFragment(), rsv(), content().copy());
97 }
98
99 @Override
100 public ContinuationWebSocketFrame duplicate() {
101 return new ContinuationWebSocketFrame(isFinalFragment(), rsv(), content().duplicate());
102 }
103
104 @Override
105 public ContinuationWebSocketFrame retain() {
106 super.retain();
107 return this;
108 }
109
110 @Override
111 public ContinuationWebSocketFrame retain(int increment) {
112 super.retain(increment);
113 return this;
114 }
115 }