View Javadoc
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 io.netty.util.internal.StringUtil;
19  
20  /**
21   * The default {@link SpdySynReplyFrame} implementation.
22   */
23  public class DefaultSpdySynReplyFrame extends DefaultSpdyHeadersFrame implements SpdySynReplyFrame {
24  
25      /**
26       * Creates a new instance.
27       *
28       * @param streamId the Stream-ID of this frame
29       */
30      public DefaultSpdySynReplyFrame(int streamId) {
31          super(streamId);
32      }
33  
34      /**
35       * Creates a new instance.
36       *
37       * @param streamId        the Stream-ID of this frame
38       * @param validateHeaders validate the header names and values when adding them to the {@link SpdyHeaders}
39       */
40      public DefaultSpdySynReplyFrame(int streamId, boolean validateHeaders) {
41          super(streamId, validateHeaders);
42      }
43  
44      @Override
45      public SpdySynReplyFrame setStreamId(int streamId) {
46          super.setStreamId(streamId);
47          return this;
48      }
49  
50      @Override
51      public SpdySynReplyFrame setLast(boolean last) {
52          super.setLast(last);
53          return this;
54      }
55  
56      @Override
57      public SpdySynReplyFrame setInvalid() {
58          super.setInvalid();
59          return this;
60      }
61  
62      @Override
63      public String toString() {
64          StringBuilder buf = new StringBuilder()
65              .append(StringUtil.simpleClassName(this))
66              .append("(last: ")
67              .append(isLast())
68              .append(')')
69              .append(StringUtil.NEWLINE)
70              .append("--> Stream-ID = ")
71              .append(streamId())
72              .append(StringUtil.NEWLINE)
73              .append("--> Headers:")
74              .append(StringUtil.NEWLINE);
75          appendHeaders(buf);
76  
77          // Remove the last newline.
78          buf.setLength(buf.length() - StringUtil.NEWLINE.length());
79          return buf.toString();
80      }
81  }