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  
19  import io.netty.buffer.ByteBuf;
20  import io.netty.handler.codec.DecoderResult;
21  
22  /**
23   * The default {@link StompContentSubframe} implementation.
24   */
25  public class DefaultStompContentSubframe implements StompContentSubframe {
26      private DecoderResult decoderResult = DecoderResult.SUCCESS;
27      private final ByteBuf content;
28  
29      public DefaultStompContentSubframe(ByteBuf content) {
30          if (content == null) {
31              throw new NullPointerException("content");
32          }
33          this.content = content;
34      }
35  
36      @Override
37      public ByteBuf content() {
38          return content;
39      }
40  
41      @Override
42      public StompContentSubframe copy() {
43          return new DefaultStompContentSubframe(content().copy());
44      }
45  
46      @Override
47      public StompContentSubframe duplicate() {
48          return new DefaultStompContentSubframe(content().duplicate());
49      }
50  
51      @Override
52      public int refCnt() {
53          return content().refCnt();
54      }
55  
56      @Override
57      public StompContentSubframe retain() {
58          content().retain();
59          return this;
60      }
61  
62      @Override
63      public StompContentSubframe retain(int increment) {
64          content().retain(increment);
65          return this;
66      }
67  
68      @Override
69      public StompContentSubframe touch() {
70          content.touch();
71          return this;
72      }
73  
74      @Override
75      public StompContentSubframe touch(Object hint) {
76          content.touch(hint);
77          return this;
78      }
79  
80      @Override
81      public boolean release() {
82          return content().release();
83      }
84  
85      @Override
86      public boolean release(int decrement) {
87          return content().release(decrement);
88      }
89  
90      @Override
91      public DecoderResult decoderResult() {
92          return decoderResult;
93      }
94  
95      @Override
96      public void setDecoderResult(DecoderResult decoderResult) {
97          this.decoderResult = decoderResult;
98      }
99  
100     @Override
101     public String toString() {
102         return "DefaultStompContent{" +
103             "decoderResult=" + decoderResult +
104             '}';
105     }
106 }