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 import io.netty.util.internal.ObjectUtil;
20
21 import java.io.IOException;
22 import java.io.InputStream;
23 import java.io.OutputStream;
24 import java.nio.ByteBuffer;
25 import java.nio.ByteOrder;
26 import java.nio.channels.FileChannel;
27 import java.nio.channels.GatheringByteChannel;
28 import java.nio.channels.ScatteringByteChannel;
29 import java.nio.charset.Charset;
30
31
32
33
34
35
36
37 @Deprecated
38 public class SwappedByteBuf extends ByteBuf {
39
40 private final ByteBuf buf;
41 private final ByteOrder order;
42
43 public SwappedByteBuf(ByteBuf buf) {
44 this.buf = ObjectUtil.checkNotNull(buf, "buf");
45 if (buf.order() == ByteOrder.BIG_ENDIAN) {
46 order = ByteOrder.LITTLE_ENDIAN;
47 } else {
48 order = ByteOrder.BIG_ENDIAN;
49 }
50 }
51
52 @Override
53 public ByteOrder order() {
54 return order;
55 }
56
57 @Override
58 public ByteBuf order(ByteOrder endianness) {
59 if (ObjectUtil.checkNotNull(endianness, "endianness") == order) {
60 return this;
61 }
62 return buf;
63 }
64
65 @Override
66 public ByteBuf unwrap() {
67 return buf;
68 }
69
70 @Override
71 public ByteBufAllocator alloc() {
72 return buf.alloc();
73 }
74
75 @Override
76 public int capacity() {
77 return buf.capacity();
78 }
79
80 @Override
81 public ByteBuf capacity(int newCapacity) {
82 buf.capacity(newCapacity);
83 return this;
84 }
85
86 @Override
87 public int maxCapacity() {
88 return buf.maxCapacity();
89 }
90
91 @Override
92 public boolean isReadOnly() {
93 return buf.isReadOnly();
94 }
95
96 @Override
97 public ByteBuf asReadOnly() {
98 return Unpooled.unmodifiableBuffer(this);
99 }
100
101 @Override
102 public boolean isDirect() {
103 return buf.isDirect();
104 }
105
106 @Override
107 public int readerIndex() {
108 return buf.readerIndex();
109 }
110
111 @Override
112 public ByteBuf readerIndex(int readerIndex) {
113 buf.readerIndex(readerIndex);
114 return this;
115 }
116
117 @Override
118 public int writerIndex() {
119 return buf.writerIndex();
120 }
121
122 @Override
123 public ByteBuf writerIndex(int writerIndex) {
124 buf.writerIndex(writerIndex);
125 return this;
126 }
127
128 @Override
129 public ByteBuf setIndex(int readerIndex, int writerIndex) {
130 buf.setIndex(readerIndex, writerIndex);
131 return this;
132 }
133
134 @Override
135 public int readableBytes() {
136 return buf.readableBytes();
137 }
138
139 @Override
140 public int writableBytes() {
141 return buf.writableBytes();
142 }
143
144 @Override
145 public int maxWritableBytes() {
146 return buf.maxWritableBytes();
147 }
148
149 @Override
150 public int maxFastWritableBytes() {
151 return buf.maxFastWritableBytes();
152 }
153
154 @Override
155 public boolean isReadable() {
156 return buf.isReadable();
157 }
158
159 @Override
160 public boolean isReadable(int size) {
161 return buf.isReadable(size);
162 }
163
164 @Override
165 public boolean isWritable() {
166 return buf.isWritable();
167 }
168
169 @Override
170 public boolean isWritable(int size) {
171 return buf.isWritable(size);
172 }
173
174 @Override
175 public ByteBuf clear() {
176 buf.clear();
177 return this;
178 }
179
180 @Override
181 public ByteBuf markReaderIndex() {
182 buf.markReaderIndex();
183 return this;
184 }
185
186 @Override
187 public ByteBuf resetReaderIndex() {
188 buf.resetReaderIndex();
189 return this;
190 }
191
192 @Override
193 public ByteBuf markWriterIndex() {
194 buf.markWriterIndex();
195 return this;
196 }
197
198 @Override
199 public ByteBuf resetWriterIndex() {
200 buf.resetWriterIndex();
201 return this;
202 }
203
204 @Override
205 public ByteBuf discardReadBytes() {
206 buf.discardReadBytes();
207 return this;
208 }
209
210 @Override
211 public ByteBuf discardSomeReadBytes() {
212 buf.discardSomeReadBytes();
213 return this;
214 }
215
216 @Override
217 public ByteBuf ensureWritable(int writableBytes) {
218 buf.ensureWritable(writableBytes);
219 return this;
220 }
221
222 @Override
223 public int ensureWritable(int minWritableBytes, boolean force) {
224 return buf.ensureWritable(minWritableBytes, force);
225 }
226
227 @Override
228 public boolean getBoolean(int index) {
229 return buf.getBoolean(index);
230 }
231
232 @Override
233 public byte getByte(int index) {
234 return buf.getByte(index);
235 }
236
237 @Override
238 public short getUnsignedByte(int index) {
239 return buf.getUnsignedByte(index);
240 }
241
242 @Override
243 public short getShort(int index) {
244 return ByteBufUtil.swapShort(buf.getShort(index));
245 }
246
247 @Override
248 public short getShortLE(int index) {
249 return buf.getShortLE(index);
250 }
251
252 @Override
253 public int getUnsignedShort(int index) {
254 return getShort(index) & 0xFFFF;
255 }
256
257 @Override
258 public int getUnsignedShortLE(int index) {
259 return getShortLE(index) & 0xFFFF;
260 }
261
262 @Override
263 public int getMedium(int index) {
264 return ByteBufUtil.swapMedium(buf.getMedium(index));
265 }
266
267 @Override
268 public int getMediumLE(int index) {
269 return buf.getMediumLE(index);
270 }
271
272 @Override
273 public int getUnsignedMedium(int index) {
274 return getMedium(index) & 0xFFFFFF;
275 }
276
277 @Override
278 public int getUnsignedMediumLE(int index) {
279 return getMediumLE(index) & 0xFFFFFF;
280 }
281
282 @Override
283 public int getInt(int index) {
284 return ByteBufUtil.swapInt(buf.getInt(index));
285 }
286
287 @Override
288 public int getIntLE(int index) {
289 return buf.getIntLE(index);
290 }
291
292 @Override
293 public long getUnsignedInt(int index) {
294 return getInt(index) & 0xFFFFFFFFL;
295 }
296
297 @Override
298 public long getUnsignedIntLE(int index) {
299 return getIntLE(index) & 0xFFFFFFFFL;
300 }
301
302 @Override
303 public long getLong(int index) {
304 return ByteBufUtil.swapLong(buf.getLong(index));
305 }
306
307 @Override
308 public long getLongLE(int index) {
309 return buf.getLongLE(index);
310 }
311
312 @Override
313 public char getChar(int index) {
314 return (char) getShort(index);
315 }
316
317 @Override
318 public float getFloat(int index) {
319 return Float.intBitsToFloat(getInt(index));
320 }
321
322 @Override
323 public double getDouble(int index) {
324 return Double.longBitsToDouble(getLong(index));
325 }
326
327 @Override
328 public ByteBuf getBytes(int index, ByteBuf dst) {
329 buf.getBytes(index, dst);
330 return this;
331 }
332
333 @Override
334 public ByteBuf getBytes(int index, ByteBuf dst, int length) {
335 buf.getBytes(index, dst, length);
336 return this;
337 }
338
339 @Override
340 public ByteBuf getBytes(int index, ByteBuf dst, int dstIndex, int length) {
341 buf.getBytes(index, dst, dstIndex, length);
342 return this;
343 }
344
345 @Override
346 public ByteBuf getBytes(int index, byte[] dst) {
347 buf.getBytes(index, dst);
348 return this;
349 }
350
351 @Override
352 public ByteBuf getBytes(int index, byte[] dst, int dstIndex, int length) {
353 buf.getBytes(index, dst, dstIndex, length);
354 return this;
355 }
356
357 @Override
358 public ByteBuf getBytes(int index, ByteBuffer dst) {
359 buf.getBytes(index, dst);
360 return this;
361 }
362
363 @Override
364 public ByteBuf getBytes(int index, OutputStream out, int length) throws IOException {
365 buf.getBytes(index, out, length);
366 return this;
367 }
368
369 @Override
370 public int getBytes(int index, GatheringByteChannel out, int length) throws IOException {
371 return buf.getBytes(index, out, length);
372 }
373
374 @Override
375 public int getBytes(int index, FileChannel out, long position, int length) throws IOException {
376 return buf.getBytes(index, out, position, length);
377 }
378
379 @Override
380 public CharSequence getCharSequence(int index, int length, Charset charset) {
381 return buf.getCharSequence(index, length, charset);
382 }
383
384 @Override
385 public ByteBuf setBoolean(int index, boolean value) {
386 buf.setBoolean(index, value);
387 return this;
388 }
389
390 @Override
391 public ByteBuf setByte(int index, int value) {
392 buf.setByte(index, value);
393 return this;
394 }
395
396 @Override
397 public ByteBuf setShort(int index, int value) {
398 buf.setShort(index, ByteBufUtil.swapShort((short) value));
399 return this;
400 }
401
402 @Override
403 public ByteBuf setShortLE(int index, int value) {
404 buf.setShortLE(index, (short) value);
405 return this;
406 }
407
408 @Override
409 public ByteBuf setMedium(int index, int value) {
410 buf.setMedium(index, ByteBufUtil.swapMedium(value));
411 return this;
412 }
413
414 @Override
415 public ByteBuf setMediumLE(int index, int value) {
416 buf.setMediumLE(index, value);
417 return this;
418 }
419
420 @Override
421 public ByteBuf setInt(int index, int value) {
422 buf.setInt(index, ByteBufUtil.swapInt(value));
423 return this;
424 }
425
426 @Override
427 public ByteBuf setIntLE(int index, int value) {
428 buf.setIntLE(index, value);
429 return this;
430 }
431
432 @Override
433 public ByteBuf setLong(int index, long value) {
434 buf.setLong(index, ByteBufUtil.swapLong(value));
435 return this;
436 }
437
438 @Override
439 public ByteBuf setLongLE(int index, long value) {
440 buf.setLongLE(index, value);
441 return this;
442 }
443
444 @Override
445 public ByteBuf setChar(int index, int value) {
446 setShort(index, value);
447 return this;
448 }
449
450 @Override
451 public ByteBuf setFloat(int index, float value) {
452 setInt(index, Float.floatToRawIntBits(value));
453 return this;
454 }
455
456 @Override
457 public ByteBuf setDouble(int index, double value) {
458 setLong(index, Double.doubleToRawLongBits(value));
459 return this;
460 }
461
462 @Override
463 public ByteBuf setBytes(int index, ByteBuf src) {
464 buf.setBytes(index, src);
465 return this;
466 }
467
468 @Override
469 public ByteBuf setBytes(int index, ByteBuf src, int length) {
470 buf.setBytes(index, src, length);
471 return this;
472 }
473
474 @Override
475 public ByteBuf setBytes(int index, ByteBuf src, int srcIndex, int length) {
476 buf.setBytes(index, src, srcIndex, length);
477 return this;
478 }
479
480 @Override
481 public ByteBuf setBytes(int index, byte[] src) {
482 buf.setBytes(index, src);
483 return this;
484 }
485
486 @Override
487 public ByteBuf setBytes(int index, byte[] src, int srcIndex, int length) {
488 buf.setBytes(index, src, srcIndex, length);
489 return this;
490 }
491
492 @Override
493 public ByteBuf setBytes(int index, ByteBuffer src) {
494 buf.setBytes(index, src);
495 return this;
496 }
497
498 @Override
499 public int setBytes(int index, InputStream in, int length) throws IOException {
500 return buf.setBytes(index, in, length);
501 }
502
503 @Override
504 public int setBytes(int index, ScatteringByteChannel in, int length) throws IOException {
505 return buf.setBytes(index, in, length);
506 }
507
508 @Override
509 public int setBytes(int index, FileChannel in, long position, int length) throws IOException {
510 return buf.setBytes(index, in, position, length);
511 }
512
513 @Override
514 public ByteBuf setZero(int index, int length) {
515 buf.setZero(index, length);
516 return this;
517 }
518
519 @Override
520 public int setCharSequence(int index, CharSequence sequence, Charset charset) {
521 return buf.setCharSequence(index, sequence, charset);
522 }
523
524 @Override
525 public boolean readBoolean() {
526 return buf.readBoolean();
527 }
528
529 @Override
530 public byte readByte() {
531 return buf.readByte();
532 }
533
534 @Override
535 public short readUnsignedByte() {
536 return buf.readUnsignedByte();
537 }
538
539 @Override
540 public short readShort() {
541 return ByteBufUtil.swapShort(buf.readShort());
542 }
543
544 @Override
545 public short readShortLE() {
546 return buf.readShortLE();
547 }
548
549 @Override
550 public int readUnsignedShort() {
551 return readShort() & 0xFFFF;
552 }
553
554 @Override
555 public int readUnsignedShortLE() {
556 return readShortLE() & 0xFFFF;
557 }
558
559 @Override
560 public int readMedium() {
561 return ByteBufUtil.swapMedium(buf.readMedium());
562 }
563
564 @Override
565 public int readMediumLE() {
566 return buf.readMediumLE();
567 }
568
569 @Override
570 public int readUnsignedMedium() {
571 return readMedium() & 0xFFFFFF;
572 }
573
574 @Override
575 public int readUnsignedMediumLE() {
576 return readMediumLE() & 0xFFFFFF;
577 }
578
579 @Override
580 public int readInt() {
581 return ByteBufUtil.swapInt(buf.readInt());
582 }
583
584 @Override
585 public int readIntLE() {
586 return buf.readIntLE();
587 }
588
589 @Override
590 public long readUnsignedInt() {
591 return readInt() & 0xFFFFFFFFL;
592 }
593
594 @Override
595 public long readUnsignedIntLE() {
596 return readIntLE() & 0xFFFFFFFFL;
597 }
598
599 @Override
600 public long readLong() {
601 return ByteBufUtil.swapLong(buf.readLong());
602 }
603
604 @Override
605 public long readLongLE() {
606 return buf.readLongLE();
607 }
608
609 @Override
610 public char readChar() {
611 return (char) readShort();
612 }
613
614 @Override
615 public float readFloat() {
616 return Float.intBitsToFloat(readInt());
617 }
618
619 @Override
620 public double readDouble() {
621 return Double.longBitsToDouble(readLong());
622 }
623
624 @Override
625 public ByteBuf readBytes(int length) {
626 return buf.readBytes(length).order(order());
627 }
628
629 @Override
630 public ByteBuf readSlice(int length) {
631 return buf.readSlice(length).order(order);
632 }
633
634 @Override
635 public ByteBuf readRetainedSlice(int length) {
636 return buf.readRetainedSlice(length).order(order);
637 }
638
639 @Override
640 public ByteBuf readBytes(ByteBuf dst) {
641 buf.readBytes(dst);
642 return this;
643 }
644
645 @Override
646 public ByteBuf readBytes(ByteBuf dst, int length) {
647 buf.readBytes(dst, length);
648 return this;
649 }
650
651 @Override
652 public ByteBuf readBytes(ByteBuf dst, int dstIndex, int length) {
653 buf.readBytes(dst, dstIndex, length);
654 return this;
655 }
656
657 @Override
658 public ByteBuf readBytes(byte[] dst) {
659 buf.readBytes(dst);
660 return this;
661 }
662
663 @Override
664 public ByteBuf readBytes(byte[] dst, int dstIndex, int length) {
665 buf.readBytes(dst, dstIndex, length);
666 return this;
667 }
668
669 @Override
670 public ByteBuf readBytes(ByteBuffer dst) {
671 buf.readBytes(dst);
672 return this;
673 }
674
675 @Override
676 public ByteBuf readBytes(OutputStream out, int length) throws IOException {
677 buf.readBytes(out, length);
678 return this;
679 }
680
681 @Override
682 public int readBytes(GatheringByteChannel out, int length) throws IOException {
683 return buf.readBytes(out, length);
684 }
685
686 @Override
687 public int readBytes(FileChannel out, long position, int length) throws IOException {
688 return buf.readBytes(out, position, length);
689 }
690
691 @Override
692 public CharSequence readCharSequence(int length, Charset charset) {
693 return buf.readCharSequence(length, charset);
694 }
695
696 @Override
697 public ByteBuf skipBytes(int length) {
698 buf.skipBytes(length);
699 return this;
700 }
701
702 @Override
703 public ByteBuf writeBoolean(boolean value) {
704 buf.writeBoolean(value);
705 return this;
706 }
707
708 @Override
709 public ByteBuf writeByte(int value) {
710 buf.writeByte(value);
711 return this;
712 }
713
714 @Override
715 public ByteBuf writeShort(int value) {
716 buf.writeShort(ByteBufUtil.swapShort((short) value));
717 return this;
718 }
719
720 @Override
721 public ByteBuf writeShortLE(int value) {
722 buf.writeShortLE((short) value);
723 return this;
724 }
725
726 @Override
727 public ByteBuf writeMedium(int value) {
728 buf.writeMedium(ByteBufUtil.swapMedium(value));
729 return this;
730 }
731
732 @Override
733 public ByteBuf writeMediumLE(int value) {
734 buf.writeMediumLE(value);
735 return this;
736 }
737
738 @Override
739 public ByteBuf writeInt(int value) {
740 buf.writeInt(ByteBufUtil.swapInt(value));
741 return this;
742 }
743
744 @Override
745 public ByteBuf writeIntLE(int value) {
746 buf.writeIntLE(value);
747 return this;
748 }
749
750 @Override
751 public ByteBuf writeLong(long value) {
752 buf.writeLong(ByteBufUtil.swapLong(value));
753 return this;
754 }
755
756 @Override
757 public ByteBuf writeLongLE(long value) {
758 buf.writeLongLE(value);
759 return this;
760 }
761
762 @Override
763 public ByteBuf writeChar(int value) {
764 writeShort(value);
765 return this;
766 }
767
768 @Override
769 public ByteBuf writeFloat(float value) {
770 writeInt(Float.floatToRawIntBits(value));
771 return this;
772 }
773
774 @Override
775 public ByteBuf writeDouble(double value) {
776 writeLong(Double.doubleToRawLongBits(value));
777 return this;
778 }
779
780 @Override
781 public ByteBuf writeBytes(ByteBuf src) {
782 buf.writeBytes(src);
783 return this;
784 }
785
786 @Override
787 public ByteBuf writeBytes(ByteBuf src, int length) {
788 buf.writeBytes(src, length);
789 return this;
790 }
791
792 @Override
793 public ByteBuf writeBytes(ByteBuf src, int srcIndex, int length) {
794 buf.writeBytes(src, srcIndex, length);
795 return this;
796 }
797
798 @Override
799 public ByteBuf writeBytes(byte[] src) {
800 buf.writeBytes(src);
801 return this;
802 }
803
804 @Override
805 public ByteBuf writeBytes(byte[] src, int srcIndex, int length) {
806 buf.writeBytes(src, srcIndex, length);
807 return this;
808 }
809
810 @Override
811 public ByteBuf writeBytes(ByteBuffer src) {
812 buf.writeBytes(src);
813 return this;
814 }
815
816 @Override
817 public int writeBytes(InputStream in, int length) throws IOException {
818 return buf.writeBytes(in, length);
819 }
820
821 @Override
822 public int writeBytes(ScatteringByteChannel in, int length) throws IOException {
823 return buf.writeBytes(in, length);
824 }
825
826 @Override
827 public int writeBytes(FileChannel in, long position, int length) throws IOException {
828 return buf.writeBytes(in, position, length);
829 }
830
831 @Override
832 public ByteBuf writeZero(int length) {
833 buf.writeZero(length);
834 return this;
835 }
836
837 @Override
838 public int writeCharSequence(CharSequence sequence, Charset charset) {
839 return buf.writeCharSequence(sequence, charset);
840 }
841
842 @Override
843 public int indexOf(int fromIndex, int toIndex, byte value) {
844 return buf.indexOf(fromIndex, toIndex, value);
845 }
846
847 @Override
848 public int bytesBefore(byte value) {
849 return buf.bytesBefore(value);
850 }
851
852 @Override
853 public int bytesBefore(int length, byte value) {
854 return buf.bytesBefore(length, value);
855 }
856
857 @Override
858 public int bytesBefore(int index, int length, byte value) {
859 return buf.bytesBefore(index, length, value);
860 }
861
862 @Override
863 public int forEachByte(ByteProcessor processor) {
864 return buf.forEachByte(processor);
865 }
866
867 @Override
868 public int forEachByte(int index, int length, ByteProcessor processor) {
869 return buf.forEachByte(index, length, processor);
870 }
871
872 @Override
873 public int forEachByteDesc(ByteProcessor processor) {
874 return buf.forEachByteDesc(processor);
875 }
876
877 @Override
878 public int forEachByteDesc(int index, int length, ByteProcessor processor) {
879 return buf.forEachByteDesc(index, length, processor);
880 }
881
882 @Override
883 public ByteBuf copy() {
884 return buf.copy().order(order);
885 }
886
887 @Override
888 public ByteBuf copy(int index, int length) {
889 return buf.copy(index, length).order(order);
890 }
891
892 @Override
893 public ByteBuf slice() {
894 return buf.slice().order(order);
895 }
896
897 @Override
898 public ByteBuf retainedSlice() {
899 return buf.retainedSlice().order(order);
900 }
901
902 @Override
903 public ByteBuf slice(int index, int length) {
904 return buf.slice(index, length).order(order);
905 }
906
907 @Override
908 public ByteBuf retainedSlice(int index, int length) {
909 return buf.retainedSlice(index, length).order(order);
910 }
911
912 @Override
913 public ByteBuf duplicate() {
914 return buf.duplicate().order(order);
915 }
916
917 @Override
918 public ByteBuf retainedDuplicate() {
919 return buf.retainedDuplicate().order(order);
920 }
921
922 @Override
923 public int nioBufferCount() {
924 return buf.nioBufferCount();
925 }
926
927 @Override
928 public ByteBuffer nioBuffer() {
929 return buf.nioBuffer().order(order);
930 }
931
932 @Override
933 public ByteBuffer nioBuffer(int index, int length) {
934 return buf.nioBuffer(index, length).order(order);
935 }
936
937 @Override
938 public ByteBuffer internalNioBuffer(int index, int length) {
939 return nioBuffer(index, length);
940 }
941
942 @Override
943 public ByteBuffer[] nioBuffers() {
944 ByteBuffer[] nioBuffers = buf.nioBuffers();
945 for (int i = 0; i < nioBuffers.length; i++) {
946 nioBuffers[i] = nioBuffers[i].order(order);
947 }
948 return nioBuffers;
949 }
950
951 @Override
952 public ByteBuffer[] nioBuffers(int index, int length) {
953 ByteBuffer[] nioBuffers = buf.nioBuffers(index, length);
954 for (int i = 0; i < nioBuffers.length; i++) {
955 nioBuffers[i] = nioBuffers[i].order(order);
956 }
957 return nioBuffers;
958 }
959
960 @Override
961 public boolean hasArray() {
962 return buf.hasArray();
963 }
964
965 @Override
966 public byte[] array() {
967 return buf.array();
968 }
969
970 @Override
971 public int arrayOffset() {
972 return buf.arrayOffset();
973 }
974
975 @Override
976 public boolean hasMemoryAddress() {
977 return buf.hasMemoryAddress();
978 }
979
980 @Override
981 public boolean isContiguous() {
982 return buf.isContiguous();
983 }
984
985 @Override
986 public long memoryAddress() {
987 return buf.memoryAddress();
988 }
989
990 @Override
991 public String toString(Charset charset) {
992 return buf.toString(charset);
993 }
994
995 @Override
996 public String toString(int index, int length, Charset charset) {
997 return buf.toString(index, length, charset);
998 }
999
1000 @Override
1001 public int refCnt() {
1002 return buf.refCnt();
1003 }
1004
1005 @Override
1006 final boolean isAccessible() {
1007 return buf.isAccessible();
1008 }
1009
1010 @Override
1011 public ByteBuf retain() {
1012 buf.retain();
1013 return this;
1014 }
1015
1016 @Override
1017 public ByteBuf retain(int increment) {
1018 buf.retain(increment);
1019 return this;
1020 }
1021
1022 @Override
1023 public ByteBuf touch() {
1024 buf.touch();
1025 return this;
1026 }
1027
1028 @Override
1029 public ByteBuf touch(Object hint) {
1030 buf.touch(hint);
1031 return this;
1032 }
1033
1034 @Override
1035 public boolean release() {
1036 return buf.release();
1037 }
1038
1039 @Override
1040 public boolean release(int decrement) {
1041 return buf.release(decrement);
1042 }
1043
1044 @Override
1045 public int hashCode() {
1046 return buf.hashCode();
1047 }
1048
1049 @Override
1050 public boolean equals(Object obj) {
1051 if (obj instanceof ByteBuf) {
1052 return ByteBufUtil.equals(this, (ByteBuf) obj);
1053 }
1054 return false;
1055 }
1056
1057 @Override
1058 public int compareTo(ByteBuf buffer) {
1059 return ByteBufUtil.compare(this, buffer);
1060 }
1061
1062 @Override
1063 public String toString() {
1064 return "Swapped(" + buf + ')';
1065 }
1066 }