View Javadoc

1   /*
2    * Copyright (c) 2012 the original author or authors.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package org.eclipse.jetty.spdy.frames;
18  
19  import org.eclipse.jetty.spdy.api.Headers;
20  import org.eclipse.jetty.spdy.api.SynInfo;
21  
22  public class SynStreamFrame extends ControlFrame
23  {
24      private final int streamId;
25      private final int associatedStreamId;
26      private final byte priority;
27      private final Headers headers;
28  
29      public SynStreamFrame(short version, byte flags, int streamId, int associatedStreamId, byte priority, Headers headers)
30      {
31          super(version, ControlFrameType.SYN_STREAM, flags);
32          this.streamId = streamId;
33          this.associatedStreamId = associatedStreamId;
34          this.priority = priority;
35          this.headers = headers;
36      }
37  
38      public int getStreamId()
39      {
40          return streamId;
41      }
42  
43      public int getAssociatedStreamId()
44      {
45          return associatedStreamId;
46      }
47  
48      public byte getPriority()
49      {
50          return priority;
51      }
52  
53      public Headers getHeaders()
54      {
55          return headers;
56      }
57  
58      public boolean isClose()
59      {
60          return (getFlags() & SynInfo.FLAG_CLOSE) == SynInfo.FLAG_CLOSE;
61      }
62  
63      public boolean isUnidirectional()
64      {
65          return (getFlags() & SynInfo.FLAG_UNIDIRECTIONAL) == SynInfo.FLAG_UNIDIRECTIONAL;
66      }
67  
68      @Override
69      public String toString()
70      {
71          return String.format("%s stream=%d close=%b", super.toString(), getStreamId(), isClose());
72      }
73  }