View Javadoc
1   /*
2    * Copyright 2014 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    *   http://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.stomp;
17  
18  import io.netty.handler.codec.DecoderResult;
19  
20  /**
21   * Default implementation of {@link StompHeadersSubframe}.
22   */
23  public class DefaultStompHeadersSubframe implements StompHeadersSubframe {
24  
25      protected final StompCommand command;
26      protected DecoderResult decoderResult = DecoderResult.SUCCESS;
27      protected final DefaultStompHeaders headers;
28  
29      public DefaultStompHeadersSubframe(StompCommand command) {
30          this(command, null);
31      }
32  
33      DefaultStompHeadersSubframe(StompCommand command, DefaultStompHeaders headers) {
34          if (command == null) {
35              throw new NullPointerException("command");
36          }
37  
38          this.command = command;
39          this.headers = headers == null ? new DefaultStompHeaders() : headers;
40      }
41  
42      @Override
43      public StompCommand command() {
44          return command;
45      }
46  
47      @Override
48      public StompHeaders headers() {
49          return headers;
50      }
51  
52      @Override
53      public DecoderResult decoderResult() {
54          return decoderResult;
55      }
56  
57      @Override
58      public void setDecoderResult(DecoderResult decoderResult) {
59          this.decoderResult = decoderResult;
60      }
61  
62      @Override
63      public String toString() {
64          return "StompFrame{" +
65              "command=" + command +
66              ", headers=" + headers +
67              '}';
68      }
69  }