View Javadoc

1   //
2   //  ========================================================================
3   //  Copyright (c) 1995-2013 Mort Bay Consulting Pty. Ltd.
4   //  ------------------------------------------------------------------------
5   //  All rights reserved. This program and the accompanying materials
6   //  are made available under the terms of the Eclipse Public License v1.0
7   //  and Apache License v2.0 which accompanies this distribution.
8   //
9   //      The Eclipse Public License is available at
10  //      http://www.eclipse.org/legal/epl-v10.html
11  //
12  //      The Apache License v2.0 is available at
13  //      http://www.opensource.org/licenses/apache2.0.php
14  //
15  //  You may elect to redistribute this code under either of these licenses.
16  //  ========================================================================
17  //
18  
19  package org.eclipse.jetty.spdy.frames;
20  
21  import org.eclipse.jetty.spdy.PushSynInfo;
22  import org.eclipse.jetty.spdy.api.SynInfo;
23  import org.eclipse.jetty.util.Fields;
24  
25  public class SynStreamFrame extends ControlFrame
26  {
27      private final int streamId;
28      private final int associatedStreamId;
29      private final byte priority;
30      private final short slot;
31      private final Fields headers;
32  
33      public SynStreamFrame(short version, byte flags, int streamId, int associatedStreamId, byte priority, short slot, Fields headers)
34      {
35          super(version, ControlFrameType.SYN_STREAM, flags);
36          this.streamId = streamId;
37          this.associatedStreamId = associatedStreamId;
38          this.priority = priority;
39          this.slot = slot;
40          this.headers = headers;
41      }
42  
43      public int getStreamId()
44      {
45          return streamId;
46      }
47  
48      public int getAssociatedStreamId()
49      {
50          return associatedStreamId;
51      }
52  
53      public byte getPriority()
54      {
55          return priority;
56      }
57  
58      public short getSlot()
59      {
60          return slot;
61      }
62  
63      public Fields getHeaders()
64      {
65          return headers;
66      }
67  
68      public boolean isClose()
69      {
70          return (getFlags() & SynInfo.FLAG_CLOSE) == SynInfo.FLAG_CLOSE;
71      }
72  
73      public boolean isUnidirectional()
74      {
75          return (getFlags() & PushSynInfo.FLAG_UNIDIRECTIONAL) == PushSynInfo.FLAG_UNIDIRECTIONAL;
76      }
77  
78      @Override
79      public String toString()
80      {
81          return String.format("%s stream=%d close=%b", super.toString(), getStreamId(), isClose());
82      }
83  }