1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.eclipse.jetty.websocket.common.frames;
20
21 import java.nio.ByteBuffer;
22
23 import org.eclipse.jetty.util.BufferUtil;
24 import org.eclipse.jetty.util.StringUtil;
25 import org.eclipse.jetty.websocket.common.OpCode;
26
27 public class TextFrame extends DataFrame
28 {
29 public TextFrame()
30 {
31 super(OpCode.TEXT);
32 }
33
34 @Override
35 public Type getType()
36 {
37 if (getOpCode() == OpCode.CONTINUATION)
38 return Type.CONTINUATION;
39 return Type.TEXT;
40 }
41
42 public TextFrame setPayload(String str)
43 {
44 setPayload(ByteBuffer.wrap(StringUtil.getUtf8Bytes(str)));
45 return this;
46 }
47
48 public String getPayloadAsUTF8()
49 {
50 if (data == null)
51 {
52 return null;
53 }
54 return BufferUtil.toUTF8String(data);
55 }
56 }