History

Added some missing classes from java/nio, fixed some bad things

Dmitry Kabak (userdima committed 13 years ago

Commit 7d47bc81 parent b1be22084 files · +40111 −23Browse files

Showing the changes to java/pkg/java/nio/DirectByteBufferR.java (1 of 84 files). Show all

Unified · Split

java/pkg/java/nio/DirectByteBufferR.java+1009−0
@@ -0,0 +1,1009 @@
1/*
2 * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26// -- This file was mechanically generated: Do not edit! -- //
27
28package java.nio;
29
30import java.io.FileDescriptor;
31import sun.misc.Cleaner;
32import sun.misc.Unsafe;
33import sun.misc.VM;
34import sun.nio.ch.DirectBuffer;
35
36
37class DirectByteBufferR
38
39
40
41 extends DirectByteBuffer
42
43 implements DirectBuffer
44{
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114 // Primary constructor
115 //
116 DirectByteBufferR(int cap) { // package-private
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140 super(cap);
141
142 }
143
144
145
146
147
148
149
150
151
152
153
154
155
156 // For memory-mapped buffers -- invoked by FileChannelImpl via reflection
157 //
158 protected DirectByteBufferR(int cap, long addr,
159 FileDescriptor fd,
160 Runnable unmapper)
161 {
162
163
164
165
166
167
168 super(cap, addr, fd, unmapper);
169
170 }
171
172
173
174 // For duplicates and slices
175 //
176 DirectByteBufferR(DirectBuffer db, // package-private
177 int mark, int pos, int lim, int cap,
178 int off)
179 {
180
181
182
183
184
185
186
187
188 super(db, mark, pos, lim, cap, off);
189
190 }
191
192 public ByteBuffer slice() {
193 int pos = this.position();
194 int lim = this.limit();
195 assert (pos <= lim);
196 int rem = (pos <= lim ? lim - pos : 0);
197 int off = (pos << 0);
198 assert (off >= 0);
199 return new DirectByteBufferR(this, -1, 0, rem, rem, off);
200 }
201
202 public ByteBuffer duplicate() {
203 return new DirectByteBufferR(this,
204 this.markValue(),
205 this.position(),
206 this.limit(),
207 this.capacity(),
208 0);
209 }
210
211 public ByteBuffer asReadOnlyBuffer() {
212
213
214
215
216
217
218
219
220 return duplicate();
221
222 }
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275 public ByteBuffer put(byte x) {
276
277
278
279
280 throw new ReadOnlyBufferException();
281
282 }
283
284 public ByteBuffer put(int i, byte x) {
285
286
287
288
289 throw new ReadOnlyBufferException();
290
291 }
292
293 public ByteBuffer put(ByteBuffer src) {
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330 throw new ReadOnlyBufferException();
331
332 }
333
334 public ByteBuffer put(byte[] src, int offset, int length) {
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359 throw new ReadOnlyBufferException();
360
361 }
362
363 public ByteBuffer compact() {
364
365
366
367
368
369
370
371
372
373
374
375
376 throw new ReadOnlyBufferException();
377
378 }
379
380 public boolean isDirect() {
381 return true;
382 }
383
384 public boolean isReadOnly() {
385 return true;
386 }
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451 byte _get(int i) { // package-private
452 return unsafe.getByte(address + i);
453 }
454
455 void _put(int i, byte b) { // package-private
456
457
458
459 throw new ReadOnlyBufferException();
460
461 }
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484 private ByteBuffer putChar(long a, char x) {
485
486
487
488
489
490
491
492
493
494 throw new ReadOnlyBufferException();
495
496 }
497
498 public ByteBuffer putChar(char x) {
499
500
501
502
503 throw new ReadOnlyBufferException();
504
505 }
506
507 public ByteBuffer putChar(int i, char x) {
508
509
510
511
512 throw new ReadOnlyBufferException();
513
514 }
515
516 public CharBuffer asCharBuffer() {
517 int off = this.position();
518 int lim = this.limit();
519 assert (off <= lim);
520 int rem = (off <= lim ? lim - off : 0);
521
522 int size = rem >> 1;
523 if (!unaligned && ((address + off) % (1 << 1) != 0)) {
524 return (bigEndian
525 ? (CharBuffer)(new ByteBufferAsCharBufferRB(this,
526 -1,
527 0,
528 size,
529 size,
530 off))
531 : (CharBuffer)(new ByteBufferAsCharBufferRL(this,
532 -1,
533 0,
534 size,
535 size,
536 off)));
537 } else {
538 return (nativeByteOrder
539 ? (CharBuffer)(new DirectCharBufferRU(this,
540 -1,
541 0,
542 size,
543 size,
544 off))
545 : (CharBuffer)(new DirectCharBufferRS(this,
546 -1,
547 0,
548 size,
549 size,
550 off)));
551 }
552 }
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575 private ByteBuffer putShort(long a, short x) {
576
577
578
579
580
581
582
583
584
585 throw new ReadOnlyBufferException();
586
587 }
588
589 public ByteBuffer putShort(short x) {
590
591
592
593
594 throw new ReadOnlyBufferException();
595
596 }
597
598 public ByteBuffer putShort(int i, short x) {
599
600
601
602
603 throw new ReadOnlyBufferException();
604
605 }
606
607 public ShortBuffer asShortBuffer() {
608 int off = this.position();
609 int lim = this.limit();
610 assert (off <= lim);
611 int rem = (off <= lim ? lim - off : 0);
612
613 int size = rem >> 1;
614 if (!unaligned && ((address + off) % (1 << 1) != 0)) {
615 return (bigEndian
616 ? (ShortBuffer)(new ByteBufferAsShortBufferRB(this,
617 -1,
618 0,
619 size,
620 size,
621 off))
622 : (ShortBuffer)(new ByteBufferAsShortBufferRL(this,
623 -1,
624 0,
625 size,
626 size,
627 off)));
628 } else {
629 return (nativeByteOrder
630 ? (ShortBuffer)(new DirectShortBufferRU(this,
631 -1,
632 0,
633 size,
634 size,
635 off))
636 : (ShortBuffer)(new DirectShortBufferRS(this,
637 -1,
638 0,
639 size,
640 size,
641 off)));
642 }
643 }
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666 private ByteBuffer putInt(long a, int x) {
667
668
669
670
671
672
673
674
675
676 throw new ReadOnlyBufferException();
677
678 }
679
680 public ByteBuffer putInt(int x) {
681
682
683
684
685 throw new ReadOnlyBufferException();
686
687 }
688
689 public ByteBuffer putInt(int i, int x) {
690
691
692
693
694 throw new ReadOnlyBufferException();
695
696 }
697
698 public IntBuffer asIntBuffer() {
699 int off = this.position();
700 int lim = this.limit();
701 assert (off <= lim);
702 int rem = (off <= lim ? lim - off : 0);
703
704 int size = rem >> 2;
705 if (!unaligned && ((address + off) % (1 << 2) != 0)) {
706 return (bigEndian
707 ? (IntBuffer)(new ByteBufferAsIntBufferRB(this,
708 -1,
709 0,
710 size,
711 size,
712 off))
713 : (IntBuffer)(new ByteBufferAsIntBufferRL(this,
714 -1,
715 0,
716 size,
717 size,
718 off)));
719 } else {
720 return (nativeByteOrder
721 ? (IntBuffer)(new DirectIntBufferRU(this,
722 -1,
723 0,
724 size,
725 size,
726 off))
727 : (IntBuffer)(new DirectIntBufferRS(this,
728 -1,
729 0,
730 size,
731 size,
732 off)));
733 }
734 }
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757 private ByteBuffer putLong(long a, long x) {
758
759
760
761
762
763
764
765
766
767 throw new ReadOnlyBufferException();
768
769 }
770
771 public ByteBuffer putLong(long x) {
772
773
774
775
776 throw new ReadOnlyBufferException();
777
778 }
779
780 public ByteBuffer putLong(int i, long x) {
781
782
783
784
785 throw new ReadOnlyBufferException();
786
787 }
788
789 public LongBuffer asLongBuffer() {
790 int off = this.position();
791 int lim = this.limit();
792 assert (off <= lim);
793 int rem = (off <= lim ? lim - off : 0);
794
795 int size = rem >> 3;
796 if (!unaligned && ((address + off) % (1 << 3) != 0)) {
797 return (bigEndian
798 ? (LongBuffer)(new ByteBufferAsLongBufferRB(this,
799 -1,
800 0,
801 size,
802 size,
803 off))
804 : (LongBuffer)(new ByteBufferAsLongBufferRL(this,
805 -1,
806 0,
807 size,
808 size,
809 off)));
810 } else {
811 return (nativeByteOrder
812 ? (LongBuffer)(new DirectLongBufferRU(this,
813 -1,
814 0,
815 size,
816 size,
817 off))
818 : (LongBuffer)(new DirectLongBufferRS(this,
819 -1,
820 0,
821 size,
822 size,
823 off)));
824 }
825 }
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848 private ByteBuffer putFloat(long a, float x) {
849
850
851
852
853
854
855
856
857
858 throw new ReadOnlyBufferException();
859
860 }
861
862 public ByteBuffer putFloat(float x) {
863
864
865
866
867 throw new ReadOnlyBufferException();
868
869 }
870
871 public ByteBuffer putFloat(int i, float x) {
872
873
874
875
876 throw new ReadOnlyBufferException();
877
878 }
879
880 public FloatBuffer asFloatBuffer() {
881 int off = this.position();
882 int lim = this.limit();
883 assert (off <= lim);
884 int rem = (off <= lim ? lim - off : 0);
885
886 int size = rem >> 2;
887 if (!unaligned && ((address + off) % (1 << 2) != 0)) {
888 return (bigEndian
889 ? (FloatBuffer)(new ByteBufferAsFloatBufferRB(this,
890 -1,
891 0,
892 size,
893 size,
894 off))
895 : (FloatBuffer)(new ByteBufferAsFloatBufferRL(this,
896 -1,
897 0,
898 size,
899 size,
900 off)));
901 } else {
902 return (nativeByteOrder
903 ? (FloatBuffer)(new DirectFloatBufferRU(this,
904 -1,
905 0,
906 size,
907 size,
908 off))
909 : (FloatBuffer)(new DirectFloatBufferRS(this,
910 -1,
911 0,
912 size,
913 size,
914 off)));
915 }
916 }
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939 private ByteBuffer putDouble(long a, double x) {
940
941
942
943
944
945
946
947
948
949 throw new ReadOnlyBufferException();
950
951 }
952
953 public ByteBuffer putDouble(double x) {
954
955
956
957
958 throw new ReadOnlyBufferException();
959
960 }
961
962 public ByteBuffer putDouble(int i, double x) {
963
964
965
966
967 throw new ReadOnlyBufferException();
968
969 }
970
971 public DoubleBuffer asDoubleBuffer() {
972 int off = this.position();
973 int lim = this.limit();
974 assert (off <= lim);
975 int rem = (off <= lim ? lim - off : 0);
976
977 int size = rem >> 3;
978 if (!unaligned && ((address + off) % (1 << 3) != 0)) {
979 return (bigEndian
980 ? (DoubleBuffer)(new ByteBufferAsDoubleBufferRB(this,
981 -1,
982 0,
983 size,
984 size,
985 off))
986 : (DoubleBuffer)(new ByteBufferAsDoubleBufferRL(this,
987 -1,
988 0,
989 size,
990 size,
991 off)));
992 } else {
993 return (nativeByteOrder
994 ? (DoubleBuffer)(new DirectDoubleBufferRU(this,
995 -1,
996 0,
997 size,
998 size,
999 off))
1000 : (DoubleBuffer)(new DirectDoubleBufferRS(this,
1001 -1,
1002 0,
1003 size,
1004 size,
1005 off)));
1006 }
1007 }
1008
1009}