1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package io.netty.buffer;
17
18 import io.netty.util.ByteProcessor;
19
20 import java.io.IOException;
21 import java.io.InputStream;
22 import java.io.OutputStream;
23 import java.nio.ByteBuffer;
24 import java.nio.ByteOrder;
25 import java.nio.channels.FileChannel;
26 import java.nio.channels.GatheringByteChannel;
27 import java.nio.channels.ScatteringByteChannel;
28
29
30
31
32
33
34
35
36 @Deprecated
37 public class DuplicatedByteBuf extends AbstractDerivedByteBuf {
38
39 private final ByteBuf buffer;
40
41 public DuplicatedByteBuf(ByteBuf buffer) {
42 this(buffer, buffer.readerIndex(), buffer.writerIndex());
43 }
44
45 DuplicatedByteBuf(ByteBuf buffer, int readerIndex, int writerIndex) {
46 super(buffer.maxCapacity());
47
48 if (buffer instanceof DuplicatedByteBuf) {
49 this.buffer = ((DuplicatedByteBuf) buffer).buffer;
50 } else if (buffer instanceof AbstractPooledDerivedByteBuf) {
51 this.buffer = buffer.unwrap();
52 } else {
53 this.buffer = buffer;
54 }
55
56 setIndex(readerIndex, writerIndex);
57 markReaderIndex();
58 markWriterIndex();
59 }
60
61 @Override
62 public ByteBuf unwrap() {
63 return buffer;
64 }
65
66 @Override
67 public ByteBufAllocator alloc() {
68 return unwrap().alloc();
69 }
70
71 @Override
72 @Deprecated
73 public ByteOrder order() {
74 return unwrap().order();
75 }
76
77 @Override
78 public boolean isDirect() {
79 return unwrap().isDirect();
80 }
81
82 @Override
83 public int capacity() {
84 return unwrap().capacity();
85 }
86
87 @Override
88 public ByteBuf capacity(int newCapacity) {
89 unwrap().capacity(newCapacity);
90 return this;
91 }
92
93 @Override
94 public boolean hasArray() {
95 return unwrap().hasArray();
96 }
97
98 @Override
99 public byte[] array() {
100 return unwrap().array();
101 }
102
103 @Override
104 public int arrayOffset() {
105 return unwrap().arrayOffset();
106 }
107
108 @Override
109 public boolean hasMemoryAddress() {
110 return unwrap().hasMemoryAddress();
111 }
112
113 @Override
114 public long memoryAddress() {
115 return unwrap().memoryAddress();
116 }
117
118 @Override
119 public byte getByte(int index) {
120 return unwrap().getByte(index);
121 }
122
123 @Override
124 protected byte _getByte(int index) {
125 return unwrap().getByte(index);
126 }
127
128 @Override
129 public short getShort(int index) {
130 return unwrap().getShort(index);
131 }
132
133 @Override
134 protected short _getShort(int index) {
135 return unwrap().getShort(index);
136 }
137
138 @Override
139 public short getShortLE(int index) {
140 return unwrap().getShortLE(index);
141 }
142
143 @Override
144 protected short _getShortLE(int index) {
145 return unwrap().getShortLE(index);
146 }
147
148 @Override
149 public int getUnsignedMedium(int index) {
150 return unwrap().getUnsignedMedium(index);
151 }
152
153 @Override
154 protected int _getUnsignedMedium(int index) {
155 return unwrap().getUnsignedMedium(index);
156 }
157
158 @Override
159 public int getUnsignedMediumLE(int index) {
160 return unwrap().getUnsignedMediumLE(index);
161 }
162
163 @Override
164 protected int _getUnsignedMediumLE(int index) {
165 return unwrap().getUnsignedMediumLE(index);
166 }
167
168 @Override
169 public int getInt(int index) {
170 return unwrap().getInt(index);
171 }
172
173 @Override
174 protected int _getInt(int index) {
175 return unwrap().getInt(index);
176 }
177
178 @Override
179 public int getIntLE(int index) {
180 return unwrap().getIntLE(index);
181 }
182
183 @Override
184 protected int _getIntLE(int index) {
185 return unwrap().getIntLE(index);
186 }
187
188 @Override
189 public long getLong(int index) {
190 return unwrap().getLong(index);
191 }
192
193 @Override
194 protected long _getLong(int index) {
195 return unwrap().getLong(index);
196 }
197
198 @Override
199 public long getLongLE(int index) {
200 return unwrap().getLongLE(index);
201 }
202
203 @Override
204 protected long _getLongLE(int index) {
205 return unwrap().getLongLE(index);
206 }
207
208 @Override
209 public ByteBuf copy(int index, int length) {
210 return unwrap().copy(index, length);
211 }
212
213 @Override
214 public ByteBuf slice(int index, int length) {
215 return unwrap().slice(index, length);
216 }
217
218 @Override
219 public ByteBuf getBytes(int index, ByteBuf dst, int dstIndex, int length) {
220 unwrap().getBytes(index, dst, dstIndex, length);
221 return this;
222 }
223
224 @Override
225 public ByteBuf getBytes(int index, byte[] dst, int dstIndex, int length) {
226 unwrap().getBytes(index, dst, dstIndex, length);
227 return this;
228 }
229
230 @Override
231 public ByteBuf getBytes(int index, ByteBuffer dst) {
232 unwrap().getBytes(index, dst);
233 return this;
234 }
235
236 @Override
237 public ByteBuf setByte(int index, int value) {
238 unwrap().setByte(index, value);
239 return this;
240 }
241
242 @Override
243 protected void _setByte(int index, int value) {
244 unwrap().setByte(index, value);
245 }
246
247 @Override
248 public ByteBuf setShort(int index, int value) {
249 unwrap().setShort(index, value);
250 return this;
251 }
252
253 @Override
254 protected void _setShort(int index, int value) {
255 unwrap().setShort(index, value);
256 }
257
258 @Override
259 public ByteBuf setShortLE(int index, int value) {
260 unwrap().setShortLE(index, value);
261 return this;
262 }
263
264 @Override
265 protected void _setShortLE(int index, int value) {
266 unwrap().setShortLE(index, value);
267 }
268
269 @Override
270 public ByteBuf setMedium(int index, int value) {
271 unwrap().setMedium(index, value);
272 return this;
273 }
274
275 @Override
276 protected void _setMedium(int index, int value) {
277 unwrap().setMedium(index, value);
278 }
279
280 @Override
281 public ByteBuf setMediumLE(int index, int value) {
282 unwrap().setMediumLE(index, value);
283 return this;
284 }
285
286 @Override
287 protected void _setMediumLE(int index, int value) {
288 unwrap().setMediumLE(index, value);
289 }
290
291 @Override
292 public ByteBuf setInt(int index, int value) {
293 unwrap().setInt(index, value);
294 return this;
295 }
296
297 @Override
298 protected void _setInt(int index, int value) {
299 unwrap().setInt(index, value);
300 }
301
302 @Override
303 public ByteBuf setIntLE(int index, int value) {
304 unwrap().setIntLE(index, value);
305 return this;
306 }
307
308 @Override
309 protected void _setIntLE(int index, int value) {
310 unwrap().setIntLE(index, value);
311 }
312
313 @Override
314 public ByteBuf setLong(int index, long value) {
315 unwrap().setLong(index, value);
316 return this;
317 }
318
319 @Override
320 protected void _setLong(int index, long value) {
321 unwrap().setLong(index, value);
322 }
323
324 @Override
325 public ByteBuf setLongLE(int index, long value) {
326 unwrap().setLongLE(index, value);
327 return this;
328 }
329
330 @Override
331 protected void _setLongLE(int index, long value) {
332 unwrap().setLongLE(index, value);
333 }
334
335 @Override
336 public ByteBuf setBytes(int index, byte[] src, int srcIndex, int length) {
337 unwrap().setBytes(index, src, srcIndex, length);
338 return this;
339 }
340
341 @Override
342 public ByteBuf setBytes(int index, ByteBuf src, int srcIndex, int length) {
343 unwrap().setBytes(index, src, srcIndex, length);
344 return this;
345 }
346
347 @Override
348 public ByteBuf setBytes(int index, ByteBuffer src) {
349 unwrap().setBytes(index, src);
350 return this;
351 }
352
353 @Override
354 public ByteBuf getBytes(int index, OutputStream out, int length)
355 throws IOException {
356 unwrap().getBytes(index, out, length);
357 return this;
358 }
359
360 @Override
361 public int getBytes(int index, GatheringByteChannel out, int length)
362 throws IOException {
363 return unwrap().getBytes(index, out, length);
364 }
365
366 @Override
367 public int getBytes(int index, FileChannel out, long position, int length)
368 throws IOException {
369 return unwrap().getBytes(index, out, position, length);
370 }
371
372 @Override
373 public int setBytes(int index, InputStream in, int length)
374 throws IOException {
375 return unwrap().setBytes(index, in, length);
376 }
377
378 @Override
379 public int setBytes(int index, ScatteringByteChannel in, int length)
380 throws IOException {
381 return unwrap().setBytes(index, in, length);
382 }
383
384 @Override
385 public int setBytes(int index, FileChannel in, long position, int length)
386 throws IOException {
387 return unwrap().setBytes(index, in, position, length);
388 }
389
390 @Override
391 public int nioBufferCount() {
392 return unwrap().nioBufferCount();
393 }
394
395 @Override
396 public ByteBuffer[] nioBuffers(int index, int length) {
397 return unwrap().nioBuffers(index, length);
398 }
399
400 @Override
401 public int forEachByte(int index, int length, ByteProcessor processor) {
402 return unwrap().forEachByte(index, length, processor);
403 }
404
405 @Override
406 public int forEachByteDesc(int index, int length, ByteProcessor processor) {
407 return unwrap().forEachByteDesc(index, length, processor);
408 }
409 }
410