View Javadoc

1   //
2   //  ========================================================================
3   //  Copyright (c) 1995-2016 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.http2.frames;
20  
21  public class PriorityFrame extends Frame
22  {
23      public static final int PRIORITY_LENGTH = 5;
24  
25      private final int streamId;
26      private final int parentStreamId;
27      private final int weight;
28      private final boolean exclusive;
29  
30      public PriorityFrame(int parentStreamId, int weight, boolean exclusive)
31      {
32          this(0, parentStreamId, weight, exclusive);
33      }
34  
35      public PriorityFrame(int streamId, int parentStreamId, int weight, boolean exclusive)
36      {
37          super(FrameType.PRIORITY);
38          this.streamId = streamId;
39          this.parentStreamId = parentStreamId;
40          this.weight = weight;
41          this.exclusive = exclusive;
42      }
43  
44      public int getStreamId()
45      {
46          return streamId;
47      }
48  
49      /**
50       * @deprecated use {@link #getParentStreamId()} instead.
51       */
52      @Deprecated
53      public int getDependentStreamId()
54      {
55          return getParentStreamId();
56      }
57  
58      public int getParentStreamId()
59      {
60          return parentStreamId;
61      }
62  
63      public int getWeight()
64      {
65          return weight;
66      }
67  
68      public boolean isExclusive()
69      {
70          return exclusive;
71      }
72  
73      @Override
74      public String toString()
75      {
76          return String.format("%s#%d/#%d{weight=%d,exclusive=%b}", super.toString(), streamId, parentStreamId, weight, exclusive);
77      }
78  }