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 DefaultSpdyHeaderBlock
24 implements SpdySynStreamFrame {
25
26 private int streamId;
27 private int associatedToStreamId;
28 private byte priority;
29 private boolean last;
30 private boolean unidirectional;
31
32
33
34
35
36
37
38
39 public DefaultSpdySynStreamFrame(
40 int streamID, int associatedToStreamId, byte priority) {
41 setStreamId(streamID);
42 setAssociatedToStreamId(associatedToStreamId);
43 setPriority(priority);
44 }
45
46 @Deprecated
47 public int getStreamID() {
48 return getStreamId();
49 }
50
51 public int getStreamId() {
52 return streamId;
53 }
54
55 @Deprecated
56 public void setStreamID(int streamId) {
57 setStreamId(streamId);
58 }
59
60 public void setStreamId(int streamId) {
61 if (streamId <= 0) {
62 throw new IllegalArgumentException(
63 "Stream-ID must be positive: " + streamId);
64 }
65 this.streamId = streamId;
66 }
67
68 @Deprecated
69 public int getAssociatedToStreamID() {
70 return getAssociatedToStreamId();
71 }
72
73 public int getAssociatedToStreamId() {
74 return associatedToStreamId;
75 }
76
77 @Deprecated
78 public void setAssociatedToStreamID(int associatedToStreamId) {
79 setAssociatedToStreamId(associatedToStreamId);
80 }
81
82 public void setAssociatedToStreamId(int associatedToStreamId) {
83 if (associatedToStreamId < 0) {
84 throw new IllegalArgumentException(
85 "Associated-To-Stream-ID cannot be negative: " +
86 associatedToStreamId);
87 }
88 this.associatedToStreamId = associatedToStreamId;
89 }
90
91 public byte getPriority() {
92 return priority;
93 }
94
95 public void setPriority(byte priority) {
96 if (priority < 0 || priority > 7) {
97 throw new IllegalArgumentException(
98 "Priority must be between 0 and 7 inclusive: " + priority);
99 }
100 this.priority = priority;
101 }
102
103 public boolean isLast() {
104 return last;
105 }
106
107 public void setLast(boolean last) {
108 this.last = last;
109 }
110
111 public boolean isUnidirectional() {
112 return unidirectional;
113 }
114
115 public void setUnidirectional(boolean unidirectional) {
116 this.unidirectional = unidirectional;
117 }
118
119 @Override
120 public String toString() {
121 StringBuilder buf = new StringBuilder();
122 buf.append(getClass().getSimpleName());
123 buf.append("(last: ");
124 buf.append(isLast());
125 buf.append("; unidirectional: ");
126 buf.append(isUnidirectional());
127 buf.append(')');
128 buf.append(StringUtil.NEWLINE);
129 buf.append("--> Stream-ID = ");
130 buf.append(streamId);
131 buf.append(StringUtil.NEWLINE);
132 if (associatedToStreamId != 0) {
133 buf.append("--> Associated-To-Stream-ID = ");
134 buf.append(associatedToStreamId);
135 buf.append(StringUtil.NEWLINE);
136 }
137 buf.append("--> Priority = ");
138 buf.append(priority);
139 buf.append(StringUtil.NEWLINE);
140 buf.append("--> Headers:");
141 buf.append(StringUtil.NEWLINE);
142 appendHeaders(buf);
143
144
145 buf.setLength(buf.length() - StringUtil.NEWLINE.length());
146 return buf.toString();
147 }
148 }