1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.eclipse.jetty.websocket.api.extensions;
20
21 import java.nio.ByteBuffer;
22
23
24
25
26 public interface Frame
27 {
28 public static enum Type
29 {
30 CONTINUATION((byte)0x00),
31 TEXT((byte)0x01),
32 BINARY((byte)0x02),
33 CLOSE((byte)0x08),
34 PING((byte)0x09),
35 PONG((byte)0x0A);
36
37 public static Type from(byte op)
38 {
39 for (Type type : values())
40 {
41 if (type.opcode == op)
42 {
43 return type;
44 }
45 }
46 throw new IllegalArgumentException("OpCode " + op + " is not a valid Frame.Type");
47 }
48
49 private byte opcode;
50
51 private Type(byte code)
52 {
53 this.opcode = code;
54 }
55
56 public byte getOpCode()
57 {
58 return opcode;
59 }
60
61 public boolean isControl()
62 {
63 return (opcode >= CLOSE.getOpCode());
64 }
65
66 public boolean isData()
67 {
68 return (opcode == TEXT.getOpCode()) | (opcode == BINARY.getOpCode());
69 }
70
71 public boolean isContinuation()
72 {
73 return opcode == CONTINUATION.getOpCode();
74 }
75
76 @Override
77 public String toString()
78 {
79 return this.name();
80 }
81 }
82
83 public byte[] getMask();
84
85 public byte getOpCode();
86
87 public ByteBuffer getPayload();
88
89
90
91
92
93
94 public int getPayloadLength();
95
96 public Type getType();
97
98 public boolean hasPayload();
99
100 public boolean isFin();
101
102
103
104
105
106
107
108 @Deprecated
109 public boolean isLast();
110
111 public boolean isMasked();
112
113 public boolean isRsv1();
114
115 public boolean isRsv2();
116
117 public boolean isRsv3();
118
119 }