1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package io.netty.channel;
17
18 import io.netty.buffer.ByteBuf;
19 import io.netty.buffer.ByteBufAllocator;
20 import io.netty.buffer.CompositeByteBuf;
21 import io.netty.util.internal.ObjectUtil;
22 import io.netty.util.internal.UnstableApi;
23
24
25
26
27
28 @UnstableApi
29 public final class PreferHeapByteBufAllocator implements ByteBufAllocator {
30 private final ByteBufAllocator allocator;
31
32 public PreferHeapByteBufAllocator(ByteBufAllocator allocator) {
33 this.allocator = ObjectUtil.checkNotNull(allocator, "allocator");
34 }
35
36 @Override
37 public ByteBuf buffer() {
38 return allocator.heapBuffer();
39 }
40
41 @Override
42 public ByteBuf buffer(int initialCapacity) {
43 return allocator.heapBuffer(initialCapacity);
44 }
45
46 @Override
47 public ByteBuf buffer(int initialCapacity, int maxCapacity) {
48 return allocator.heapBuffer(initialCapacity, maxCapacity);
49 }
50
51 @Override
52 public ByteBuf ioBuffer() {
53 return allocator.heapBuffer();
54 }
55
56 @Override
57 public ByteBuf ioBuffer(int initialCapacity) {
58 return allocator.heapBuffer(initialCapacity);
59 }
60
61 @Override
62 public ByteBuf ioBuffer(int initialCapacity, int maxCapacity) {
63 return allocator.heapBuffer(initialCapacity, maxCapacity);
64 }
65
66 @Override
67 public ByteBuf heapBuffer() {
68 return allocator.heapBuffer();
69 }
70
71 @Override
72 public ByteBuf heapBuffer(int initialCapacity) {
73 return allocator.heapBuffer(initialCapacity);
74 }
75
76 @Override
77 public ByteBuf heapBuffer(int initialCapacity, int maxCapacity) {
78 return allocator.heapBuffer(initialCapacity, maxCapacity);
79 }
80
81 @Override
82 public ByteBuf directBuffer() {
83 return allocator.directBuffer();
84 }
85
86 @Override
87 public ByteBuf directBuffer(int initialCapacity) {
88 return allocator.directBuffer(initialCapacity);
89 }
90
91 @Override
92 public ByteBuf directBuffer(int initialCapacity, int maxCapacity) {
93 return allocator.directBuffer(initialCapacity, maxCapacity);
94 }
95
96 @Override
97 public CompositeByteBuf compositeBuffer() {
98 return allocator.compositeHeapBuffer();
99 }
100
101 @Override
102 public CompositeByteBuf compositeBuffer(int maxNumComponents) {
103 return allocator.compositeHeapBuffer(maxNumComponents);
104 }
105
106 @Override
107 public CompositeByteBuf compositeHeapBuffer() {
108 return allocator.compositeHeapBuffer();
109 }
110
111 @Override
112 public CompositeByteBuf compositeHeapBuffer(int maxNumComponents) {
113 return allocator.compositeHeapBuffer(maxNumComponents);
114 }
115
116 @Override
117 public CompositeByteBuf compositeDirectBuffer() {
118 return allocator.compositeDirectBuffer();
119 }
120
121 @Override
122 public CompositeByteBuf compositeDirectBuffer(int maxNumComponents) {
123 return allocator.compositeDirectBuffer(maxNumComponents);
124 }
125
126 @Override
127 public boolean isDirectBufferPooled() {
128 return allocator.isDirectBufferPooled();
129 }
130
131 @Override
132 public int calculateNewCapacity(int minNewCapacity, int maxCapacity) {
133 return allocator.calculateNewCapacity(minNewCapacity, maxCapacity);
134 }
135 }