View Javadoc

1   //========================================================================
2   //Copyright 2011-2012 Mort Bay Consulting Pty. Ltd.
3   //------------------------------------------------------------------------
4   //All rights reserved. This program and the accompanying materials
5   //are made available under the terms of the Eclipse Public License v1.0
6   //and Apache License v2.0 which accompanies this distribution.
7   //The Eclipse Public License is available at
8   //http://www.eclipse.org/legal/epl-v10.html
9   //The Apache License v2.0 is available at
10  //http://www.opensource.org/licenses/apache2.0.php
11  //You may elect to redistribute this code under either of these licenses.
12  //========================================================================
13  
14  package org.eclipse.jetty.spdy.frames;
15  
16  import org.eclipse.jetty.spdy.api.DataInfo;
17  
18  public class DataFrame
19  {
20      public static final int HEADER_LENGTH = 8;
21  
22      private final int streamId;
23      private final byte flags;
24      private final int length;
25  
26      public DataFrame(int streamId, byte flags, int length)
27      {
28          this.streamId = streamId;
29          this.flags = flags;
30          this.length = length;
31      }
32  
33      public int getStreamId()
34      {
35          return streamId;
36      }
37  
38      public byte getFlags()
39      {
40          return flags;
41      }
42  
43      public int getLength()
44      {
45          return length;
46      }
47  
48      public boolean isClose()
49      {
50          return (flags & DataInfo.FLAG_CLOSE) == DataInfo.FLAG_CLOSE;
51      }
52  
53      public boolean isCompress()
54      {
55          return (flags & DataInfo.FLAG_COMPRESS) == DataInfo.FLAG_COMPRESS;
56      }
57  
58      @Override
59      public String toString()
60      {
61          return String.format("DATA frame stream=%d length=%d close=%b compress=%b", getStreamId(), getLength(), isClose(), isCompress());
62      }
63  }