查看本类的 API文档回源码主页即时通讯网 - 即时通讯开发者社区!
1   /*
2    * Copyright 2013 The Netty Project
3    *
4    * The Netty Project licenses this file to you under the Apache License,
5    * version 2.0 (the "License"); you may not use this file except in compliance
6    * with the License. You may obtain a copy of the License at:
7    *
8    *   https://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, WITHOUT
12   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13   * License for the specific language governing permissions and limitations
14   * under the License.
15   */
16  package io.netty.handler.codec.spdy;
17  
18  import static io.netty.util.internal.ObjectUtil.checkPositive;
19  import static io.netty.util.internal.ObjectUtil.checkPositiveOrZero;
20  
21  import io.netty.util.internal.StringUtil;
22  
23  /**
24   * The default {@link SpdyWindowUpdateFrame} implementation.
25   */
26  public class DefaultSpdyWindowUpdateFrame implements SpdyWindowUpdateFrame {
27  
28      private int streamId;
29      private int deltaWindowSize;
30  
31      /**
32       * Creates a new instance.
33       *
34       * @param streamId        the Stream-ID of this frame
35       * @param deltaWindowSize the Delta-Window-Size of this frame
36       */
37      public DefaultSpdyWindowUpdateFrame(int streamId, int deltaWindowSize) {
38          setStreamId(streamId);
39          setDeltaWindowSize(deltaWindowSize);
40      }
41  
42      @Override
43      public int streamId() {
44          return streamId;
45      }
46  
47      @Override
48      public SpdyWindowUpdateFrame setStreamId(int streamId) {
49          checkPositiveOrZero(streamId, "streamId");
50          this.streamId = streamId;
51          return this;
52      }
53  
54      @Override
55      public int deltaWindowSize() {
56          return deltaWindowSize;
57      }
58  
59      @Override
60      public SpdyWindowUpdateFrame setDeltaWindowSize(int deltaWindowSize) {
61          checkPositive(deltaWindowSize, "deltaWindowSize");
62          this.deltaWindowSize = deltaWindowSize;
63          return this;
64      }
65  
66      @Override
67      public String toString() {
68          return new StringBuilder()
69              .append(StringUtil.simpleClassName(this))
70              .append(StringUtil.NEWLINE)
71              .append("--> Stream-ID = ")
72              .append(streamId())
73              .append(StringUtil.NEWLINE)
74              .append("--> Delta-Window-Size = ")
75              .append(deltaWindowSize())
76              .toString();
77      }
78  }