1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package io.netty.buffer;
17
18 import java.io.IOException;
19 import java.io.InputStream;
20 import java.io.OutputStream;
21 import java.nio.ByteBuffer;
22 import java.nio.ByteOrder;
23 import java.nio.channels.GatheringByteChannel;
24 import java.nio.channels.ScatteringByteChannel;
25
26
27
28
29
30
31
32
33 @Deprecated
34 public class DuplicatedByteBuf extends AbstractDerivedByteBuf {
35
36 private final ByteBuf buffer;
37
38 public DuplicatedByteBuf(ByteBuf buffer) {
39 super(buffer.maxCapacity());
40
41 if (buffer instanceof DuplicatedByteBuf) {
42 this.buffer = ((DuplicatedByteBuf) buffer).buffer;
43 } else {
44 this.buffer = buffer;
45 }
46
47 setIndex(buffer.readerIndex(), buffer.writerIndex());
48 markReaderIndex();
49 markWriterIndex();
50 }
51
52 @Override
53 public ByteBuf unwrap() {
54 return buffer;
55 }
56
57 @Override
58 public ByteBufAllocator alloc() {
59 return unwrap().alloc();
60 }
61
62 @Override
63 @Deprecated
64 public ByteOrder order() {
65 return unwrap().order();
66 }
67
68 @Override
69 public boolean isDirect() {
70 return unwrap().isDirect();
71 }
72
73 @Override
74 public int capacity() {
75 return unwrap().capacity();
76 }
77
78 @Override
79 public ByteBuf capacity(int newCapacity) {
80 unwrap().capacity(newCapacity);
81 return this;
82 }
83
84 @Override
85 public boolean hasArray() {
86 return unwrap().hasArray();
87 }
88
89 @Override
90 public byte[] array() {
91 return unwrap().array();
92 }
93
94 @Override
95 public int arrayOffset() {
96 return unwrap().arrayOffset();
97 }
98
99 @Override
100 public boolean hasMemoryAddress() {
101 return unwrap().hasMemoryAddress();
102 }
103
104 @Override
105 public long memoryAddress() {
106 return unwrap().memoryAddress();
107 }
108
109 @Override
110 public byte getByte(int index) {
111 return unwrap().getByte(index);
112 }
113
114 @Override
115 protected byte _getByte(int index) {
116 return unwrap().getByte(index);
117 }
118
119 @Override
120 public short getShort(int index) {
121 return unwrap().getShort(index);
122 }
123
124 @Override
125 protected short _getShort(int index) {
126 return unwrap().getShort(index);
127 }
128
129 @Override
130 public int getUnsignedMedium(int index) {
131 return unwrap().getUnsignedMedium(index);
132 }
133
134 @Override
135 protected int _getUnsignedMedium(int index) {
136 return unwrap().getUnsignedMedium(index);
137 }
138
139 @Override
140 public int getInt(int index) {
141 return unwrap().getInt(index);
142 }
143
144 @Override
145 protected int _getInt(int index) {
146 return unwrap().getInt(index);
147 }
148
149 @Override
150 public long getLong(int index) {
151 return unwrap().getLong(index);
152 }
153
154 @Override
155 protected long _getLong(int index) {
156 return unwrap().getLong(index);
157 }
158
159 @Override
160 public ByteBuf copy(int index, int length) {
161 return unwrap().copy(index, length);
162 }
163
164 @Override
165 public ByteBuf slice(int index, int length) {
166 return unwrap().slice(index, length);
167 }
168
169 @Override
170 public ByteBuf getBytes(int index, ByteBuf dst, int dstIndex, int length) {
171 unwrap().getBytes(index, dst, dstIndex, length);
172 return this;
173 }
174
175 @Override
176 public ByteBuf getBytes(int index, byte[] dst, int dstIndex, int length) {
177 unwrap().getBytes(index, dst, dstIndex, length);
178 return this;
179 }
180
181 @Override
182 public ByteBuf getBytes(int index, ByteBuffer dst) {
183 unwrap().getBytes(index, dst);
184 return this;
185 }
186
187 @Override
188 public ByteBuf setByte(int index, int value) {
189 unwrap().setByte(index, value);
190 return this;
191 }
192
193 @Override
194 protected void _setByte(int index, int value) {
195 unwrap().setByte(index, value);
196 }
197
198 @Override
199 public ByteBuf setShort(int index, int value) {
200 unwrap().setShort(index, value);
201 return this;
202 }
203
204 @Override
205 protected void _setShort(int index, int value) {
206 unwrap().setShort(index, value);
207 }
208
209 @Override
210 public ByteBuf setMedium(int index, int value) {
211 unwrap().setMedium(index, value);
212 return this;
213 }
214
215 @Override
216 protected void _setMedium(int index, int value) {
217 unwrap().setMedium(index, value);
218 }
219
220 @Override
221 public ByteBuf setInt(int index, int value) {
222 unwrap().setInt(index, value);
223 return this;
224 }
225
226 @Override
227 protected void _setInt(int index, int value) {
228 unwrap().setInt(index, value);
229 }
230
231 @Override
232 public ByteBuf setLong(int index, long value) {
233 unwrap().setLong(index, value);
234 return this;
235 }
236
237 @Override
238 protected void _setLong(int index, long value) {
239 unwrap().setLong(index, value);
240 }
241
242 @Override
243 public ByteBuf setBytes(int index, byte[] src, int srcIndex, int length) {
244 unwrap().setBytes(index, src, srcIndex, length);
245 return this;
246 }
247
248 @Override
249 public ByteBuf setBytes(int index, ByteBuf src, int srcIndex, int length) {
250 unwrap().setBytes(index, src, srcIndex, length);
251 return this;
252 }
253
254 @Override
255 public ByteBuf setBytes(int index, ByteBuffer src) {
256 unwrap().setBytes(index, src);
257 return this;
258 }
259
260 @Override
261 public ByteBuf getBytes(int index, OutputStream out, int length)
262 throws IOException {
263 unwrap().getBytes(index, out, length);
264 return this;
265 }
266
267 @Override
268 public int getBytes(int index, GatheringByteChannel out, int length)
269 throws IOException {
270 return unwrap().getBytes(index, out, length);
271 }
272
273 @Override
274 public int setBytes(int index, InputStream in, int length)
275 throws IOException {
276 return unwrap().setBytes(index, in, length);
277 }
278
279 @Override
280 public int setBytes(int index, ScatteringByteChannel in, int length)
281 throws IOException {
282 return unwrap().setBytes(index, in, length);
283 }
284
285 @Override
286 public int nioBufferCount() {
287 return unwrap().nioBufferCount();
288 }
289
290 @Override
291 public ByteBuffer[] nioBuffers(int index, int length) {
292 return unwrap().nioBuffers(index, length);
293 }
294
295 @Override
296 public int forEachByte(int index, int length, ByteBufProcessor processor) {
297 return unwrap().forEachByte(index, length, processor);
298 }
299
300 @Override
301 public int forEachByteDesc(int index, int length, ByteBufProcessor processor) {
302 return unwrap().forEachByteDesc(index, length, processor);
303 }
304 }
305