1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.eclipse.jetty.spdy.generator;
20
21 import java.nio.ByteBuffer;
22
23 import org.eclipse.jetty.io.ByteBufferPool;
24 import org.eclipse.jetty.spdy.frames.ControlFrame;
25
26 public abstract class ControlFrameGenerator
27 {
28 private final ByteBufferPool bufferPool;
29
30 protected ControlFrameGenerator(ByteBufferPool bufferPool)
31 {
32 this.bufferPool = bufferPool;
33 }
34
35 protected ByteBufferPool getByteBufferPool()
36 {
37 return bufferPool;
38 }
39
40 public abstract ByteBuffer generate(ControlFrame frame);
41
42 protected void generateControlFrameHeader(ControlFrame frame, int frameLength, ByteBuffer buffer)
43 {
44 buffer.putShort((short)(0x8000 + frame.getVersion()));
45 buffer.putShort(frame.getType().getCode());
46 int flagsAndLength = frame.getFlags();
47 flagsAndLength <<= 24;
48 flagsAndLength += frameLength;
49 buffer.putInt(flagsAndLength);
50 }
51 }