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