UnpooledHeapByteBuf Class — netty Architecture
Architecture documentation for the UnpooledHeapByteBuf class in UnpooledHeapByteBuf.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD d1903687_2aa7_726c_eff7_eab963e923d3["UnpooledHeapByteBuf"] 6f95da9c_94e3_0cf9_07ca_cc38615a7cfe["UnpooledHeapByteBuf.java"] d1903687_2aa7_726c_eff7_eab963e923d3 -->|defined in| 6f95da9c_94e3_0cf9_07ca_cc38615a7cfe e7c26b1a_3e25_b6d5_b579_a2e8ad5287c9["UnpooledHeapByteBuf()"] d1903687_2aa7_726c_eff7_eab963e923d3 -->|method| e7c26b1a_3e25_b6d5_b579_a2e8ad5287c9 664232a9_6132_df1b_71a6_19e8b1ecf2a1["allocateArray()"] d1903687_2aa7_726c_eff7_eab963e923d3 -->|method| 664232a9_6132_df1b_71a6_19e8b1ecf2a1 06fdb113_7ad2_9bd7_137b_966ce0496401["freeArray()"] d1903687_2aa7_726c_eff7_eab963e923d3 -->|method| 06fdb113_7ad2_9bd7_137b_966ce0496401 7448da7b_08e0_502b_718e_75f2b3b3c664["setArray()"] d1903687_2aa7_726c_eff7_eab963e923d3 -->|method| 7448da7b_08e0_502b_718e_75f2b3b3c664 09f19376_8304_2047_7e0e_3e9740a19b39["ByteBufAllocator()"] d1903687_2aa7_726c_eff7_eab963e923d3 -->|method| 09f19376_8304_2047_7e0e_3e9740a19b39 0ea220da_9278_a924_13cf_49f49ec9a37b["ByteOrder()"] d1903687_2aa7_726c_eff7_eab963e923d3 -->|method| 0ea220da_9278_a924_13cf_49f49ec9a37b 7cb05490_33cb_d394_6a3e_37d3a066beb6["isDirect()"] d1903687_2aa7_726c_eff7_eab963e923d3 -->|method| 7cb05490_33cb_d394_6a3e_37d3a066beb6 9126059b_3996_d1e1_8466_b68e0b96ee3f["capacity()"] d1903687_2aa7_726c_eff7_eab963e923d3 -->|method| 9126059b_3996_d1e1_8466_b68e0b96ee3f 1dcd2e68_11cf_6e6a_a36f_7242aaa8ba02["ByteBuf()"] d1903687_2aa7_726c_eff7_eab963e923d3 -->|method| 1dcd2e68_11cf_6e6a_a36f_7242aaa8ba02 b3b9d221_40c5_7f1f_f985_16a1aed24ccb["hasArray()"] d1903687_2aa7_726c_eff7_eab963e923d3 -->|method| b3b9d221_40c5_7f1f_f985_16a1aed24ccb 179ec81f_cf93_7816_089f_002b14918f7f["array()"] d1903687_2aa7_726c_eff7_eab963e923d3 -->|method| 179ec81f_cf93_7816_089f_002b14918f7f 87fbfde6_0ff5_8437_a967_63d4e7935ac9["arrayOffset()"] d1903687_2aa7_726c_eff7_eab963e923d3 -->|method| 87fbfde6_0ff5_8437_a967_63d4e7935ac9 236fa00d_50fc_a7f3_0401_2d7f3cd3b210["hasMemoryAddress()"] d1903687_2aa7_726c_eff7_eab963e923d3 -->|method| 236fa00d_50fc_a7f3_0401_2d7f3cd3b210
Relationship Graph
Source Code
buffer/src/main/java/io/netty/buffer/UnpooledHeapByteBuf.java lines 38–557
public class UnpooledHeapByteBuf extends AbstractReferenceCountedByteBuf {
private final ByteBufAllocator alloc;
byte[] array;
private ByteBuffer tmpNioBuf;
/**
* Creates a new heap buffer with a newly allocated byte array.
*
* @param initialCapacity the initial capacity of the underlying byte array
* @param maxCapacity the max capacity of the underlying byte array
*/
public UnpooledHeapByteBuf(ByteBufAllocator alloc, int initialCapacity, int maxCapacity) {
super(maxCapacity);
if (initialCapacity > maxCapacity) {
throw new IllegalArgumentException(String.format(
"initialCapacity(%d) > maxCapacity(%d)", initialCapacity, maxCapacity));
}
this.alloc = checkNotNull(alloc, "alloc");
setArray(allocateArray(initialCapacity));
setIndex(0, 0);
}
/**
* Creates a new heap buffer with an existing byte array.
*
* @param initialArray the initial underlying byte array
* @param maxCapacity the max capacity of the underlying byte array
*/
protected UnpooledHeapByteBuf(ByteBufAllocator alloc, byte[] initialArray, int maxCapacity) {
super(maxCapacity);
checkNotNull(alloc, "alloc");
checkNotNull(initialArray, "initialArray");
if (initialArray.length > maxCapacity) {
throw new IllegalArgumentException(String.format(
"initialCapacity(%d) > maxCapacity(%d)", initialArray.length, maxCapacity));
}
this.alloc = alloc;
setArray(initialArray);
setIndex(0, initialArray.length);
}
protected byte[] allocateArray(int initialCapacity) {
return new byte[initialCapacity];
}
protected void freeArray(byte[] array) {
// NOOP
}
private void setArray(byte[] initialArray) {
array = initialArray;
tmpNioBuf = null;
}
@Override
public ByteBufAllocator alloc() {
return alloc;
}
@Override
public ByteOrder order() {
return ByteOrder.BIG_ENDIAN;
}
@Override
public boolean isDirect() {
return false;
}
@Override
public int capacity() {
return array.length;
}
@Override
public ByteBuf capacity(int newCapacity) {
Source
Frequently Asked Questions
What is the UnpooledHeapByteBuf class?
UnpooledHeapByteBuf is a class in the netty codebase, defined in buffer/src/main/java/io/netty/buffer/UnpooledHeapByteBuf.java.
Where is UnpooledHeapByteBuf defined?
UnpooledHeapByteBuf is defined in buffer/src/main/java/io/netty/buffer/UnpooledHeapByteBuf.java at line 38.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free