1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.jboss.netty.handler.codec.spdy;
17
18 import org.jboss.netty.util.internal.StringUtil;
19
20
21
22
23 public class DefaultSpdySynStreamFrame extends DefaultSpdyHeadersFrame
24 implements SpdySynStreamFrame {
25
26 private int associatedToStreamId;
27 private byte priority;
28 private boolean unidirectional;
29
30
31
32
33
34
35
36
37 public DefaultSpdySynStreamFrame(
38 int streamId, int associatedToStreamId, byte priority) {
39 super(streamId);
40 setAssociatedToStreamId(associatedToStreamId);
41 setPriority(priority);
42 }
43
44 public int getAssociatedToStreamId() {
45 return associatedToStreamId;
46 }
47
48 public void setAssociatedToStreamId(int associatedToStreamId) {
49 if (associatedToStreamId < 0) {
50 throw new IllegalArgumentException(
51 "Associated-To-Stream-ID cannot be negative: " +
52 associatedToStreamId);
53 }
54 this.associatedToStreamId = associatedToStreamId;
55 }
56
57 public byte getPriority() {
58 return priority;
59 }
60
61 public void setPriority(byte priority) {
62 if (priority < 0 || priority > 7) {
63 throw new IllegalArgumentException(
64 "Priority must be between 0 and 7 inclusive: " + priority);
65 }
66 this.priority = priority;
67 }
68
69 public boolean isUnidirectional() {
70 return unidirectional;
71 }
72
73 public void setUnidirectional(boolean unidirectional) {
74 this.unidirectional = unidirectional;
75 }
76
77 @Override
78 public String toString() {
79 StringBuilder buf = new StringBuilder();
80 buf.append(getClass().getSimpleName());
81 buf.append("(last: ");
82 buf.append(isLast());
83 buf.append("; unidirectional: ");
84 buf.append(isUnidirectional());
85 buf.append(')');
86 buf.append(StringUtil.NEWLINE);
87 buf.append("--> Stream-ID = ");
88 buf.append(getStreamId());
89 buf.append(StringUtil.NEWLINE);
90 if (associatedToStreamId != 0) {
91 buf.append("--> Associated-To-Stream-ID = ");
92 buf.append(getAssociatedToStreamId());
93 buf.append(StringUtil.NEWLINE);
94 }
95 buf.append("--> Priority = ");
96 buf.append(getPriority());
97 buf.append(StringUtil.NEWLINE);
98 buf.append("--> Headers:");
99 buf.append(StringUtil.NEWLINE);
100 appendHeaders(buf);
101
102
103 buf.setLength(buf.length() - StringUtil.NEWLINE.length());
104 return buf.toString();
105 }
106 }