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 @Override
72 public String toString()
73 {
74 return this.name();
75 }
76 }
77
78 public byte[] getMask();
79
80 public byte getOpCode();
81
82 public ByteBuffer getPayload();
83
84 public int getPayloadLength();
85
86 public int getPayloadStart();
87
88 public Type getType();
89
90 public boolean hasPayload();
91
92 public boolean isContinuation();
93
94 public boolean isFin();
95
96
97
98
99
100
101 public boolean isLast();
102
103 public boolean isMasked();
104
105 public boolean isRsv1();
106
107 public boolean isRsv2();
108
109 public boolean isRsv3();
110
111 public int remaining();
112 }