Package io.netty.buffer
Class AbstractByteBufAllocator
- java.lang.Object
-
- io.netty.buffer.AbstractByteBufAllocator
-
- All Implemented Interfaces:
ByteBufAllocator
- Direct Known Subclasses:
AdaptiveByteBufAllocator
,PooledByteBufAllocator
,UnpooledByteBufAllocator
public abstract class AbstractByteBufAllocator extends java.lang.Object implements ByteBufAllocator
SkeletalByteBufAllocator
implementation to extend.
-
-
Field Summary
-
Fields inherited from interface io.netty.buffer.ByteBufAllocator
DEFAULT
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractByteBufAllocator()
Instance use heap buffers by defaultprotected
AbstractByteBufAllocator(boolean preferDirect)
Create new instance
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description ByteBuf
buffer()
Allocate aByteBuf
.ByteBuf
buffer(int initialCapacity)
Allocate aByteBuf
with the given initial capacity.ByteBuf
buffer(int initialCapacity, int maxCapacity)
Allocate aByteBuf
with the given initial capacity and the given maximal capacity.int
calculateNewCapacity(int minNewCapacity, int maxCapacity)
CompositeByteBuf
compositeBuffer()
Allocate aCompositeByteBuf
.CompositeByteBuf
compositeBuffer(int maxNumComponents)
Allocate aCompositeByteBuf
with the given maximum number of components that can be stored in it.CompositeByteBuf
compositeDirectBuffer()
Allocate a directCompositeByteBuf
.CompositeByteBuf
compositeDirectBuffer(int maxNumComponents)
Allocate a directCompositeByteBuf
with the given maximum number of components that can be stored in it.CompositeByteBuf
compositeHeapBuffer()
Allocate a heapCompositeByteBuf
.CompositeByteBuf
compositeHeapBuffer(int maxNumComponents)
Allocate a heapCompositeByteBuf
with the given maximum number of components that can be stored in it.ByteBuf
directBuffer()
Allocate a directByteBuf
.ByteBuf
directBuffer(int initialCapacity)
Allocate a directByteBuf
with the given initial capacity.ByteBuf
directBuffer(int initialCapacity, int maxCapacity)
Allocate a directByteBuf
with the given initial capacity and the given maximal capacity.ByteBuf
heapBuffer()
Allocate a heapByteBuf
.ByteBuf
heapBuffer(int initialCapacity)
Allocate a heapByteBuf
with the given initial capacity.ByteBuf
heapBuffer(int initialCapacity, int maxCapacity)
Allocate a heapByteBuf
with the given initial capacity and the given maximal capacity.ByteBuf
ioBuffer()
Allocate aByteBuf
, preferably a direct buffer which is suitable for I/O.ByteBuf
ioBuffer(int initialCapacity)
Allocate aByteBuf
, preferably a direct buffer which is suitable for I/O.ByteBuf
ioBuffer(int initialCapacity, int maxCapacity)
Allocate aByteBuf
, preferably a direct buffer which is suitable for I/O.protected abstract ByteBuf
newDirectBuffer(int initialCapacity, int maxCapacity)
Create a directByteBuf
with the given initialCapacity and maxCapacity.protected abstract ByteBuf
newHeapBuffer(int initialCapacity, int maxCapacity)
Create a heapByteBuf
with the given initialCapacity and maxCapacity.protected static ByteBuf
toLeakAwareBuffer(ByteBuf buf)
protected static CompositeByteBuf
toLeakAwareBuffer(CompositeByteBuf buf)
java.lang.String
toString()
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface io.netty.buffer.ByteBufAllocator
isDirectBufferPooled
-
-
-
-
Constructor Detail
-
AbstractByteBufAllocator
protected AbstractByteBufAllocator()
Instance use heap buffers by default
-
AbstractByteBufAllocator
protected AbstractByteBufAllocator(boolean preferDirect)
Create new instance- Parameters:
preferDirect
-true
ifbuffer(int)
should try to allocate a direct buffer rather than a heap buffer
-
-
Method Detail
-
toLeakAwareBuffer
protected static CompositeByteBuf toLeakAwareBuffer(CompositeByteBuf buf)
-
buffer
public ByteBuf buffer()
Description copied from interface:ByteBufAllocator
Allocate aByteBuf
. If it is a direct or heap buffer depends on the actual implementation.- Specified by:
buffer
in interfaceByteBufAllocator
-
buffer
public ByteBuf buffer(int initialCapacity)
Description copied from interface:ByteBufAllocator
Allocate aByteBuf
with the given initial capacity. If it is a direct or heap buffer depends on the actual implementation.- Specified by:
buffer
in interfaceByteBufAllocator
-
buffer
public ByteBuf buffer(int initialCapacity, int maxCapacity)
Description copied from interface:ByteBufAllocator
Allocate aByteBuf
with the given initial capacity and the given maximal capacity. If it is a direct or heap buffer depends on the actual implementation.- Specified by:
buffer
in interfaceByteBufAllocator
-
ioBuffer
public ByteBuf ioBuffer()
Description copied from interface:ByteBufAllocator
Allocate aByteBuf
, preferably a direct buffer which is suitable for I/O.- Specified by:
ioBuffer
in interfaceByteBufAllocator
-
ioBuffer
public ByteBuf ioBuffer(int initialCapacity)
Description copied from interface:ByteBufAllocator
Allocate aByteBuf
, preferably a direct buffer which is suitable for I/O.- Specified by:
ioBuffer
in interfaceByteBufAllocator
-
ioBuffer
public ByteBuf ioBuffer(int initialCapacity, int maxCapacity)
Description copied from interface:ByteBufAllocator
Allocate aByteBuf
, preferably a direct buffer which is suitable for I/O.- Specified by:
ioBuffer
in interfaceByteBufAllocator
-
heapBuffer
public ByteBuf heapBuffer()
Description copied from interface:ByteBufAllocator
Allocate a heapByteBuf
.- Specified by:
heapBuffer
in interfaceByteBufAllocator
-
heapBuffer
public ByteBuf heapBuffer(int initialCapacity)
Description copied from interface:ByteBufAllocator
Allocate a heapByteBuf
with the given initial capacity.- Specified by:
heapBuffer
in interfaceByteBufAllocator
-
heapBuffer
public ByteBuf heapBuffer(int initialCapacity, int maxCapacity)
Description copied from interface:ByteBufAllocator
Allocate a heapByteBuf
with the given initial capacity and the given maximal capacity.- Specified by:
heapBuffer
in interfaceByteBufAllocator
-
directBuffer
public ByteBuf directBuffer()
Description copied from interface:ByteBufAllocator
Allocate a directByteBuf
.- Specified by:
directBuffer
in interfaceByteBufAllocator
-
directBuffer
public ByteBuf directBuffer(int initialCapacity)
Description copied from interface:ByteBufAllocator
Allocate a directByteBuf
with the given initial capacity.- Specified by:
directBuffer
in interfaceByteBufAllocator
-
directBuffer
public ByteBuf directBuffer(int initialCapacity, int maxCapacity)
Description copied from interface:ByteBufAllocator
Allocate a directByteBuf
with the given initial capacity and the given maximal capacity.- Specified by:
directBuffer
in interfaceByteBufAllocator
-
compositeBuffer
public CompositeByteBuf compositeBuffer()
Description copied from interface:ByteBufAllocator
Allocate aCompositeByteBuf
. If it is a direct or heap buffer depends on the actual implementation.- Specified by:
compositeBuffer
in interfaceByteBufAllocator
-
compositeBuffer
public CompositeByteBuf compositeBuffer(int maxNumComponents)
Description copied from interface:ByteBufAllocator
Allocate aCompositeByteBuf
with the given maximum number of components that can be stored in it. If it is a direct or heap buffer depends on the actual implementation.- Specified by:
compositeBuffer
in interfaceByteBufAllocator
-
compositeHeapBuffer
public CompositeByteBuf compositeHeapBuffer()
Description copied from interface:ByteBufAllocator
Allocate a heapCompositeByteBuf
.- Specified by:
compositeHeapBuffer
in interfaceByteBufAllocator
-
compositeHeapBuffer
public CompositeByteBuf compositeHeapBuffer(int maxNumComponents)
Description copied from interface:ByteBufAllocator
Allocate a heapCompositeByteBuf
with the given maximum number of components that can be stored in it.- Specified by:
compositeHeapBuffer
in interfaceByteBufAllocator
-
compositeDirectBuffer
public CompositeByteBuf compositeDirectBuffer()
Description copied from interface:ByteBufAllocator
Allocate a directCompositeByteBuf
.- Specified by:
compositeDirectBuffer
in interfaceByteBufAllocator
-
compositeDirectBuffer
public CompositeByteBuf compositeDirectBuffer(int maxNumComponents)
Description copied from interface:ByteBufAllocator
Allocate a directCompositeByteBuf
with the given maximum number of components that can be stored in it.- Specified by:
compositeDirectBuffer
in interfaceByteBufAllocator
-
newHeapBuffer
protected abstract ByteBuf newHeapBuffer(int initialCapacity, int maxCapacity)
Create a heapByteBuf
with the given initialCapacity and maxCapacity.
-
newDirectBuffer
protected abstract ByteBuf newDirectBuffer(int initialCapacity, int maxCapacity)
Create a directByteBuf
with the given initialCapacity and maxCapacity.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
calculateNewCapacity
public int calculateNewCapacity(int minNewCapacity, int maxCapacity)
Description copied from interface:ByteBufAllocator
Calculate the new capacity of aByteBuf
that is used when aByteBuf
needs to expand by theminNewCapacity
withmaxCapacity
as upper-bound.- Specified by:
calculateNewCapacity
in interfaceByteBufAllocator
-
-