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
SkeletalByteBufAllocatorimplementation to extend.
-
-
Field Summary
-
Fields inherited from interface io.netty.buffer.ByteBufAllocator
DEFAULT
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractByteBufAllocator()Instance use heap buffers by defaultprotectedAbstractByteBufAllocator(boolean preferDirect)Create new instance
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description ByteBufbuffer()Allocate aByteBuf.ByteBufbuffer(int initialCapacity)Allocate aByteBufwith the given initial capacity.ByteBufbuffer(int initialCapacity, int maxCapacity)Allocate aByteBufwith the given initial capacity and the given maximal capacity.intcalculateNewCapacity(int minNewCapacity, int maxCapacity)CompositeByteBufcompositeBuffer()Allocate aCompositeByteBuf.CompositeByteBufcompositeBuffer(int maxNumComponents)Allocate aCompositeByteBufwith the given maximum number of components that can be stored in it.CompositeByteBufcompositeDirectBuffer()Allocate a directCompositeByteBuf.CompositeByteBufcompositeDirectBuffer(int maxNumComponents)Allocate a directCompositeByteBufwith the given maximum number of components that can be stored in it.CompositeByteBufcompositeHeapBuffer()Allocate a heapCompositeByteBuf.CompositeByteBufcompositeHeapBuffer(int maxNumComponents)Allocate a heapCompositeByteBufwith the given maximum number of components that can be stored in it.ByteBufdirectBuffer()Allocate a directByteBuf.ByteBufdirectBuffer(int initialCapacity)Allocate a directByteBufwith the given initial capacity.ByteBufdirectBuffer(int initialCapacity, int maxCapacity)Allocate a directByteBufwith the given initial capacity and the given maximal capacity.ByteBufheapBuffer()Allocate a heapByteBuf.ByteBufheapBuffer(int initialCapacity)Allocate a heapByteBufwith the given initial capacity.ByteBufheapBuffer(int initialCapacity, int maxCapacity)Allocate a heapByteBufwith the given initial capacity and the given maximal capacity.ByteBufioBuffer()Allocate aByteBuf, preferably a direct buffer which is suitable for I/O.ByteBufioBuffer(int initialCapacity)Allocate aByteBuf, preferably a direct buffer which is suitable for I/O.ByteBufioBuffer(int initialCapacity, int maxCapacity)Allocate aByteBuf, preferably a direct buffer which is suitable for I/O.protected abstract ByteBufnewDirectBuffer(int initialCapacity, int maxCapacity)Create a directByteBufwith the given initialCapacity and maxCapacity.protected abstract ByteBufnewHeapBuffer(int initialCapacity, int maxCapacity)Create a heapByteBufwith the given initialCapacity and maxCapacity.protected static ByteBuftoLeakAwareBuffer(ByteBuf buf)protected static CompositeByteBuftoLeakAwareBuffer(CompositeByteBuf buf)java.lang.StringtoString()-
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-trueifbuffer(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:ByteBufAllocatorAllocate aByteBuf. If it is a direct or heap buffer depends on the actual implementation.- Specified by:
bufferin interfaceByteBufAllocator
-
buffer
public ByteBuf buffer(int initialCapacity)
Description copied from interface:ByteBufAllocatorAllocate aByteBufwith the given initial capacity. If it is a direct or heap buffer depends on the actual implementation.- Specified by:
bufferin interfaceByteBufAllocator
-
buffer
public ByteBuf buffer(int initialCapacity, int maxCapacity)
Description copied from interface:ByteBufAllocatorAllocate aByteBufwith the given initial capacity and the given maximal capacity. If it is a direct or heap buffer depends on the actual implementation.- Specified by:
bufferin interfaceByteBufAllocator
-
ioBuffer
public ByteBuf ioBuffer()
Description copied from interface:ByteBufAllocatorAllocate aByteBuf, preferably a direct buffer which is suitable for I/O.- Specified by:
ioBufferin interfaceByteBufAllocator
-
ioBuffer
public ByteBuf ioBuffer(int initialCapacity)
Description copied from interface:ByteBufAllocatorAllocate aByteBuf, preferably a direct buffer which is suitable for I/O.- Specified by:
ioBufferin interfaceByteBufAllocator
-
ioBuffer
public ByteBuf ioBuffer(int initialCapacity, int maxCapacity)
Description copied from interface:ByteBufAllocatorAllocate aByteBuf, preferably a direct buffer which is suitable for I/O.- Specified by:
ioBufferin interfaceByteBufAllocator
-
heapBuffer
public ByteBuf heapBuffer()
Description copied from interface:ByteBufAllocatorAllocate a heapByteBuf.- Specified by:
heapBufferin interfaceByteBufAllocator
-
heapBuffer
public ByteBuf heapBuffer(int initialCapacity)
Description copied from interface:ByteBufAllocatorAllocate a heapByteBufwith the given initial capacity.- Specified by:
heapBufferin interfaceByteBufAllocator
-
heapBuffer
public ByteBuf heapBuffer(int initialCapacity, int maxCapacity)
Description copied from interface:ByteBufAllocatorAllocate a heapByteBufwith the given initial capacity and the given maximal capacity.- Specified by:
heapBufferin interfaceByteBufAllocator
-
directBuffer
public ByteBuf directBuffer()
Description copied from interface:ByteBufAllocatorAllocate a directByteBuf.- Specified by:
directBufferin interfaceByteBufAllocator
-
directBuffer
public ByteBuf directBuffer(int initialCapacity)
Description copied from interface:ByteBufAllocatorAllocate a directByteBufwith the given initial capacity.- Specified by:
directBufferin interfaceByteBufAllocator
-
directBuffer
public ByteBuf directBuffer(int initialCapacity, int maxCapacity)
Description copied from interface:ByteBufAllocatorAllocate a directByteBufwith the given initial capacity and the given maximal capacity.- Specified by:
directBufferin interfaceByteBufAllocator
-
compositeBuffer
public CompositeByteBuf compositeBuffer()
Description copied from interface:ByteBufAllocatorAllocate aCompositeByteBuf. If it is a direct or heap buffer depends on the actual implementation.- Specified by:
compositeBufferin interfaceByteBufAllocator
-
compositeBuffer
public CompositeByteBuf compositeBuffer(int maxNumComponents)
Description copied from interface:ByteBufAllocatorAllocate aCompositeByteBufwith 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:
compositeBufferin interfaceByteBufAllocator
-
compositeHeapBuffer
public CompositeByteBuf compositeHeapBuffer()
Description copied from interface:ByteBufAllocatorAllocate a heapCompositeByteBuf.- Specified by:
compositeHeapBufferin interfaceByteBufAllocator
-
compositeHeapBuffer
public CompositeByteBuf compositeHeapBuffer(int maxNumComponents)
Description copied from interface:ByteBufAllocatorAllocate a heapCompositeByteBufwith the given maximum number of components that can be stored in it.- Specified by:
compositeHeapBufferin interfaceByteBufAllocator
-
compositeDirectBuffer
public CompositeByteBuf compositeDirectBuffer()
Description copied from interface:ByteBufAllocatorAllocate a directCompositeByteBuf.- Specified by:
compositeDirectBufferin interfaceByteBufAllocator
-
compositeDirectBuffer
public CompositeByteBuf compositeDirectBuffer(int maxNumComponents)
Description copied from interface:ByteBufAllocatorAllocate a directCompositeByteBufwith the given maximum number of components that can be stored in it.- Specified by:
compositeDirectBufferin interfaceByteBufAllocator
-
newHeapBuffer
protected abstract ByteBuf newHeapBuffer(int initialCapacity, int maxCapacity)
Create a heapByteBufwith the given initialCapacity and maxCapacity.
-
newDirectBuffer
protected abstract ByteBuf newDirectBuffer(int initialCapacity, int maxCapacity)
Create a directByteBufwith the given initialCapacity and maxCapacity.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
calculateNewCapacity
public int calculateNewCapacity(int minNewCapacity, int maxCapacity)Description copied from interface:ByteBufAllocatorCalculate the new capacity of aByteBufthat is used when aByteBufneeds to expand by theminNewCapacitywithmaxCapacityas upper-bound.- Specified by:
calculateNewCapacityin interfaceByteBufAllocator
-
-