2013-02-10 05:10:09 +01:00
|
|
|
/*
|
|
|
|
* Copyright 2013 The Netty Project
|
|
|
|
*
|
|
|
|
* The Netty Project licenses this file to you under the Apache License,
|
|
|
|
* version 2.0 (the "License"); you may not use this file except in compliance
|
|
|
|
* with the License. You may obtain a copy of the License at:
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
* License for the specific language governing permissions and limitations
|
|
|
|
* under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
package io.netty.buffer;
|
|
|
|
|
2013-08-30 09:51:12 +02:00
|
|
|
import java.nio.ByteBuffer;
|
|
|
|
|
2013-02-17 20:12:48 +01:00
|
|
|
/**
|
|
|
|
* Abstract base class for {@link ByteBuf} implementations that wrap another
|
|
|
|
* {@link ByteBuf}.
|
|
|
|
*/
|
2013-02-10 05:10:09 +01:00
|
|
|
public abstract class AbstractDerivedByteBuf extends AbstractByteBuf {
|
|
|
|
|
|
|
|
protected AbstractDerivedByteBuf(int maxCapacity) {
|
|
|
|
super(maxCapacity);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public final int refCnt() {
|
|
|
|
return unwrap().refCnt();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2013-02-13 08:09:33 +01:00
|
|
|
public final ByteBuf retain() {
|
2013-03-14 08:37:20 +01:00
|
|
|
unwrap().retain();
|
2013-02-13 08:09:33 +01:00
|
|
|
return this;
|
|
|
|
}
|
2013-02-10 05:10:09 +01:00
|
|
|
|
|
|
|
@Override
|
2013-02-13 08:09:33 +01:00
|
|
|
public final ByteBuf retain(int increment) {
|
2013-03-14 08:37:20 +01:00
|
|
|
unwrap().retain(increment);
|
2013-02-13 08:09:33 +01:00
|
|
|
return this;
|
|
|
|
}
|
2013-02-10 05:10:09 +01:00
|
|
|
|
2014-01-28 12:00:28 +01:00
|
|
|
@Override
|
|
|
|
public final ByteBuf touch() {
|
|
|
|
unwrap().touch();
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2014-01-29 03:44:59 +01:00
|
|
|
@Override
|
|
|
|
public final ByteBuf touch(Object hint) {
|
|
|
|
unwrap().touch(hint);
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2013-02-10 05:10:09 +01:00
|
|
|
@Override
|
|
|
|
public final boolean release() {
|
2015-05-11 08:35:12 +02:00
|
|
|
if (unwrap().release()) {
|
|
|
|
deallocate();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
2013-02-10 05:10:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public final boolean release(int decrement) {
|
2015-05-11 08:35:12 +02:00
|
|
|
if (unwrap().release(decrement)) {
|
|
|
|
deallocate();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
2013-02-10 05:10:09 +01:00
|
|
|
}
|
2013-08-30 09:51:12 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public ByteBuffer internalNioBuffer(int index, int length) {
|
|
|
|
return nioBuffer(index, length);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public ByteBuffer nioBuffer(int index, int length) {
|
|
|
|
return unwrap().nioBuffer(index, length);
|
|
|
|
}
|
2015-05-11 08:35:12 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Called when the wrapped {@link ByteBuf} was released due calling of {@link #release()} or {@link #release(int)}.
|
|
|
|
*/
|
|
|
|
protected void deallocate() { }
|
2013-02-10 05:10:09 +01:00
|
|
|
}
|